<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h1>Chai aur Javascript</h1> <button id="start">Start</button> <button id="stop">Stop</button> </body> <script> const sayDate = function(str){ console.log(str, Date.now()); } const intervalId = setInterval(sayDate, 1000, "hi") // it wil print date after 1 sec clearInterval(intervalId) // for stopping the setInterval </script> </html>