setIntervalGlobal

// setInterval wit global update

var x = 2;

setInterval(function(){
    // print number of apples
    console.log('I have ' + x + ' apples right now.');

    // increment by 1
    x = x + 1;
    console.log('I added another apple.');

    // show result
    console.log('Now I have ' + x + ' apples.');
}, 1000);

Comments

Popular posts from this blog

Lesson 2 Chat

Arrays