diff --git a/index.html b/index.html
index 0f7fb66..6568f00 100644
--- a/index.html
+++ b/index.html
@@ -24,6 +24,7 @@
Progress: 0% (0/0 tasks completed)
00:00:00
+
diff --git a/script.js b/script.js
index ca39a81..c3f1cd3 100644
--- a/script.js
+++ b/script.js
@@ -97,4 +97,27 @@ function updateTime() {
function pad(num) {
return num < 10 ? "0" + num : num;
+}
+//stop timer when task is completed
+function stop() {
+ let total = tasks.length;
+ if (total === 0) return;
+ let doneTasks = tasks.filter(task => task.done).length;
+ let percent = Math.round((doneTasks / total) * 100);
+
+ if (percent === 100) {
+ stopTimer();
+ }
+}
+ function toggleTask(index) {
+ tasks[index].done = !tasks[index].done;
+ renderTasks();
+ stop();
+}
+// Restart
+function Restart(){
+ seconds=0;
+ updateTime();
+ tasks = [];
+ renderTasks();
}
\ No newline at end of file