I want to make a counter that will count(and add up) each second. I'm trying to do it with the timing events but it doesn't work
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
var i=0;
function Time(){
seconds = setInterval(function(){
i++;
}, 1000);
return {label:seconds};
}
console.log(setTimeout(Time, 1000));
</script>
</body>
</html>
it just shows the first iteration and also it starts from 2 instead of 1...
SetIntervalwill return the ID value that can be used toclearInterval. Why are you mapping it toseconds?