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
Written by Will
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Related Tags
#coffeescript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#