Let’s say I have an array of data and a variable (or multiple variables)
var i = 1;
var arr = {
1: ['whatever' + i,'there are ' + i + ' dogs in the yard.', etc],
}
Is there a way to dynamically update the variable(s) in the array later on in a function?
So
function start() {
i++;
alert(arr[1][0]);
}
Would output “whatever2” instead of “whatever1”
You could use functions instead:
Which would change your calls to: