setInterval() will call a function each 1 second, since we have set it for 1000 (milliseconds)
<button type="button" onclick="clearInterval(timer)">Stop the clock</button>