Javascript Variable Issue
why does this http://jsfiddle.net/BkGxq/1/ return '$undefined' ? if i dont do level_prices['f'.i] = i; and do level_prices[i] = i; it works, (i also change it in the html to v
Solution 1:
The dot is not the string concatenation operator, but the property accessor. You want
level_prices['f'+i] = i;
'f'.i
gets the literal "i" property of the string object, which is undefined
.
Solution 2:
In JavaScript, you concatenate strings with +
instead of .
Try:
level_prices['f'+i] = i;
Edit: updated your JSFiddle: http://jsfiddle.net/BkGxq/2/
Post a Comment for "Javascript Variable Issue"