I discovered that the website was trying to load an image with id 360, but that image didn't exist, and the whole function I designed was to make sure the id never exceeded 359 under any circumstances, so I don't know why. ..
You didn't design the function that way. Using 1 and 2 will give you that result... If you want all images from 359 to 0, why not just get them and display them in order?
console.log(test(1,1)) // 359 console.log(test(1,2)) // 360 function test(row, col) { return 359 - ((row - 1) * 24) + (col - 1) }