I have created a function that positions my objects based on the array they are assigned to.
For example, if they are in players[0], they will be placed in one position, and if they are in players[1], they will be placed elsewhere. The X and Y values are just placeholders for actual pixel values, which can vary significantly.
This function also takes a flag as a parameter to determine whether the source continues to the same location or changes to another source. Everything is functioning correctly.
function putHands(flag){
let show;
if(flag == true) show= true;
else show = false;
for(let i = 0; i < 4; i++){
for(let j = 0; j < 13; j++){
if(i == 0 || i == 1 || i == 2 || i == 3){
players[i][j].style.left = X;
players[i][j].style.top = Y;
}
if(show == true)
players[i][j].src = '../images/c'+players[i][j].id+'.gif';
}
}
}
Now, I want to include an event listener that changes the src of each object when hovered over. However, my attempts have resulted in an error message whenever I move the mouse over the objects:
Uncaught TypeError: Cannot read property '13' of undefined