I just try to build a counter, which counts the seconds but it prints the second only once. Actually, the times function runs each second but it does not update the printed value before. Is there any way for it?
var times = () => {
const d = new Date();
return d.getSeconds();
}
console.log(setInterval(times, 1000)); // Write the console.log once and update the inner value each second