Skip to content

Commit a628ce8

Browse files
committed
StopWatch
1 parent 76d637b commit a628ce8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/All Assessment/assessment01/StopWatch.jsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import React, { useEffect, useState } from "react";
2-
import '../../index.css'
2+
import "../../index.css";
33
import GoToHome from "../../Components/GoToHome";
44

55
const StopWatch = () => {
66
const [clicked, setClicked] = useState(false);
77
const [time, setTime] = useState(0);
88

9-
10-
119
useEffect(() => {
1210
let interval;
1311
if (clicked) {
1412
interval = setInterval(() => {
15-
setTime(prevTime => prevTime + 1);
13+
setTime((prevTime) => prevTime + 1);
1614
}, 500);
1715
} else {
1816
clearInterval(interval);
@@ -24,13 +22,10 @@ const StopWatch = () => {
2422
return (
2523
<div className="flex flex-col items-center justify-center h-screen gap-10">
2624
<div className="text-6xl">{time}</div>
27-
<button
28-
className="custom-button"
29-
onClick={() => setClicked(!clicked)}
30-
>
31-
{clicked ? 'Stop' : 'Start'}
25+
<button className="custom-button" onClick={() => setClicked(!clicked)}>
26+
{clicked ? "Stop" : "Start"}
3227
</button>
33-
<GoToHome/>
28+
<GoToHome />
3429
</div>
3530
);
3631
};

0 commit comments

Comments
 (0)