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"
ilater on, that's not possible.'whatever' + iand'there are ' + i + ' dogs in the yard.'are evaluated when the array is defined, i.e. the value ofiis determined at that moment and that value is concatenated with the other string.