From 4c276e6df247a978ec5eb4ab3f614b3c0ccc5cdd Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:00:30 +0100 Subject: [PATCH 01/18] complete Chronometer constructor --- javascript/chronometer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 7a13496..8d854df 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -1,6 +1,8 @@ class Chronometer { constructor() { // ... your code goes here + this.currentTime = 0; + this.intervalId = null; } start(callback) { From 94a2040b5a08996794f9e44ad5031ed4e9f30696 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:04:10 +0100 Subject: [PATCH 02/18] complete Chronometer start method --- javascript/chronometer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 8d854df..93447e5 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -7,6 +7,12 @@ class Chronometer { start(callback) { // ... your code goes here + this.intervalId = setInterval(() => { + this.currentTime += 1; + if (callback) { + callback(); + } + }, 1000); } getMinutes() { From 2211a7523e245b84515b8f060f0838e17defa833 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:05:25 +0100 Subject: [PATCH 03/18] complete Chronometer getMinutes() --- javascript/chronometer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 93447e5..19030fa 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -17,6 +17,7 @@ class Chronometer { getMinutes() { // ... your code goes here + return Math.floor(this.currentTime / 60); } getSeconds() { From 168e1e4a5cf2edfcba953c27575eb4b019dba8bc Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:06:33 +0100 Subject: [PATCH 04/18] complete Chronometer getSeconds() --- javascript/chronometer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 19030fa..42675ad 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -22,6 +22,7 @@ class Chronometer { getSeconds() { // ... your code goes here + return this.currentTime % 60; } computeTwoDigitNumber(value) { From 205d84154a52bdaf75cc2cae3eacb447c5ffdefc Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:07:36 +0100 Subject: [PATCH 05/18] complete Chronometer computeTwoDigitNumber() --- javascript/chronometer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 42675ad..01cccc3 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -27,6 +27,7 @@ class Chronometer { computeTwoDigitNumber(value) { // ... your code goes here + return value < 10 ? `0${value}` : `${value}`; } stop() { From 6124c9b0ec12cfd80c502b2a2c22444152a059ba Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:08:17 +0100 Subject: [PATCH 06/18] complete stop() method --- javascript/chronometer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 01cccc3..8f205e7 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -32,6 +32,7 @@ class Chronometer { stop() { // ... your code goes here + clearInterval(this.intervalId); } reset() { From bec6e8d127de700b07f8f0c918ca38e84c58f2a3 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:08:53 +0100 Subject: [PATCH 07/18] complete reset() method --- javascript/chronometer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index 8f205e7..d1fd7ed 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -37,6 +37,7 @@ class Chronometer { reset() { // ... your code goes here + this.currentTime = 0; } split() { From 5667e6810467d68a6ee3abf59a25ea8c56b4bc54 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Mon, 20 Oct 2025 17:09:25 +0100 Subject: [PATCH 08/18] complete split() method --- javascript/chronometer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/javascript/chronometer.js b/javascript/chronometer.js index d1fd7ed..538649c 100644 --- a/javascript/chronometer.js +++ b/javascript/chronometer.js @@ -42,6 +42,9 @@ class Chronometer { split() { // ... your code goes here + const minutes = this.computeTwoDigitNumber(this.getMinutes()); + const seconds = this.computeTwoDigitNumber(this.getSeconds()); + return `${minutes}:${seconds}`; } } From e381e378ef917a343a406f2dbac9caaaa6d81930 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 18:22:28 +0000 Subject: [PATCH 09/18] complete printTime() --- javascript/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/javascript/index.js b/javascript/index.js index fb3a43a..1313175 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -15,23 +15,32 @@ const splitsElement = document.getElementById('splits'); function printTime() { // ... your code goes here + printMinutes(); + printSeconds(); + printMilliseconds(); } function printMinutes() { // ... your code goes here + } function printSeconds() { // ... your code goes here + + } // ==> BONUS function printMilliseconds() { // ... your code goes here + + } function printSplit() { // ... your code goes here + } function clearSplits() { @@ -57,6 +66,8 @@ function setResetBtn() { // Start/Stop Button btnLeftElement.addEventListener('click', () => { // ... your code goes here + + }); // Reset/Split Button From 72ac07e52e62fef9aa62e99f62a740625f7eb3b6 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:45:48 +0000 Subject: [PATCH 10/18] complete printMinutes() --- javascript/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/javascript/index.js b/javascript/index.js index 1313175..2ee0e25 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -22,6 +22,10 @@ function printTime() { function printMinutes() { // ... your code goes here + const minutes = chronometer.getMinutes(); + const minutesString = chronometer.computeTwoDigitNumber(minutes); + minDecElement.textContent = minutesString[0]; + minUniElement.textContent = minutesString[1]; } From 118a329117a720bf1a22e7db1c967b1ca83e95f9 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:47:05 +0000 Subject: [PATCH 11/18] complete printSeconds() --- javascript/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/index.js b/javascript/index.js index 2ee0e25..57e5504 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -31,8 +31,10 @@ function printMinutes() { function printSeconds() { // ... your code goes here - - + const seconds = chronometer.getSeconds(); + const secondsString = chronometer.computeTwoDigitNumber(seconds); + secDecElement.textContent = secondsString[0]; + secUniElement.textContent = secondsString[1]; } // ==> BONUS From 16ae17d33306d3b1cad44e00aee48dee5cf09cad Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:48:15 +0000 Subject: [PATCH 12/18] complete printMilliSeconds() --- javascript/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/index.js b/javascript/index.js index 57e5504..5006c53 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -40,8 +40,10 @@ function printSeconds() { // ==> BONUS function printMilliseconds() { // ... your code goes here - - + const milliseconds = chronometer.getMilliseconds(); + const millisecondsString = chronometer.computeTwoDigitNumber(milliseconds); + milDecElement.textContent = millisecondsString[0]; + milUniElement.textContent = millisecondsString[1]; } function printSplit() { From 310f54da038d4b9d9b1a69c55e0315b555cbed48 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:49:35 +0000 Subject: [PATCH 13/18] complete printSplit() --- javascript/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/javascript/index.js b/javascript/index.js index 5006c53..1348d08 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -48,7 +48,10 @@ function printMilliseconds() { function printSplit() { // ... your code goes here - + const splitTime = chronometer.split(); + const li = document.createElement('li'); + li.textContent = splitTime; + splitsElement.appendChild(li); } function clearSplits() { From 40b8273ee11a668779f9ecb401c1e7bba298f074 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:52:06 +0000 Subject: [PATCH 14/18] complete clearSplits() --- javascript/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/index.js b/javascript/index.js index 1348d08..f664dee 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -56,6 +56,7 @@ function printSplit() { function clearSplits() { // ... your code goes here + splitsElement.innerHTML = ''; } function setStopBtn() { From 3a0ca9f839d8af7075b070c6540c78d459842463 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:56:06 +0000 Subject: [PATCH 15/18] complete set functions for buttons --- javascript/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/javascript/index.js b/javascript/index.js index f664dee..0e20ee9 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -48,10 +48,10 @@ function printMilliseconds() { function printSplit() { // ... your code goes here - const splitTime = chronometer.split(); - const li = document.createElement('li'); - li.textContent = splitTime; - splitsElement.appendChild(li); +const splitTime = chronometer.split(); +const liElement = document.createElement('li'); +liElement.textContent = splitTime; +splitsElement.appendChild(liElement); } function clearSplits() { @@ -61,18 +61,26 @@ function clearSplits() { function setStopBtn() { // ... your code goes here + btnLeftElement.textContent = 'STOP'; + btnLeftElement.className = 'btn stop'; } function setSplitBtn() { // ... your code goes here + btnRightElement.textContent = 'SPLIT'; + btnRightElement.className = 'btn split'; } function setStartBtn() { // ... your code goes here + btnLeftElement.textContent = 'START'; + btnLeftElement.className = 'btn start'; } function setResetBtn() { // ... your code goes here + btnRightElement.textContent = 'RESET'; + btnRightElement.className = 'btn reset'; } // Start/Stop Button From d8ccc90eaad3e929f0786294886d2c78e10a4060 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 20:59:10 +0000 Subject: [PATCH 16/18] update printSplit() --- javascript/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/javascript/index.js b/javascript/index.js index 0e20ee9..2f08370 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -48,10 +48,10 @@ function printMilliseconds() { function printSplit() { // ... your code goes here -const splitTime = chronometer.split(); -const liElement = document.createElement('li'); -liElement.textContent = splitTime; -splitsElement.appendChild(liElement); + const li = document.createElement('li'); + li.className = 'split-item'; + li.textContent = chronometer.split(); + splitsElement.appendChild(li); } function clearSplits() { From 29df0d9526a8402e251430601114790140250e98 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 21:01:58 +0000 Subject: [PATCH 17/18] complete btnLeftElement.addEventListener() --- javascript/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/javascript/index.js b/javascript/index.js index 2f08370..c28d574 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -86,8 +86,15 @@ function setResetBtn() { // Start/Stop Button btnLeftElement.addEventListener('click', () => { // ... your code goes here - - + if(btnLeftElement.classList.contains('start')){ + chronometer.start(printTime); + setStopBtn(); + setSplitBtn(); + } else { + chronometer.stop(); + setStartBtn(); + setResetBtn(); + } }); // Reset/Split Button From eb2d7fe8311e70681dd5d013ea04f3f57e15df20 Mon Sep 17 00:00:00 2001 From: SiyaM108 Date: Wed, 29 Oct 2025 21:04:07 +0000 Subject: [PATCH 18/18] complete btnRightElement.addEventListener() --- javascript/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/javascript/index.js b/javascript/index.js index c28d574..cc54622 100644 --- a/javascript/index.js +++ b/javascript/index.js @@ -100,4 +100,11 @@ btnLeftElement.addEventListener('click', () => { // Reset/Split Button btnRightElement.addEventListener('click', () => { // ... your code goes here + if(btnRightElement.classList.contains('reset')){ + chronometer.reset(); + clearSplits(); + printTime(); + } else { + printSplit(); + } });