0

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);
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
Mona Coder
  • 6,212
  • 18
  • 66
  • 128

0 Answers0