Reputation: 17467
I have an array
daysoftheweek:['Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday'],
Also I have functions
function totalMonday() {}
function totalTuesday() {}
Can I use variable substitution to call them?
total+{daysoftheweek[0]}
Upvotes: 0
Views: 123
Reputation: 66488
Use bracket notation on window object:
window['total' + daysoftheweek[0]]()
Upvotes: 5