epioua
Last Updated: February 25, 2016
·
5.38K
· willrax
Profile

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
Say Thanks
Respond

1 Response
Add your response

7139

How to pass some parameter to this function?

(for ex., I have variable @myWindow upper from the setInterval code and wanna to output every 5 seconds @myWindow.location.href; )

over 1 year ago ·