Hello I have a JSON array data.cells that I need to iterate through to get the values out of and put the values into an onclick event listener.
Right now the variable name data.cells.letter is being based through the buildString function for each cell in my board, instead of the value of the variable. Same goes for the x and y variables.
for(var i = 0; i < data.cells.length; i++) {
var x = i % 4 + 1;
var y = 0;
if(i < 4) {
y = 1;
}
else if(i < 8) {
y = 2;
}
else if(i < 12) {
y = 3;
}
else {
y = 4;
}
document.getElementById('t' + i).addEventListener('click',function(data){
buildString(this, data.cells[i].letter, x, y);}, false);
document.getElementById('t' + i).setTextValue(data.cells[i].letter);
}