It’s important to note that setInterval is defined as:
A method that calls a function or evaluates an expression at specified intervals (in milliseconds).
It continues to call this interval until clearInterval() is used.
Notice that it uses milliseconds as opposed to normal seconds. This gives us a lot more flexibility as we can utilize half second intervals if need be. In the case below, I convert seconds to milliseconds by multiplying it by 1000.
//define variables, and convert to milliseconds for usage with setInterval()
var seconds = 6;
var millisecs = seconds*1000;
//Start the function containing the timer
//use the setInterval() function
//Clear the interval for the timer.
//Write a function that does something when the setInterval is fired.
alert("This will fire every "+seconds+" seconds")