I'm trying to push elements into array X
while iterating through array Y
. At some point, while pushing a new element into array X, I get an "Unexpected token :" error in the browser console. I am able to push several elements properly before it fails (almost every time around 7th element).
It is recursive function, and maybe that causes an issue... Here is the code:
function getPosition(img) {
var tmpRandPosition = Math.floor(Math.random() * (9));
if($.inArray(galleryPositions[tmpRandPosition], populatedPositions) != -1) {
setTimeout("getPosition("+img+")",1);
} else {
populatedPositions.push(galleryPositions[tmpRandPosition]);
return true;
}
}
As you can see from the script, I'm trying to display photos randomly at 8 different positioned elements in HTML.