In the previous lessons, our timer started its work as soon as the page loaded. Let's now make a button, by clicking on which our timer will start:
<button id="start">start</button>
Let's write the appropriate JavaScript:
let start = document.querySelector('#start');
start.addEventListener('click', function() {
let i = 0;
setInterval(function() {
console.log(++i);
}, 1000);
});
Make a button, by clicking on which a countdown
will be displayed in the console,
starting from 100
.