Snorlax Snorlax - 3 months ago 7x
jQuery Question

Javascript: Looping Through Images

I have an array of images that I want to loop through infinitely but I can't seem to get the logic down, this is my attempt:

var imagesArray = ["",

var count = 0;

var loopImages = function(count){

$('#firstStar').fadeIn(1500, function(){

if (count=0){
$('img').attr('src', imagesArray[1]);

$('#firstStar').delay(4000).fadeOut(1500, loopImages(count));
console.log('Ending Count:'+count);

loopImages(count); //Step 1: Initiate Loop, passing count, starting at 0;

<script src=""></script>
<img src="" id="firstStar">


I have edited the code to make it work:

In particular, see usage of the modulo (%) operator and the .bind function.