epioua
Last Updated: April 14, 2019
·
6.643K
· willrax

setInterval with Coffeescript

This will run the setInterval function every 2 secs. It grabs a random word from the array and replaces the text in the phrase span with it.

$(document).ready ->
    setInterval () ->
        a = ['WOOHOO!', 'YAY!', 'HOORAY!']
        w = a[Math.floor(Math.random()*a.length)];
        $('#phrase').text(w)
    , 2000