I am trying to change the source of an image every 5 second loading from and array of arrays called imgs
,but I am getting this error
Uncaught TypeError: Cannot read property '3' of undefined
at
$("#map_image").attr("src", path+ imgs[i][j]);
What am I doing wrong?
let i;
let j;
for (i = 0; i < imgs.length; i++) {
for (j = 0; j < imgs[i].length; j++) {
(function(index) {
setTimeout(function() {
$("#map_image").attr("src", path+ imgs[i][j]);
}, i * 5000);
})(i);
}