Skip to content
Permalink
57c2045312
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
21 lines (18 sloc) 650 Bytes
let startBtn = document.querySelector('#start')
let stopBtn = document.querySelector('#stop')
let intervalId;
let timer = document.querySelector('#timer')
let counter = 0;
function change(){
timer.innerHTML = "Seconds Passed: " + counter;
}
startBtn.addEventListener('click', function(){
intervalId = setInterval(function(){
console.log('1 second has passed')
counter += 1;
change();
}, 1000)
})
stopBtn.addEventListener('click', function(){
clearInterval(intervalId)
})