From 301ea630acfa482fd155e83c79c874c0622a453d Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 14:46:02 +0100 Subject: [PATCH 01/59] List edge cases for test. --- format-clock-edge-cases/timeConverter.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 88f2af094..485e13c8b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -9,3 +9,18 @@ test("correctly convert time after 12:00", function(){ test("can correctly convert morning time", function() { assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); + +/* +Edge cases to be tested. + +1. 00:00 +2. 00:01 +3. 01:00 +4. 09:05 +5. 11:59 +6. 23:59 +7. 12:00 +8. 12:01 +9. 12:59 +10.13:00 +*/ \ No newline at end of file From 2501561c60d5751117e7f4369848fcd7c950ceac Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:12:24 +0100 Subject: [PATCH 02/59] Update list. --- format-clock-edge-cases/timeConverter.test.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 485e13c8b..8003a1feb 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -6,21 +6,26 @@ test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); -test("can correctly convert morning time", function() { +test("can correctly convert morning time", function(){ assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); +test("can correctly convert morning time", function (){ + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +}); + /* Edge cases to be tested. + Input Expected What it tests -1. 00:00 -2. 00:01 -3. 01:00 -4. 09:05 -5. 11:59 -6. 23:59 -7. 12:00 -8. 12:01 -9. 12:59 -10.13:00 +1. 00:00 -> 12:00 am Midnight: hour 0 becomes 12 +2. 00:01 -> 12:01 am Just after midnight, still 12 +3. 01:00 -> 01:00 am First normal morning hour +4. 09:05 -> 09:05 am Leading zeros in hour and minute +5. 11:59 -> 11:59 am Last minute before noon +6. 23:59 -> 11:59 pm Last minute of the day +7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 +8. 12:01 -> 12:01 pm Just after noon, must not become 00 +9. 12:59 -> 12:59 pm Last minute of the noon hour +10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded */ \ No newline at end of file From 63e477b4d8dc96b53edf7d343581a5d6e223335b Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:36:21 +0100 Subject: [PATCH 03/59] Add an if condition to check midnight --- format-clock-edge-cases/timeConverter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9..ccd71295f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,16 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(3, 5); + + if (hours === 0) { + return `12:${minutes} AM` + } if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${hours - 12}:${minutes} PM`; } - return `${time} am`; + return `${time} AM`; } export {formatAs12HourClock}; From a8e1b2d657bc6701d1b2662d9d3f378c2921e33c Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:37:04 +0100 Subject: [PATCH 04/59] Add another case to test midnight --- format-clock-edge-cases/timeConverter.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 8003a1feb..4bd33a0fe 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -3,15 +3,15 @@ import assert from "node:assert"; import test from "node:test"; test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); + assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); test("can correctly convert morning time", function(){ - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); + assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert morning time", function (){ - assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +test("can correctly convert midnight time", function (){ + assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); }); /* From 9e2cef84be358c6b92e7f4fed3918571a0bf23d7 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:05:07 +0100 Subject: [PATCH 05/59] Add test case 00:01 to 12:01 am --- format-clock-edge-cases/timeConverter.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 4bd33a0fe..2c21a2e8c 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,6 +2,14 @@ import {formatAs12HourClock} from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; +test("can correctly convert midnight time", function () { + assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); +}); + +test("can correctly convert just after midnight", function () { + assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); @@ -10,9 +18,7 @@ test("can correctly convert morning time", function(){ assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert midnight time", function (){ - assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); -}); + /* Edge cases to be tested. From 2ba2e3421223ea5b7d3424a55b2909c481067ee1 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:05:53 +0100 Subject: [PATCH 06/59] Add condition for checking midday 12 pm --- format-clock-edge-cases/timeConverter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index ccd71295f..0e9e5dc92 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -6,7 +6,9 @@ function formatAs12HourClock(time) { if (hours === 0) { return `12:${minutes} AM` } - + if (hours === 12) { + return `12:${minutes} PM`; + } if (hours > 12) { return `${hours - 12}:${minutes} PM`; } From 06d5f9196609421da4bfad96d57138dc34a5f1d5 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:08:52 +0100 Subject: [PATCH 07/59] Add test case for 01:00 to 01:00 am --- format-clock-edge-cases/timeConverter.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 2c21a2e8c..89d71751f 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -10,6 +10,11 @@ test("can correctly convert just after midnight", function () { assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); }); +test("can correctly convert first normal hour", function () { + assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); +}); + + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); From 3dc6da6c1f66800bbf9ad12ded58c2f35c074fb7 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:12:29 +0100 Subject: [PATCH 08/59] Add test case for 11:59 to 11:59 am --- format-clock-edge-cases/timeConverter.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 89d71751f..181110f5d 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -14,6 +14,13 @@ test("can correctly convert first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); +test("can correctly convert leading zeros in hour and minute", function () { + assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); +}); + +test("can correctly convert last minute before noon", function () { + assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); +}); test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); From 1e6cb55cff9ebed1dba684a035546a3bf2e73b1a Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:20:54 +0100 Subject: [PATCH 09/59] Add test case for 12:01 to 12:01 pm --- format-clock-edge-cases/timeConverter.test.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 181110f5d..a40314267 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -14,6 +14,10 @@ test("can correctly convert first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); +}); + test("can correctly convert leading zeros in hour and minute", function () { assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); }); @@ -22,13 +26,19 @@ test("can correctly convert last minute before noon", function () { assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); }); +test("can correctly convert time to PM noon", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); +}); + +test("can correctly convert time just afternoon", function () { + assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); -test("can correctly convert morning time", function(){ - assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); -}); + @@ -41,9 +51,10 @@ Edge cases to be tested. 3. 01:00 -> 01:00 am First normal morning hour 4. 09:05 -> 09:05 am Leading zeros in hour and minute 5. 11:59 -> 11:59 am Last minute before noon -6. 23:59 -> 11:59 pm Last minute of the day + 7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 8. 12:01 -> 12:01 pm Just after noon, must not become 00 9. 12:59 -> 12:59 pm Last minute of the noon hour 10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded +6. 23:59 -> 11:59 pm Last minute of the day */ \ No newline at end of file From 61b2ce70c7cb54298572a6b4dab7cb03c596dcaf Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:25:30 +0100 Subject: [PATCH 10/59] Add test case for 13:00 to 1:00 pm --- format-clock-edge-cases/timeConverter.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index a40314267..fbf92b1da 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -34,6 +34,14 @@ test("can correctly convert time just afternoon", function () { assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); }); +test("can correctly convert time last minute of the noon hour", function () { + assert.equal(formatAs12HourClock("12:59"), "12:59 PM"); +}); + +test("can correctly convert time first hour after noon", function () { + assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); From 040786906e6dd059ad1748bb69e7559d30acac80 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:28:50 +0100 Subject: [PATCH 11/59] Add test case fo 23:59 to 11:59 pm --- format-clock-edge-cases/timeConverter.test.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index fbf92b1da..ffedaea52 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,4 +1,4 @@ -import {formatAs12HourClock} from "./timeConverter.js"; +import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; @@ -42,13 +42,13 @@ test("can correctly convert time first hour after noon", function () { assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); }); -test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); +test("correctly convert time after 12:00", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); - - - +test("can correctly convert time last minute of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 PM"); +}); /* Edge cases to be tested. @@ -59,10 +59,9 @@ Edge cases to be tested. 3. 01:00 -> 01:00 am First normal morning hour 4. 09:05 -> 09:05 am Leading zeros in hour and minute 5. 11:59 -> 11:59 am Last minute before noon - -7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 -8. 12:01 -> 12:01 pm Just after noon, must not become 00 -9. 12:59 -> 12:59 pm Last minute of the noon hour -10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded -6. 23:59 -> 11:59 pm Last minute of the day -*/ \ No newline at end of file +6. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 +7. 12:01 -> 12:01 pm Just after noon, must not become 00 +8. 12:59 -> 12:59 pm Last minute of the noon hour +9. 13:00 -> 01:00 pm First hour after noon: 13 - 12, padded +10.23:59 -> 11:59 pm Last minute of the day +*/ From 06d3f9a0c6958076566110dae7ed8b1265059d31 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:36:26 +0100 Subject: [PATCH 12/59] Add padStart method to hours --- format-clock-edge-cases/timeConverter.js | 2 +- format-clock-edge-cases/timeConverter.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 0e9e5dc92..9703a7fea 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,6 +1,6 @@ function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); + const hours = Number(time.slice(0, 2).padStart(2, 0)); const minutes = time.slice(3, 5); if (hours === 0) { diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index ffedaea52..1803282b5 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -39,7 +39,7 @@ test("can correctly convert time last minute of the noon hour", function () { }); test("can correctly convert time first hour after noon", function () { - assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); + assert.equal(formatAs12HourClock("13:00"), "01:00 PM"); }); test("correctly convert time after 12:00", function () { From 598f744790e7497234e6b954abc127e280707755 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:42:18 +0100 Subject: [PATCH 13/59] Add more description. --- format-clock-edge-cases/timeConverter.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 1803282b5..f3ffcea1e 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,15 +2,15 @@ import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("can correctly convert midnight time", function () { +test("can correctly convert time at midnight ", function () { assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); }); -test("can correctly convert just after midnight", function () { +test("can correctly convert time just after midnight", function () { assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); }); -test("can correctly convert first normal hour", function () { +test("can correctly convert time at the first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); @@ -18,15 +18,15 @@ test("can correctly convert morning time", function () { assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert leading zeros in hour and minute", function () { +test("can correctly convert time on leading zeros in hour and minute", function () { assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); }); -test("can correctly convert last minute before noon", function () { +test("can correctly convert time just last minute before noon", function () { assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); }); -test("can correctly convert time to PM noon", function () { +test("can correctly convert time to PM at noon", function () { assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); }); From e6fde3bd32233e9e618bc5ad607ef8182ed4337c Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 29 Sep 2026 22:31:32 +0100 Subject: [PATCH 14/59] Add padStart method to convert 23:00 to 01:00pm --- format-clock-edge-cases/timeConverter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 9703a7fea..489779331 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,18 +1,19 @@ function formatAs12HourClock(time) { + const hours = Number(time.slice(0, 2)); - const hours = Number(time.slice(0, 2).padStart(2, 0)); const minutes = time.slice(3, 5); if (hours === 0) { - return `12:${minutes} AM` + return `12:${minutes} AM`; } if (hours === 12) { return `12:${minutes} PM`; } if (hours > 12) { - return `${hours - 12}:${minutes} PM`; + const paddedHours = String(hours - 12).padStart(2, "0"); + return `${paddedHours}:${minutes} PM`; } return `${time} AM`; } -export {formatAs12HourClock}; +export { formatAs12HourClock }; From c2f743cc9af42331cdaf0ed8e70d589b6d160355 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 29 Sep 2026 22:34:46 +0100 Subject: [PATCH 15/59] Edit comments --- format-clock-edge-cases/timeConverter.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index f3ffcea1e..5208d6384 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -53,7 +53,6 @@ test("can correctly convert time last minute of the day", function () { /* Edge cases to be tested. Input Expected What it tests - 1. 00:00 -> 12:00 am Midnight: hour 0 becomes 12 2. 00:01 -> 12:01 am Just after midnight, still 12 3. 01:00 -> 01:00 am First normal morning hour From e7ff9c7e7aeb92a258a202676cb92762eee1ec71 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 13:09:10 +0100 Subject: [PATCH 16/59] Inline code directly into return statement --- format-clock-edge-cases/timeConverter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 489779331..a784d125f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -10,8 +10,7 @@ function formatAs12HourClock(time) { return `12:${minutes} PM`; } if (hours > 12) { - const paddedHours = String(hours - 12).padStart(2, "0"); - return `${paddedHours}:${minutes} PM`; + return `${String(hours - 12).padStart(2, "0")}:${minutes} PM`; } return `${time} AM`; } From 751fb787e8c9314b5ce60dbce71399fc6cdc5110 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 20:55:15 +0100 Subject: [PATCH 17/59] Change am and pm to lower case and update description. --- format-clock-edge-cases/timeConverter.js | 8 ++-- format-clock-edge-cases/timeConverter.test.js | 38 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index a784d125f..192894d77 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -4,15 +4,15 @@ function formatAs12HourClock(time) { const minutes = time.slice(3, 5); if (hours === 0) { - return `12:${minutes} AM`; + return `12:${minutes} am`; } if (hours === 12) { - return `12:${minutes} PM`; + return `12:${minutes} pm`; } if (hours > 12) { - return `${String(hours - 12).padStart(2, "0")}:${minutes} PM`; + return `${String(hours - 12).padStart(2, "0")}:${minutes} pm`; } - return `${time} AM`; + return `${time} am`; } export { formatAs12HourClock }; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 5208d6384..8889b2c7b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,52 +2,52 @@ import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; +test("can correctly convert time last minute of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); +}); + +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); +}); + test("can correctly convert time at midnight ", function () { - assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); }); test("can correctly convert time just after midnight", function () { - assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); + assert.equal(formatAs12HourClock("00:01"), "12:01 am"); }); test("can correctly convert time at the first normal hour", function () { - assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); -}); - -test("can correctly convert morning time", function () { - assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); + assert.equal(formatAs12HourClock("01:00"), "01:00 am"); }); test("can correctly convert time on leading zeros in hour and minute", function () { - assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); + assert.equal(formatAs12HourClock("09:05"), "09:05 am"); }); test("can correctly convert time just last minute before noon", function () { - assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); }); test("can correctly convert time to PM at noon", function () { - assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); }); test("can correctly convert time just afternoon", function () { - assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); + assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); }); test("can correctly convert time last minute of the noon hour", function () { - assert.equal(formatAs12HourClock("12:59"), "12:59 PM"); + assert.equal(formatAs12HourClock("12:59"), "12:59 pm"); }); test("can correctly convert time first hour after noon", function () { - assert.equal(formatAs12HourClock("13:00"), "01:00 PM"); + assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); }); -test("correctly convert time after 12:00", function () { - assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); -}); - -test("can correctly convert time last minute of the day", function () { - assert.equal(formatAs12HourClock("23:59"), "11:59 PM"); +test("correctly convert time before midnight", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); /* From 4707f5ae5a5fca7ca09a839f25a09747f8dd9f52 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 21:17:03 +0100 Subject: [PATCH 18/59] Unreachable code. --- dead-code/exercise-1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa..e5ab68be2 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -5,9 +5,9 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; + return `${greeting}, ${name}!`; - console.log(greetingStr); + } testName = "Aman"; From f504687afc5ffe3be7784d73a30092d19e906211 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 21:27:07 +0100 Subject: [PATCH 19/59] Remove unreachable and redundant code. --- dead-code/exercise-1.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index e5ab68be2..5593f9e23 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +1,6 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. -let testName = "Jerry"; -const greeting = "hello"; - function sayHello(greeting, name) { - return `${greeting}, ${name}!`; - } - -testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); - -console.log(greetingMessage); // 'hello, Aman!' From d9197c47e1591171187d6fbd063620cf80aed368 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 22:39:13 +0100 Subject: [PATCH 20/59] Remove unused code --- dead-code/exercise-2.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4..3b7d2e0f7 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,27 +2,21 @@ // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; -const capitalisedPets = pets.map((pet) => pet.toUpperCase()); -const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); - -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} function countAndCapitalisePets(petsArr) { const petCount = {}; - petsArr.forEach((pet) => { - const capitalisedPet = pet.toUpperCase(); + petsArr.filter((pet) => pet[0] === "h").forEach((pet) => { + const capitalisedPet = pet.toUpperCase() + if (petCount[capitalisedPet]) { petCount[capitalisedPet] += 1; } else { petCount[capitalisedPet] = 1; } }); + return petCount; } -const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +console.log(countAndCapitalisePets(pets)); \ No newline at end of file From 9494c3dac2547134a695d9155abb492e162abeca Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 22:42:16 +0100 Subject: [PATCH 21/59] Update function to work for any input. --- dead-code/exercise-2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 3b7d2e0f7..e57e5f190 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -19,4 +19,5 @@ function countAndCapitalisePets(petsArr) { return petCount; } -console.log(countAndCapitalisePets(pets)); \ No newline at end of file +const animals = ["lion", "hyena", "elephant", "hippo", "tiger", "hippo"] +console.log(countAndCapitalisePets(animals)); \ No newline at end of file From 582699c1261356f84c8a4b911feb23d3704cca8d Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 22:45:05 +0100 Subject: [PATCH 22/59] Format code with prettier. --- dead-code/exercise-2.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index e57e5f190..16ca0657e 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -6,18 +6,20 @@ const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; function countAndCapitalisePets(petsArr) { const petCount = {}; - petsArr.filter((pet) => pet[0] === "h").forEach((pet) => { - const capitalisedPet = pet.toUpperCase() + petsArr + .filter((pet) => pet[0] === "h") + .forEach((pet) => { + const capitalisedPet = pet.toUpperCase(); + + if (petCount[capitalisedPet]) { + petCount[capitalisedPet] += 1; + } else { + petCount[capitalisedPet] = 1; + } + }); - if (petCount[capitalisedPet]) { - petCount[capitalisedPet] += 1; - } else { - petCount[capitalisedPet] = 1; - } - }); - return petCount; } -const animals = ["lion", "hyena", "elephant", "hippo", "tiger", "hippo"] -console.log(countAndCapitalisePets(animals)); \ No newline at end of file +const animals = ["lion", "hyena", "elephant", "hippo", "tiger", "hippo"]; +console.log(countAndCapitalisePets(animals)); From b806b4115e598a01afb8fcb0ad36ea8cc1f484bd Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 15:13:24 +0100 Subject: [PATCH 23/59] Stop tracking files --- format-clock-edge-cases/timeConverter.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 format-clock-edge-cases/timeConverter.js diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index 192894d77..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,18 +0,0 @@ -function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); - - const minutes = time.slice(3, 5); - - if (hours === 0) { - return `12:${minutes} am`; - } - if (hours === 12) { - return `12:${minutes} pm`; - } - if (hours > 12) { - return `${String(hours - 12).padStart(2, "0")}:${minutes} pm`; - } - return `${time} am`; -} - -export { formatAs12HourClock }; From fcf27e7360b9d8f4c9b6dc2148792d6c97f1798a Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 15:14:57 +0100 Subject: [PATCH 24/59] Stop tracking files --- format-clock-edge-cases/timeConverter.test.js | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index 8889b2c7b..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,66 +0,0 @@ -import { formatAs12HourClock } from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("can correctly convert time last minute of the day", function () { - assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); -}); - -test("can correctly convert morning time", function () { - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); -}); - -test("can correctly convert time at midnight ", function () { - assert.equal(formatAs12HourClock("00:00"), "12:00 am"); -}); - -test("can correctly convert time just after midnight", function () { - assert.equal(formatAs12HourClock("00:01"), "12:01 am"); -}); - -test("can correctly convert time at the first normal hour", function () { - assert.equal(formatAs12HourClock("01:00"), "01:00 am"); -}); - -test("can correctly convert time on leading zeros in hour and minute", function () { - assert.equal(formatAs12HourClock("09:05"), "09:05 am"); -}); - -test("can correctly convert time just last minute before noon", function () { - assert.equal(formatAs12HourClock("11:59"), "11:59 am"); -}); - -test("can correctly convert time to PM at noon", function () { - assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); -}); - -test("can correctly convert time just afternoon", function () { - assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); -}); - -test("can correctly convert time last minute of the noon hour", function () { - assert.equal(formatAs12HourClock("12:59"), "12:59 pm"); -}); - -test("can correctly convert time first hour after noon", function () { - assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); -}); - -test("correctly convert time before midnight", function () { - assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); -}); - -/* -Edge cases to be tested. - Input Expected What it tests -1. 00:00 -> 12:00 am Midnight: hour 0 becomes 12 -2. 00:01 -> 12:01 am Just after midnight, still 12 -3. 01:00 -> 01:00 am First normal morning hour -4. 09:05 -> 09:05 am Leading zeros in hour and minute -5. 11:59 -> 11:59 am Last minute before noon -6. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 -7. 12:01 -> 12:01 pm Just after noon, must not become 00 -8. 12:59 -> 12:59 pm Last minute of the noon hour -9. 13:00 -> 01:00 pm First hour after noon: 13 - 12, padded -10.23:59 -> 11:59 pm Last minute of the day -*/ From 04f544f7feca8b80b84cca68cba73dd53144b58f Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 15:55:44 +0100 Subject: [PATCH 25/59] Restore files unrelated to this PR --- format-clock-edge-cases/timeConverter.js | 11 +++++++++++ format-clock-edge-cases/timeConverter.test.js | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 format-clock-edge-cases/timeConverter.js create mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..310c07bd9 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,11 @@ +function formatAs12HourClock(time) { + + const hours = Number(time.slice(0, 2)); + + if (hours > 12) { + return `${hours - 12}:00 pm`; + } + return `${time} am`; +} + +export {formatAs12HourClock}; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js new file mode 100644 index 000000000..88f2af094 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,11 @@ +import {formatAs12HourClock} from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", function(){ + assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); +}); + +test("can correctly convert morning time", function() { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); +}); From 4815e87568540639e435716e3aad0986644faa7c Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 16:35:58 +0100 Subject: [PATCH 26/59] Add if condition for checking right angle. --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 8a6fba050..3ba549bbb 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -18,4 +18,7 @@ export function getAngleType(angle) { // TODO: Implement this function + if (angle === 90) { + return "Right angle"; + } } From 9dc9e1ffb91a6e07a9ff4163b2c9533aee4c984b Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:16:49 +0100 Subject: [PATCH 27/59] Write test for Acute angle. --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index cf50f6cad..30da8da07 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -10,3 +10,8 @@ test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + +test("Classifies Acute angles", () => { + const Acute = getAngleType(90); + assert.equal(Acute, "Acute angle"); +}); \ No newline at end of file From 10b0d0f4ffb61973fad4d4a33c58981f7a26ab6c Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:20:12 +0100 Subject: [PATCH 28/59] Write test for Obtuse angle. --- .../1-get-angle-type.test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 30da8da07..464f16e9a 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -6,12 +6,18 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles +test("Classifies Acute angles", () => { + const Acute = getAngleType(89); + assert.equal(Acute, "Acute angle"); +}); + test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); -test("Classifies Acute angles", () => { - const Acute = getAngleType(90); - assert.equal(Acute, "Acute angle"); -}); \ No newline at end of file +test("Classifies Obtuse angles", () => { + const Obtuse = getAngleType(89); + assert.equal(Obtuse, "Obtuse angle"); +}); + From cccf002bfc2928a46bbac1fc98694c3f01c90547 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:21:00 +0100 Subject: [PATCH 29/59] Add if condition for checking Acute angle. --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 3ba549bbb..05314ff66 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -18,7 +18,10 @@ export function getAngleType(angle) { // TODO: Implement this function - if (angle === 90) { + if (angle > 0 && angle < 90) { + return "Acute angle" + } + else if (angle === 90) { return "Right angle"; } } From ed2729e307da4ebe3c498d745cf50eb18706e20b Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:25:37 +0100 Subject: [PATCH 30/59] Add if condition for checking Obtuse angle. --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 05314ff66..087a70692 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -19,9 +19,11 @@ export function getAngleType(angle) { // TODO: Implement this function if (angle > 0 && angle < 90) { - return "Acute angle" - } - else if (angle === 90) { + return "Acute angle"; + } else if (angle === 90) { return "Right angle"; + } else if (angle > 90 && angle < 180) { + return "Obtuse angle"; } + } From 4fa3e6cf79af16eca1e792f337f34293aa2f9efd Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:31:33 +0100 Subject: [PATCH 31/59] Write test for invalid angles --- .../1-get-angle-type.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 464f16e9a..6cdb02a83 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -17,7 +17,21 @@ test("Classifies right angles", () => { }); test("Classifies Obtuse angles", () => { - const Obtuse = getAngleType(89); + const Obtuse = getAngleType(99); assert.equal(Obtuse, "Obtuse angle"); }); +test("Classifies Straight angles", () => { + const Straight = getAngleType(180); + assert.equal(Straight, "Straight angle"); +}); + +test("Classifies Reflex angles", () => { + const Reflex = getAngleType(181); + assert.equal(Reflex, "Reflex angle"); +}); + +test("Classifies Invalid angles", () => { + const Invalid = getAngleType(399); + assert.equal(Invalid, "Invalid angle"); +}); \ No newline at end of file From ea5fa0f2e9de0c6cd8fd7b1d7e4ecfe9704e3784 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 3 Oct 2026 22:31:56 +0100 Subject: [PATCH 32/59] Add final if condition for checking invalid angle --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 087a70692..bf7490771 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -24,6 +24,12 @@ export function getAngleType(angle) { return "Right angle"; } else if (angle > 90 && angle < 180) { return "Obtuse angle"; + } else if (angle === 180) { + return "Straight angle"; + } else if (angle > 180 && angle < 360) { + return "Reflex angle"; + } else { + return "Invalid angle" } } From 6102a89e716adc450cd2b91056e284a21d3a8af0 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 4 Oct 2026 21:31:13 +0100 Subject: [PATCH 33/59] Add boundary case test for acute angle. --- .../1-get-angle-type.test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 6cdb02a83..5b5b93c0d 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -7,12 +7,18 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // Example: Identify Right Angles test("Classifies Acute angles", () => { - const Acute = getAngleType(89); + const Acute = getAngleType(1); assert.equal(Acute, "Acute angle"); + + const Acute1 = getAngleType(45); + assert.equal(Acute1, "Acute angle"); + + const Acute2 = getAngleType(89); + assert.equal(Acute2, "Acute angle"); }); test("Classifies right angles", () => { - const right = getAngleType(90); + const right = getAngleType(90, ); assert.equal(right, "Right angle"); }); From 717584dcb37b70d2cde34bb8520f7386e874f25c Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 4 Oct 2026 21:32:10 +0100 Subject: [PATCH 34/59] Add if condition for checking invalid inputs. --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index bf7490771..6255e3400 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -29,7 +29,6 @@ export function getAngleType(angle) { } else if (angle > 180 && angle < 360) { return "Reflex angle"; } else { - return "Invalid angle" + return "Invalid angle"; } - } From fed8ddd8019712ad1aecb8859cba0e6e1edda2a2 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 4 Oct 2026 21:44:21 +0100 Subject: [PATCH 35/59] Add boundary test cases for multiple angles. --- .../1-get-angle-type.test.js | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 5b5b93c0d..89bb57d9b 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -18,13 +18,19 @@ test("Classifies Acute angles", () => { }); test("Classifies right angles", () => { - const right = getAngleType(90, ); + const right = getAngleType(90); assert.equal(right, "Right angle"); }); test("Classifies Obtuse angles", () => { - const Obtuse = getAngleType(99); + const Obtuse = getAngleType(91); assert.equal(Obtuse, "Obtuse angle"); + + const Obtuse1 = getAngleType(120); + assert.equal(Obtuse1, "Obtuse angle"); + + const Obtuse2 = getAngleType(179); + assert.equal(Obtuse2, "Obtuse angle"); }); test("Classifies Straight angles", () => { @@ -35,9 +41,27 @@ test("Classifies Straight angles", () => { test("Classifies Reflex angles", () => { const Reflex = getAngleType(181); assert.equal(Reflex, "Reflex angle"); + + const Reflex1 = getAngleType(299); + assert.equal(Reflex1, "Reflex angle"); + + const Reflex2 = getAngleType(360); + assert.equal(Reflex2, "Reflex angle"); }); test("Classifies Invalid angles", () => { - const Invalid = getAngleType(399); + const Invalid = getAngleType(0); assert.equal(Invalid, "Invalid angle"); -}); \ No newline at end of file + + const Invalid1 = getAngleType(361); + assert.equal(Invalid1, "Invalid angle"); + + const Invalid2 = getAngleType(399); + assert.equal(Invalid2, "Invalid angle"); + + const Invalid3 = getAngleType(-7); + assert.equal(Invalid3, "Invalid angle"); + + const Invalid4 = getAngleType(30.2); + assert.equal(Invalid4, "Invalid angle"); +}); From bb815ef5de66e609a0cc7720eb073a919d15cdf1 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 4 Oct 2026 21:45:16 +0100 Subject: [PATCH 36/59] Add = operator for checking 360 degrees is included --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 6255e3400..e10c0d61d 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -26,7 +26,7 @@ export function getAngleType(angle) { return "Obtuse angle"; } else if (angle === 180) { return "Straight angle"; - } else if (angle > 180 && angle < 360) { + } else if (angle > 180 && angle <= 360) { return "Reflex angle"; } else { return "Invalid angle"; From c8fc9dd540dfcfecbe467d3732d3d290bff2992f Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 5 Oct 2026 14:36:40 +0100 Subject: [PATCH 37/59] Add boundary test cases. --- .../1-get-angle-type.test.js | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 89bb57d9b..cf50f6cad 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -6,62 +6,7 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles -test("Classifies Acute angles", () => { - const Acute = getAngleType(1); - assert.equal(Acute, "Acute angle"); - - const Acute1 = getAngleType(45); - assert.equal(Acute1, "Acute angle"); - - const Acute2 = getAngleType(89); - assert.equal(Acute2, "Acute angle"); -}); - test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); - -test("Classifies Obtuse angles", () => { - const Obtuse = getAngleType(91); - assert.equal(Obtuse, "Obtuse angle"); - - const Obtuse1 = getAngleType(120); - assert.equal(Obtuse1, "Obtuse angle"); - - const Obtuse2 = getAngleType(179); - assert.equal(Obtuse2, "Obtuse angle"); -}); - -test("Classifies Straight angles", () => { - const Straight = getAngleType(180); - assert.equal(Straight, "Straight angle"); -}); - -test("Classifies Reflex angles", () => { - const Reflex = getAngleType(181); - assert.equal(Reflex, "Reflex angle"); - - const Reflex1 = getAngleType(299); - assert.equal(Reflex1, "Reflex angle"); - - const Reflex2 = getAngleType(360); - assert.equal(Reflex2, "Reflex angle"); -}); - -test("Classifies Invalid angles", () => { - const Invalid = getAngleType(0); - assert.equal(Invalid, "Invalid angle"); - - const Invalid1 = getAngleType(361); - assert.equal(Invalid1, "Invalid angle"); - - const Invalid2 = getAngleType(399); - assert.equal(Invalid2, "Invalid angle"); - - const Invalid3 = getAngleType(-7); - assert.equal(Invalid3, "Invalid angle"); - - const Invalid4 = getAngleType(30.2); - assert.equal(Invalid4, "Invalid angle"); -}); From 3a565e93f8cae9a6e6eff8816cb91bf501df1a97 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 5 Oct 2026 15:03:11 +0100 Subject: [PATCH 38/59] Add angle type boundary tests --- .../1-get-angle-type.test.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index cf50f6cad..89bb57d9b 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -6,7 +6,62 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles +test("Classifies Acute angles", () => { + const Acute = getAngleType(1); + assert.equal(Acute, "Acute angle"); + + const Acute1 = getAngleType(45); + assert.equal(Acute1, "Acute angle"); + + const Acute2 = getAngleType(89); + assert.equal(Acute2, "Acute angle"); +}); + test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + +test("Classifies Obtuse angles", () => { + const Obtuse = getAngleType(91); + assert.equal(Obtuse, "Obtuse angle"); + + const Obtuse1 = getAngleType(120); + assert.equal(Obtuse1, "Obtuse angle"); + + const Obtuse2 = getAngleType(179); + assert.equal(Obtuse2, "Obtuse angle"); +}); + +test("Classifies Straight angles", () => { + const Straight = getAngleType(180); + assert.equal(Straight, "Straight angle"); +}); + +test("Classifies Reflex angles", () => { + const Reflex = getAngleType(181); + assert.equal(Reflex, "Reflex angle"); + + const Reflex1 = getAngleType(299); + assert.equal(Reflex1, "Reflex angle"); + + const Reflex2 = getAngleType(360); + assert.equal(Reflex2, "Reflex angle"); +}); + +test("Classifies Invalid angles", () => { + const Invalid = getAngleType(0); + assert.equal(Invalid, "Invalid angle"); + + const Invalid1 = getAngleType(361); + assert.equal(Invalid1, "Invalid angle"); + + const Invalid2 = getAngleType(399); + assert.equal(Invalid2, "Invalid angle"); + + const Invalid3 = getAngleType(-7); + assert.equal(Invalid3, "Invalid angle"); + + const Invalid4 = getAngleType(30.2); + assert.equal(Invalid4, "Invalid angle"); +}); From c80ed87564226f0cc1406e43f8dd4b483fd11097 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 5 Oct 2026 15:03:44 +0100 Subject: [PATCH 39/59] Add angle type boundary tests --- .../1-get-angle-type.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 89bb57d9b..2511112a2 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -42,11 +42,11 @@ test("Classifies Reflex angles", () => { const Reflex = getAngleType(181); assert.equal(Reflex, "Reflex angle"); - const Reflex1 = getAngleType(299); - assert.equal(Reflex1, "Reflex angle"); + const Reflex1 = getAngleType(299); + assert.equal(Reflex1, "Reflex angle"); - const Reflex2 = getAngleType(360); - assert.equal(Reflex2, "Reflex angle"); + const Reflex2 = getAngleType(360); + assert.equal(Reflex2, "Reflex angle"); }); test("Classifies Invalid angles", () => { @@ -59,9 +59,9 @@ test("Classifies Invalid angles", () => { const Invalid2 = getAngleType(399); assert.equal(Invalid2, "Invalid angle"); - const Invalid3 = getAngleType(-7); - assert.equal(Invalid3, "Invalid angle"); + const Invalid3 = getAngleType(-7); + assert.equal(Invalid3, "Invalid angle"); - const Invalid4 = getAngleType(30.2); - assert.equal(Invalid4, "Invalid angle"); + const Invalid4 = getAngleType(30.2); + assert.equal(Invalid4, "Invalid angle"); }); From 38c28b3f07ef62fe03fa5e126cd28a4d4519ed54 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 5 Oct 2026 15:12:49 +0100 Subject: [PATCH 40/59] Implement if condition to check propr function. --- .../implement/2-is-proper-fraction.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index f983800f0..a8fcfbbc7 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -15,4 +15,10 @@ export function isProperFraction(numerator, denominator) { // TODO: Implement this function + if (numerator < denominator) { + return true; + } else { + return false; + } } + From f12c63543b74a2e2d94aeee3b61772d1f8eb08e1 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 6 Oct 2026 10:11:27 +0100 Subject: [PATCH 41/59] Delete not needed test. --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 2511112a2..4a3d88089 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -61,7 +61,4 @@ test("Classifies Invalid angles", () => { const Invalid3 = getAngleType(-7); assert.equal(Invalid3, "Invalid angle"); - - const Invalid4 = getAngleType(30.2); - assert.equal(Invalid4, "Invalid angle"); }); From 48b8daea41b4a1fdddeaa62deecbe793e241c5a8 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 6 Oct 2026 11:00:32 +0100 Subject: [PATCH 42/59] Write cases for testing proper and improper fractions. --- .../2-is-proper-fraction.test.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index a29084605..2eb2ce300 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -10,3 +10,58 @@ test("Basic proper fraction", () => { // Example: 1/2 is a proper fraction assert.equal(isProperFraction(1, 2), true); }); + +// Proper fraction +test("Decimal proper fraction", () => { + assert.equal(isProperFraction(0.5, 1.5), true); +}); + +test("0 numerator proper fraction", () => { + assert.equal(isProperFraction(0, 5), true); +}); + +test("Negative numerator proper fraction", () => { + assert.equal(isProperFraction(-9, 1), true); +}); + +test("Both negatives proper fraction", () => { + assert.equal(isProperFraction(-7, -3), true); +}); + +test("Large number proper fraction", () => { + assert.equal(isProperFraction(999, 1000), true); +}); + +test("Very small denominator proper fraction", () => { + assert.equal(isProperFraction(1, 1000000), true); +}); + +// Improper fractions + +test("Decimal improper fraction", () => { + assert.equal(isProperFraction(1.2, 1.1), false); +}); + +test("Numerator larger improper fraction", () => { + assert.equal(isProperFraction(5, 3), false); +}); + +test("Both equal improper fraction", () => { + assert.equal(isProperFraction(4, 4), false); +}); + +test("0 denominator improper fraction", () => { + assert.equal(isProperFraction(7, 0), false); +}); + +test("Both 0 improper fraction", () => { + assert.equal(isProperFraction(0, 0), false); +}); + +test("Both equal negatives improper fraction", () => { + assert.equal(isProperFraction(-4, -4), false); +}); + +test("Negative denominator improper fraction", () => { + assert.equal(isProperFraction(2, -9), false); +}); From d5091de872befc265325603aa656aabb5c714121 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 6 Oct 2026 13:33:11 +0100 Subject: [PATCH 43/59] Update tests description. --- .../2-is-proper-fraction.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 2eb2ce300..12fb66067 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -42,11 +42,11 @@ test("Decimal improper fraction", () => { assert.equal(isProperFraction(1.2, 1.1), false); }); -test("Numerator larger improper fraction", () => { +test("Large numerator improper fraction", () => { assert.equal(isProperFraction(5, 3), false); }); -test("Both equal improper fraction", () => { +test("Both number equal improper fraction", () => { assert.equal(isProperFraction(4, 4), false); }); @@ -54,7 +54,7 @@ test("0 denominator improper fraction", () => { assert.equal(isProperFraction(7, 0), false); }); -test("Both 0 improper fraction", () => { +test("Both numbers 0 improper fraction", () => { assert.equal(isProperFraction(0, 0), false); }); From fa07e40aee065b377c43d69ad266985d4aad9a81 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 7 Oct 2026 21:04:42 +0100 Subject: [PATCH 44/59] Implement if condition to check card value --- implement-and-rewrite-tests/implement/3-get-card-value.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 9614ab1ee..cd8fa4826 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -25,4 +25,11 @@ export function getCardValue(card) { // TODO: Implement this function + if (card === "A") { + return 11; + } else if (card === "J" || card === "Q" || card === "K") { + return 10; + } else { + return Number(card); + } } From 651191c5355a099fc2f062020f5c711bc4fdab21 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 12:31:44 +0100 Subject: [PATCH 45/59] Check valid card ranks --- .../3-get-card-value.test.js | 2 -- .../implement/3-get-card-value.js | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index f5092d9b1..84b2e6b3f 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -8,9 +8,7 @@ import { getCardValue } from "../implement/3-get-card-value.js"; test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); - test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); - // TODO: What other invalid card cases can you think of? diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index cd8fa4826..ebaa91f75 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -25,11 +25,20 @@ export function getCardValue(card) { // TODO: Implement this function - if (card === "A") { + if (typeof card !== "string") { + throw new Error("Invalid"); + } + const rank = card.slice(0, -1); + + if (rank === "A") { return 11; - } else if (card === "J" || card === "Q" || card === "K") { + } + if (rank === "J" || rank === "Q" || rank === "K") { return 10; - } else { - return Number(card); } + const value = Number(rank); + if (Number.isInteger(value) && value >= 2 && value <= 10) { + return value; + } + throw new Error(`Expected a number followed by a suit, but got "${card}"`); } From 53d733c85d3c38eacab82f33ff327c5c0482a321 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 13:10:58 +0100 Subject: [PATCH 46/59] Add test cases for single-digit card --- .../3-get-card-value.test.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 84b2e6b3f..7e0ffde1a 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -8,7 +8,33 @@ import { getCardValue } from "../implement/3-get-card-value.js"; test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); +test("Valid single-digit card", () => { + assert.equal(getCardValue("8♥"), 8); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("7♣"), 7); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("6♦"), 6); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("5♥"), 5); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("4♦"), 4); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("3♠"), 3); +}); +test("Valid single-digit card", () => { + assert.equal(getCardValue("2♣"), 2); +}); + test("Arbitrary non-card string", () => { - assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); + assert.throws( + () => getCardValue("invalid"), + /Expected a number followed by a suit, but got "invalid"/, + "Expected clear error" + ); }); // TODO: What other invalid card cases can you think of? From 699f8c08200849d839fbcdbda16ef26cb7ddfcca Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 13:23:04 +0100 Subject: [PATCH 47/59] Add test cases for invalid card --- .../3-get-card-value.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 7e0ffde1a..f7f6ca975 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -38,3 +38,15 @@ test("Arbitrary non-card string", () => { ); }); // TODO: What other invalid card cases can you think of? + +test("Invalid cards", () => { + assert.throws(() => getCardValue(""), "invalid"); + assert.throws(() => getCardValue("♠"), "invalid"); + assert.throws(() => getCardValue("A"), "invalid"); + assert.throws(() => getCardValue("5"), "invalid"); + assert.throws(() => getCardValue("1♠"), "invalid"); + assert.throws(() => getCardValue("0♠"), "invalid"); + assert.throws(() => getCardValue("11♠"), "invalid"); + assert.throws(() => getCardValue("X♠"), "invalid"); + assert.throws(() => getCardValue("5♠♥"), "invalid"); +}); From 63b1d2071107a3b4ca3c67ef7c7bb38bf920ffec Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 14:57:18 +0100 Subject: [PATCH 48/59] Add test case for Obtuse angle --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index e0ba786ab..5cc04eaef 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -12,7 +12,16 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when (angle = 90)`, () => { + expect(getAngleType(90)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (90 > angle < 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(200)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); // Case 4: Straight angle // Case 5: Reflex angles // Case 6: Invalid angles From c0bc7b782dffddc5fe4da6d316ccc4144fdcce34 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 15:06:24 +0100 Subject: [PATCH 49/59] Add test cases for Straight, Reflex, and Invalid angles. --- .../1-get-angle-type.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 5cc04eaef..7d1b49a40 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -19,9 +19,26 @@ test(`should return "Right angle" when (angle = 90)`, () => { // Case 3: Obtuse angles test(`should return "Obtuse angle" when (90 > angle < 180)`, () => { expect(getAngleType(91)).toEqual("Obtuse angle"); - expect(getAngleType(200)).toEqual("Obtuse angle"); + expect(getAngleType(120)).toEqual("Obtuse angle"); expect(getAngleType(179)).toEqual("Obtuse angle"); }); + // Case 4: Straight angle +test(`should return "Straight angle" when (angle = 180)`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 > angle <= 360)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(299)).toEqual("Reflex angle"); + expect(getAngleType(360)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test(`should return "Invalid angle"`, () => { + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); + expect(getAngleType(399)).toEqual("Invalid angle"); + expect(getAngleType(-7)).toEqual("Invalid angle"); +}); From eb68334ec04718e9776e140bfe33c567339d5a86 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Mon, 12 Oct 2026 22:24:04 +0100 Subject: [PATCH 50/59] Write multiple test cases for proper and improper fraction --- .../2-is-proper-fraction.test.js | 2 +- .../2-is-proper-fraction.test.js | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 12fb66067..61b0c986c 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -42,7 +42,7 @@ test("Decimal improper fraction", () => { assert.equal(isProperFraction(1.2, 1.1), false); }); -test("Large numerator improper fraction", () => { +test("Large numerator improper fraction", () => { assert.equal(isProperFraction(5, 3), false); }); diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 5d49e2d8b..191220807 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -6,3 +6,56 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +test(`should return true for basic proper fraction`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +test(`should return true for decimal proper fraction`, () => { + expect(isProperFraction(0.5, 1.5)).toEqual(true); +}); + +test(`should return true for 0 numerator proper fraction`, () => { + expect(isProperFraction(0, 5)).toEqual(true); +}); + +test(`should return true for negative numerator proper fraction`, () => { + expect(isProperFraction(-9, 1)).toEqual(true); +}); + +test(`should return true for negative proper fraction`, () => { + expect(isProperFraction(-7, -3)).toEqual(true); +}); + +test(`should return true for very small denominator proper fraction`, () => { + expect(isProperFraction(1, 1000000)).toEqual(true); +}); + +// Improper fractions +test(`should return false for very small denominator proper fraction`, () => { + expect(isProperFraction(1.2, 1.1)).toEqual(false); +}); + +test(`should return false for large numerator improper fraction`, () => { + expect(isProperFraction(5, 3)).toEqual(false); +}); + +test(`should return false for both equal numbers improper fraction`, () => { + expect(isProperFraction(4, 4)).toEqual(false); +}); + +test(`should return false for 0 denominator improper fraction`, () => { + expect(isProperFraction(7, 0)).toEqual(false); +}); + +test(`should return false for both 0 improper fraction`, () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + +test(`should return false for both negative improper fraction`, () => { + expect(isProperFraction(-4, -4)).toEqual(false); +}); + +test(`should return false for negative denominator improper fraction`, () => { + expect(isProperFraction(2, -9)).toEqual(false); +}); \ No newline at end of file From 3d93bc4b955432996fc35d0bfbe68c014b90ef7f Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 20:16:00 +0100 Subject: [PATCH 51/59] Add more test cases for Ace and face cards --- .../3-get-card-value.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index f7f6ca975..5f2cedde5 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -5,6 +5,26 @@ import { getCardValue } from "../implement/3-get-card-value.js"; // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. +test("Valid Ace card", () => { + assert.equal(getCardValue("A♠"), 11); +}); + +test("Valid Jack card", () => { + assert.equal(getCardValue("J♥"), 10); +}); + +test("Valid Queen card", () => { + assert.equal(getCardValue("Q♣"), 10); +}); + +test("Valid single-digit card", () => { + assert.equal(getCardValue("K♦"), 10); +}); + +test("Valid double-digit card", () => { + assert.equal(getCardValue("10♣"), 10); +}); + test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); From b9732cb259d6ee2b375ebed627d7faebe5ab5691 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 20:17:55 +0100 Subject: [PATCH 52/59] Write test cases for cards number 2 -10 --- .../3-get-card-value.test.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index a6de5a82a..511edf296 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -7,6 +7,43 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Number Cards (2-10) +test(`Should return 2 when given number 2 card`, () => { + expect(getCardValue("2♥")).toEqual(2); +}); + +test(`Should return 3 when given number 3 card`, () => { + expect(getCardValue("3♣")).toEqual(3); +}); + +test(`Should return 4 when given number 4 card`, () => { + expect(getCardValue("4♠")).toEqual(4); +}); + +test(`Should return 5 when given number 5 card`, () => { + expect(getCardValue("5♦")).toEqual(5); +}); + +test(`Should return 6 when given number 6 card`, () => { + expect(getCardValue("6♣")).toEqual(6); +}); + +test(`Should return 7 when given number 7 card`, () => { + expect(getCardValue("7♠")).toEqual(7); +}); + +test(`Should return 8 when given number 8 card`, () => { + expect(getCardValue("8♥")).toEqual(8); +}); + +test(`Should return 9 when given number 9 card`, () => { + expect(getCardValue("9♣")).toEqual(9); +}); + +test(`Should return 10 when given number 10 card`, () => { + expect(getCardValue("10♦")).toEqual(10); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 66f6482c0beef951bf28f117b6fec4ddd146a381 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 20:28:46 +0100 Subject: [PATCH 53/59] Correct spelling error --- .../implement-tests-with-node-test/3-get-card-value.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 5f2cedde5..f9285e9e8 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -17,7 +17,7 @@ test("Valid Queen card", () => { assert.equal(getCardValue("Q♣"), 10); }); -test("Valid single-digit card", () => { +test("Valid King card", () => { assert.equal(getCardValue("K♦"), 10); }); From 7f0c6c896bb8e2dd5b6f9fde288babbbdacc3ebb Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 20:53:55 +0100 Subject: [PATCH 54/59] Write test cases for invalid cards --- .../3-get-card-value.test.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 511edf296..8152b2b1c 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -44,6 +44,29 @@ test(`Should return 10 when given number 10 card`, () => { expect(getCardValue("10♦")).toEqual(10); }); +// Case 3: Face Cards (J, Q, K) +test(`Should return 10 when given a Kings card`, () => { + expect(getCardValue("K♠")).toEqual(10); +}); + +test(`Should return 10 when given a Queen card`, () => { + expect(getCardValue("Q♦")).toEqual(10); +}); + +test(`Should return "Invalid" when given invalid cards card`, () => { + expect(() => getCardValue("")).toThrow(); + expect(() => getCardValue("♠")).toThrow(); + expect(() => getCardValue("A")).toThrow(); + expect(() => getCardValue("5")).toThrow(); + expect(() => getCardValue("1♠")).toThrow(); + expect(() => getCardValue("0♠")).toThrow(); + expect(() => getCardValue("11♠")).toThrow(); + expect(() => getCardValue("X♠")).toThrow(); + expect(() => getCardValue("5♠♥")).toThrow(); +}); + +// Case 4: Invalid Cards + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 0a2de270bf6ddf791ba05013b1a4ea89819ec1dc Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 21:03:10 +0100 Subject: [PATCH 55/59] Format code with prettier. --- .../3-get-card-value.test.js | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 8152b2b1c..b663a06fb 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -8,52 +8,28 @@ test(`Should return 11 when given an ace card`, () => { }); // Case 2: Number Cards (2-10) -test(`Should return 2 when given number 2 card`, () => { +test(`Should return its numeric value when given a number card`, () => { expect(getCardValue("2♥")).toEqual(2); -}); - -test(`Should return 3 when given number 3 card`, () => { expect(getCardValue("3♣")).toEqual(3); -}); - -test(`Should return 4 when given number 4 card`, () => { expect(getCardValue("4♠")).toEqual(4); -}); - -test(`Should return 5 when given number 5 card`, () => { expect(getCardValue("5♦")).toEqual(5); -}); - -test(`Should return 6 when given number 6 card`, () => { expect(getCardValue("6♣")).toEqual(6); -}); - -test(`Should return 7 when given number 7 card`, () => { expect(getCardValue("7♠")).toEqual(7); -}); - -test(`Should return 8 when given number 8 card`, () => { expect(getCardValue("8♥")).toEqual(8); -}); - -test(`Should return 9 when given number 9 card`, () => { expect(getCardValue("9♣")).toEqual(9); -}); - -test(`Should return 10 when given number 10 card`, () => { expect(getCardValue("10♦")).toEqual(10); }); // Case 3: Face Cards (J, Q, K) -test(`Should return 10 when given a Kings card`, () => { +test(`Should return 10 when given a face card`, () => { expect(getCardValue("K♠")).toEqual(10); + expect(getCardValue("Q♠")).toEqual(10); + expect(getCardValue("K♦")).toEqual(10); }); -test(`Should return 10 when given a Queen card`, () => { - expect(getCardValue("Q♦")).toEqual(10); -}); +// Case 4: Invalid Cards -test(`Should return "Invalid" when given invalid cards card`, () => { +test(`Should return "Invalid" when given an invalid card`, () => { expect(() => getCardValue("")).toThrow(); expect(() => getCardValue("♠")).toThrow(); expect(() => getCardValue("A")).toThrow(); @@ -65,8 +41,6 @@ test(`Should return "Invalid" when given invalid cards card`, () => { expect(() => getCardValue("5♠♥")).toThrow(); }); -// Case 4: Invalid Cards - // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -75,4 +49,3 @@ test(`Should return "Invalid" when given invalid cards card`, () => { // To learn how to test whether a function throws an error as expected in Jest, // please refer to the Jest documentation: // https://jestjs.io/docs/expect#tothrowerror - From 3e40397817431427892e512f8d754c0b536f4a70 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 21:15:19 +0100 Subject: [PATCH 56/59] Fix spelling error. --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 4a3d88089..d63b6f4a3 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -17,7 +17,7 @@ test("Classifies Acute angles", () => { assert.equal(Acute2, "Acute angle"); }); -test("Classifies right angles", () => { +test("Classifies Right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); From ad4fae019077374b35ea0c561a2c73b7620f7e4a Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 21:15:37 +0100 Subject: [PATCH 57/59] Fix spelling error. --- .../2-is-proper-fraction.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 61b0c986c..cb8fead52 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -24,7 +24,7 @@ test("Negative numerator proper fraction", () => { assert.equal(isProperFraction(-9, 1), true); }); -test("Both negatives proper fraction", () => { +test("Both negative proper fraction", () => { assert.equal(isProperFraction(-7, -3), true); }); @@ -46,7 +46,7 @@ test("Large numerator improper fraction", () => { assert.equal(isProperFraction(5, 3), false); }); -test("Both number equal improper fraction", () => { +test("Equal numbers improper fraction", () => { assert.equal(isProperFraction(4, 4), false); }); @@ -58,7 +58,7 @@ test("Both numbers 0 improper fraction", () => { assert.equal(isProperFraction(0, 0), false); }); -test("Both equal negatives improper fraction", () => { +test("Negative numbers improper fraction", () => { assert.equal(isProperFraction(-4, -4), false); }); From b8ba7fd8d111043e63173d26ebbd11f7ea7fa61e Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 21:18:01 +0100 Subject: [PATCH 58/59] Format code with prettier. --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 1 - .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index a8fcfbbc7..41fe92857 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -21,4 +21,3 @@ export function isProperFraction(numerator, denominator) { return false; } } - diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 191220807..501d122d9 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -58,4 +58,4 @@ test(`should return false for both negative improper fraction`, () => { test(`should return false for negative denominator improper fraction`, () => { expect(isProperFraction(2, -9)).toEqual(false); -}); \ No newline at end of file +}); From 0c75ac6ee9c9059d25dac4e268a2960d99966d84 Mon Sep 17 00:00:00 2001 From: Russom Gebremeskel Date: Tue, 13 Oct 2026 21:40:07 +0100 Subject: [PATCH 59/59] Restore dead-code files to match main --- dead-code/exercise-1.js | 11 +++++++++++ dead-code/exercise-2.js | 31 +++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 5593f9e23..4d09f15fa 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,6 +1,17 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. +let testName = "Jerry"; +const greeting = "hello"; + function sayHello(greeting, name) { + const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; + console.log(greetingStr); } + +testName = "Aman"; + +const greetingMessage = sayHello(greeting, testName); + +console.log(greetingMessage); // 'hello, Aman!' diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 16ca0657e..56d7887c4 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,24 +2,27 @@ // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; +const capitalisedPets = pets.map((pet) => pet.toUpperCase()); +const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); + +function logPets(petsArr) { + petsArr.forEach((pet) => console.log(pet)); +} function countAndCapitalisePets(petsArr) { const petCount = {}; - petsArr - .filter((pet) => pet[0] === "h") - .forEach((pet) => { - const capitalisedPet = pet.toUpperCase(); - - if (petCount[capitalisedPet]) { - petCount[capitalisedPet] += 1; - } else { - petCount[capitalisedPet] = 1; - } - }); - + petsArr.forEach((pet) => { + const capitalisedPet = pet.toUpperCase(); + if (petCount[capitalisedPet]) { + petCount[capitalisedPet] += 1; + } else { + petCount[capitalisedPet] = 1; + } + }); return petCount; } -const animals = ["lion", "hyena", "elephant", "hippo", "tiger", "hippo"]; -console.log(countAndCapitalisePets(animals)); +const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); + +console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log