var i = 1
var pattern1 = ["apple", "pear", "orange", "carrot"]
var pattern2 = ["apple", "pear", "orange", "carrot"]
var currentPat = "pattern" + i
alert(currentPat)
The currentPat variable is returning the string pattern1, its not returning the array. What am i doing wrong?
pattern1[i]. Note that broken code isn't a great substitute for a properly detailed explanation of what you are trying to accomplishvar currentPat = window["pattern" + i]does what you want.