Counter 1 to 10 with Time out in HTML,JS

0 0
Read Time:17 Second
<!DOCTYPE html>
<html>
	<head>
		<title>Page Title</title>
	</head>
	<body>
        <h1 id="counter"></h1>
		<script>
           let time = 1

const interval = setInterval(() => {

 document.getElementById("counter").innerHTML=time;
                // time is up
  if (time === 10) {
      document.getElementById("counter").innerHTML="TimeUp";
    clearInterval(interval);
  }

  time++;
}, 1000);
        </script>

        
	</body>
</html>
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
100 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Comment

Verified by MonsterInsights