From c3cc796723c636f71a9a27b2f08b4dfdac7ecbb2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 10:16:33 +0100 Subject: [PATCH 01/99] refactor: update formatAs12HourClock function to improve time parsing and period handling --- format-clock-edge-cases/timeConverter.js | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9..5c54f88ed 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,28 @@ -function formatAs12HourClock(time) { +// function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); +// const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export {formatAs12HourClock}; + +function formatAs12HourClock(time){ + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + let period; + if(hours < 12){ + period = "am"; + } else { + period = "pm"; } - return `${time} am`; -} -export {formatAs12HourClock}; + let displayHour = hours % 12; + if(displayHour === 0){ + displayHour = 12; + } +} From b03e0fbd6025ddf479c53fda059c6782d01a865a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 10:43:31 +0100 Subject: [PATCH 02/99] refactor: update test syntax to use arrow functions for consistency --- format-clock-edge-cases/timeConverter.test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 88f2af094..87ebf6f0d 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,10 +2,13 @@ import {formatAs12HourClock} from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("correctly convert time after 12:00", function(){ +test("correctly convert time after 12:00", () => { assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); -test("can correctly convert morning time", function() { +test("can correctly convert morning time", () => { assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) \ No newline at end of file From 05e8ef311bd3e4cd59181cb6001f96f960649d76 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 10:44:14 +0100 Subject: [PATCH 03/99] fix: ensure formatAs12HourClock function exports correctly --- format-clock-edge-cases/timeConverter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 5c54f88ed..cfc15cf0d 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -26,3 +26,4 @@ function formatAs12HourClock(time){ displayHour = 12; } } +export {formatAs12HourClock}; From 1544b3863f7bc83092b1a3779f123901ddae1f13 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 10:47:01 +0100 Subject: [PATCH 04/99] test: add test case for converting midnight time --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 87ebf6f0d..958577764 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -11,4 +11,7 @@ test("can correctly convert morning time", () => { }); test("converts a single-digit morning hour and drops leading zero", () => { assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) +test("converts correctly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); }) \ No newline at end of file From 8230a0e18ffb9f272d44bd8d3022cb0648cfb923 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:08:19 +0100 Subject: [PATCH 05/99] refactor: improve time conversion logic and enhance test cases for clarity --- format-clock-edge-cases/timeConverter.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 958577764..526b54add 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -12,6 +12,9 @@ test("can correctly convert morning time", () => { test("converts a single-digit morning hour and drops leading zero", () => { assert.equal(formatAs12HourClock("08:00"), "8:00am"); }) -test("converts correctly to midnight", () => { +test("converts exactly to midnight", () => { assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}) +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); }) \ No newline at end of file From ead95df8677dafc76d86a95af0136c91a71aa890 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:08:43 +0100 Subject: [PATCH 06/99] fix: correct return statement in formatAs12HourClock function for accurate time formatting --- format-clock-edge-cases/timeConverter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index cfc15cf0d..8c790c71e 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -25,5 +25,7 @@ function formatAs12HourClock(time){ if(displayHour === 0){ displayHour = 12; } + return `${displayHour}:${minutePart} ${period}` } export {formatAs12HourClock}; +console.log(formatAs12HourClock("24:00")) From 19e10f50ad39a1576e23461bad31f26c6d514ab2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:10:41 +0100 Subject: [PATCH 07/99] test: add test case for converting the last minute before noon --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 526b54add..1439f3645 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -17,4 +17,7 @@ test("converts exactly to midnight", () => { }) test("converts time just after midnight", () => { assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}) +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); }) \ No newline at end of file From 15938a2f6f3dba6ac81a0574486468eeedf2f395 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:17:57 +0100 Subject: [PATCH 08/99] test: add test case for converting exact noon to pm --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 1439f3645..d17001510 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -20,4 +20,7 @@ test("converts time just after midnight", () => { }) test("converts the last minute before noon", () => { assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}) +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); }) \ No newline at end of file From 8acdeaac7b1ecf042a74ecbac66df04d501780de Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:24:44 +0100 Subject: [PATCH 09/99] test: add test case for converting time just after noon --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index d17001510..e6de2a0ae 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -23,4 +23,7 @@ test("converts the last minute before noon", () => { }) test("converts exact noon to pm", () => { assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}) +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); }) \ No newline at end of file From a7d1115808deaf5f887c330cd6b91d9ab1327965 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 12:31:15 +0100 Subject: [PATCH 10/99] fix: add missing newline at end of timeConverter.test.js --- format-clock-edge-cases/timeConverter.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index e6de2a0ae..5c77479ae 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -26,4 +26,4 @@ test("converts exact noon to pm", () => { }) test("convert time just after noon", () => { assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) \ No newline at end of file +}) From ee8f85b58e813844d51c47595bfbdfc698cd94f3 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:13:43 +0100 Subject: [PATCH 11/99] fix: remove space before am/pm in time formatting and clean up test cases --- 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 5c77479ae..35f0353f3 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -3,12 +3,9 @@ import assert from "node:assert"; import test from "node:test"; test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); }); -test("can correctly convert morning time", () => { - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); -}); test("converts a single-digit morning hour and drops leading zero", () => { assert.equal(formatAs12HourClock("08:00"), "8:00am"); }) @@ -27,3 +24,6 @@ test("converts exact noon to pm", () => { test("convert time just after noon", () => { assert.equal(formatAs12HourClock("12:30"), "12:30pm"); }) +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:30pm"); +}) \ No newline at end of file From f93cd35b0045c49fcd1009cf6b44e0d6bdf86104 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:13:53 +0100 Subject: [PATCH 12/99] fix: remove space before period in time formatting --- format-clock-edge-cases/timeConverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 8c790c71e..2838957f9 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -25,7 +25,7 @@ function formatAs12HourClock(time){ if(displayHour === 0){ displayHour = 12; } - return `${displayHour}:${minutePart} ${period}` + return `${displayHour}:${minutePart}${period}`; } export {formatAs12HourClock}; console.log(formatAs12HourClock("24:00")) From 59863c5e7088f6732b3ef324778de64c1f8a6e9d Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:15:29 +0100 Subject: [PATCH 13/99] test: add test case for converting late evening hour --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 35f0353f3..3e85ff048 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -26,4 +26,7 @@ test("convert time just after noon", () => { }) test("converts the first afternoon hour", () => { assert.equal(formatAs12HourClock("13:00"), "1:30pm"); +}) +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); }) \ No newline at end of file From c6ed571c83cfb10cf15f19c3a8f1e55ce0b9e62e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:18:46 +0100 Subject: [PATCH 14/99] test: add test case for converting last minute of the day --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 3e85ff048..e35005af7 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -29,4 +29,7 @@ test("converts the first afternoon hour", () => { }) test("converts late evening hour", () => { assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}) +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); }) \ No newline at end of file From ced1c53a2856d38caa69fe7991ffe0447aa69f6a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:21:23 +0100 Subject: [PATCH 15/99] fix: correct expected output for first afternoon hour test case --- format-clock-edge-cases/timeConverter.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index e35005af7..95e2dbb63 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -25,7 +25,7 @@ test("convert time just after noon", () => { assert.equal(formatAs12HourClock("12:30"), "12:30pm"); }) test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:30pm"); + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); }) test("converts late evening hour", () => { assert.equal(formatAs12HourClock("23:00"), "11:00pm"); From 9f0876ffc3e682040df0d6091c22839210580481 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:27:19 +0100 Subject: [PATCH 16/99] test: add test case for preserving minutes with leading zero --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 95e2dbb63..dde4dfa88 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -32,4 +32,7 @@ test("converts late evening hour", () => { }) test("converts last minute of the day", () => { assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}) +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); }) \ No newline at end of file From 03c860be74f1e4f038572dc3980050112046c4b1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:27:33 +0100 Subject: [PATCH 17/99] test: update console log to test formatting for 8:00 AM --- format-clock-edge-cases/timeConverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 2838957f9..40878c68b 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -28,4 +28,4 @@ function formatAs12HourClock(time){ return `${displayHour}:${minutePart}${period}`; } export {formatAs12HourClock}; -console.log(formatAs12HourClock("24:00")) +console.log(formatAs12HourClock("08:00")) From 42d563c84ef7e1dcf86cab68f30941cf2a71ade8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:29:00 +0100 Subject: [PATCH 18/99] test: add test case for preserving non-zero minutes --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index dde4dfa88..ac64852b1 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -35,4 +35,7 @@ test("converts last minute of the day", () => { }) test("preserves minutes with leading zero", () => { assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}) +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); }) \ No newline at end of file From 91ccb0c1655a452efe960dc0a75650fb536d6fa5 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sat, 3 Oct 2026 14:30:09 +0100 Subject: [PATCH 19/99] test: update console log to test formatting for 8:40 AM --- format-clock-edge-cases/timeConverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 40878c68b..d941da6e8 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -28,4 +28,4 @@ function formatAs12HourClock(time){ return `${displayHour}:${minutePart}${period}`; } export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:00")) +console.log(formatAs12HourClock("08:40")) From 472364d3f324bd4b18bbaa78fb5c97722fd6a67c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sun, 4 Oct 2026 20:15:21 +0100 Subject: [PATCH 20/99] Remove commented-out code from time formatting function --- format-clock-edge-cases/timeConverter.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index d941da6e8..f1b5ec631 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,15 +1,3 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - function formatAs12HourClock(time){ const [hourPart, minutePart] = time.split(":"); const hours = Number(hourPart); From 5b48a96d3f7f884310efe101d4d0a8ed424c055e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sun, 4 Oct 2026 20:20:48 +0100 Subject: [PATCH 21/99] Remove console log from time formatting function --- format-clock-edge-cases/timeConverter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index f1b5ec631..897565f28 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -16,4 +16,3 @@ function formatAs12HourClock(time){ return `${displayHour}:${minutePart}${period}`; } export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) From 8a740151f986648e6da5fce04705d20d0e61d51d Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sun, 4 Oct 2026 20:26:11 +0100 Subject: [PATCH 22/99] Add jsconfig.json for TypeScript configuration --- jsconfig.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..ce3653908 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Bundler", + "target": "ES2024", + "jsx": "react-jsx", + "allowImportingTsExtensions": true, + "checkJs": undefined, + "experimentalDecorators": false, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strict": true + }, + "exclude": [ + "node_modules", + "**/node_modules/*" + ] +} \ No newline at end of file From 27919c8ba64b659942665e79d3a9c1873fd0cf08 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Sun, 4 Oct 2026 20:43:28 +0100 Subject: [PATCH 23/99] Format code and improve readability --- .prettierrc | 1 - format-clock-edge-cases/timeConverter.js | 2 +- format-clock-edge-cases/timeConverter.test.js | 48 +++++++++---------- .../3-get-card-value.test.js | 6 ++- .../3-get-card-value.test.js | 1 - package.json | 5 +- practice-tdd/count.js | 2 +- .../password-validator.test.js | 15 +++--- 8 files changed, 42 insertions(+), 38 deletions(-) diff --git a/.prettierrc b/.prettierrc index 59bb3b44f..2e7e49095 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,7 +4,6 @@ "embeddedLanguageFormatting": "auto", "htmlWhitespaceSensitivity": "css", "insertPragma": false, - "jsxBracketSameLine": false, "jsxSingleQuote": false, "printWidth": 80, "proseWrap": "preserve", diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 897565f28..389d4fad8 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -5,7 +5,7 @@ function formatAs12HourClock(time){ let period; if(hours < 12){ period = "am"; - } else { + }else{ period = "pm"; } diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index ac64852b1..bc3a9a933 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,41 +1,41 @@ -import {formatAs12HourClock} from "./timeConverter.js"; +import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); }); test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}); test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}); test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}); test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}); test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}); test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}); test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}); test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}); test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}); test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}); 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..273197c9d 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 @@ -10,7 +10,11 @@ test("Valid single-digit card", () => { }); 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? 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..b5619e5e0 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 @@ -15,4 +15,3 @@ test(`Should return 11 when given an ace 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 - diff --git a/package.json b/package.json index 6ae16268c..96cf0230d 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,8 @@ "license": "ISC", "dependencies": { "jest": "^29.7.0" + }, + "devDependencies": { + "prettier": "^3.9.9" } -} \ No newline at end of file +} diff --git a/practice-tdd/count.js b/practice-tdd/count.js index 5518c5712..1a099f60f 100644 --- a/practice-tdd/count.js +++ b/practice-tdd/count.js @@ -1,3 +1,3 @@ export function countChar(stringOfCharacters, findCharacter) { - return 5 + return 5; } diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 2a58a0fb6..52f4b75e5 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -16,11 +16,10 @@ You must breakdown this problem in order to solve it. Find one test case first a */ import { isValidPassword } from "./password-validator.js"; test("password has at least 5 characters", () => { - // Arrange - const password = "12345"; - // Act - const result = isValidPassword(password); - // Assert - expect(result).toEqual(true); -} -); \ No newline at end of file + // Arrange + const password = "12345"; + // Act + const result = isValidPassword(password); + // Assert + expect(result).toEqual(true); +}); From fa688b11bc5fa9f281234745ef39327ea4522a6c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 5 Oct 2026 01:24:56 +0100 Subject: [PATCH 24/99] Simplify period determination and improve formatting --- format-clock-edge-cases/timeConverter.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 389d4fad8..13f488faf 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,18 +1,13 @@ -function formatAs12HourClock(time){ +function formatAs12HourClock(time) { const [hourPart, minutePart] = time.split(":"); const hours = Number(hourPart); - let period; - if(hours < 12){ - period = "am"; - }else{ - period = "pm"; - } + const period = hours < 12 ? "am" : "pm"; let displayHour = hours % 12; - if(displayHour === 0){ + if (displayHour === 0) { displayHour = 12; - } + } return `${displayHour}:${minutePart}${period}`; } -export {formatAs12HourClock}; +export { formatAs12HourClock }; From 5d58269403e74f6454241f735a2cc8cb218107df Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 5 Oct 2026 01:29:25 +0100 Subject: [PATCH 25/99] Refactor display hour calculation for 12-hour clock format --- format-clock-edge-cases/timeConverter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 13f488faf..f4a24c094 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -4,10 +4,7 @@ function formatAs12HourClock(time) { const period = hours < 12 ? "am" : "pm"; - let displayHour = hours % 12; - if (displayHour === 0) { - displayHour = 12; - } + const displayHour = hours % 12 || 12; return `${displayHour}:${minutePart}${period}`; } export { formatAs12HourClock }; From f9fac2a6e43f79e5c6af324f4f1913e19a3e107f Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 5 Oct 2026 02:03:20 +0100 Subject: [PATCH 26/99] Remove jsconfig.json and clean up package.json by deleting devDependencies --- .prettierrc | 1 + jsconfig.json | 18 ------------------ package.json | 5 +---- 3 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 jsconfig.json diff --git a/.prettierrc b/.prettierrc index 2e7e49095..59bb3b44f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,6 +4,7 @@ "embeddedLanguageFormatting": "auto", "htmlWhitespaceSensitivity": "css", "insertPragma": false, + "jsxBracketSameLine": false, "jsxSingleQuote": false, "printWidth": 80, "proseWrap": "preserve", diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index ce3653908..000000000 --- a/jsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - "target": "ES2024", - "jsx": "react-jsx", - "allowImportingTsExtensions": true, - "checkJs": undefined, - "experimentalDecorators": false, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strict": true - }, - "exclude": [ - "node_modules", - "**/node_modules/*" - ] -} \ No newline at end of file diff --git a/package.json b/package.json index 96cf0230d..6ae16268c 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,5 @@ "license": "ISC", "dependencies": { "jest": "^29.7.0" - }, - "devDependencies": { - "prettier": "^3.9.9" } -} +} \ No newline at end of file From aba07711c3bd9b30a047b9cace71a3b0073e6b40 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 5 Oct 2026 02:16:02 +0100 Subject: [PATCH 27/99] Refactor folders to match main --- .../3-get-card-value.test.js | 6 +----- .../3-get-card-value.test.js | 1 + practice-tdd/count.js | 2 +- .../password-validator.test.js | 15 ++++++++------- 4 files changed, 11 insertions(+), 13 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 273197c9d..f5092d9b1 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 @@ -10,11 +10,7 @@ test("Valid single-digit card", () => { }); 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? 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 b5619e5e0..a6de5a82a 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 @@ -15,3 +15,4 @@ test(`Should return 11 when given an ace 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 + diff --git a/practice-tdd/count.js b/practice-tdd/count.js index 1a099f60f..5518c5712 100644 --- a/practice-tdd/count.js +++ b/practice-tdd/count.js @@ -1,3 +1,3 @@ export function countChar(stringOfCharacters, findCharacter) { - return 5; + return 5 } diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 52f4b75e5..2a58a0fb6 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -16,10 +16,11 @@ You must breakdown this problem in order to solve it. Find one test case first a */ import { isValidPassword } from "./password-validator.js"; test("password has at least 5 characters", () => { - // Arrange - const password = "12345"; - // Act - const result = isValidPassword(password); - // Assert - expect(result).toEqual(true); -}); + // Arrange + const password = "12345"; + // Act + const result = isValidPassword(password); + // Assert + expect(result).toEqual(true); +} +); \ No newline at end of file From dc991743f54beb83f7609dc97d36084b823477a5 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:01:30 +0100 Subject: [PATCH 28/99] Add test case for classifying acute angles --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 4 ++++ 1 file changed, 4 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..73e6768ab 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,7 @@ test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + +test("Classifies acute angles", () => { + assert.equal(getAngleType(45), "Acute angle"); +}); From ca9a48e1af0e8cb2a2c919b762f7141b80f79172 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:06:53 +0100 Subject: [PATCH 29/99] Add test case for classifying acute angles at 1 degree --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 1 + 1 file changed, 1 insertion(+) 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 73e6768ab..4a29c1e3e 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 @@ -13,4 +13,5 @@ test("Classifies right angles", () => { test("Classifies acute angles", () => { assert.equal(getAngleType(45), "Acute angle"); + assert.equal(getAngleType(1), "Acute angle"); }); From e9127ddcedd07adadad688d17479c0c89571204a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:08:19 +0100 Subject: [PATCH 30/99] Add test case for classifying acute angles at 89 degrees --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 1 + 1 file changed, 1 insertion(+) 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 4a29c1e3e..ae51c8860 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 @@ -14,4 +14,5 @@ test("Classifies right angles", () => { test("Classifies acute angles", () => { assert.equal(getAngleType(45), "Acute angle"); assert.equal(getAngleType(1), "Acute angle"); + assert.equal(getAngleType(89), "Acute angle"); }); From 965d13c542dd0efc34985b0f3abe2e0acd9a35a6 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:15:02 +0100 Subject: [PATCH 31/99] Implement angle classification function for acute and right angles --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 6 +++++- 1 file changed, 5 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 8a6fba050..a1f61e961 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -17,5 +17,9 @@ // execute the code to ensure all tests pass. export function getAngleType(angle) { - // TODO: Implement this function + if(angle > 0 && angle < 90) { + return "Acute angle"; + } else if(angle === 90) { + return "RIght angle"; + } } From f95598e030fcb1490e76c885b29ffe77bdd9f964 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:18:28 +0100 Subject: [PATCH 32/99] Add test cases for classifying obtuse angles --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 6 ++++++ 1 file changed, 6 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 ae51c8860..b84a5ba10 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 @@ -16,3 +16,9 @@ test("Classifies acute angles", () => { assert.equal(getAngleType(1), "Acute angle"); assert.equal(getAngleType(89), "Acute angle"); }); + +test("Classifies obtuse angles", () => { + assert.equal(getAngleType(91), "Obtuse angle"); + assert.equal(getAngleType(135), "Obtuse angle"); + assert.equal(getAngleType(179), "Obtuse angle"); +}) From 727a787a5a67afe942d52e5f485331a0108d2752 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:22:41 +0100 Subject: [PATCH 33/99] add angle classification logic for obtuse angles --- 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 a1f61e961..02e244185 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -21,5 +21,8 @@ export function getAngleType(angle) { return "Acute angle"; } else if(angle === 90) { return "RIght angle"; + } else if(angle > 90 && angle < 180){ + return "Obtuse angle"; } } +console.log(getAngleType(179)) From fc10ee87c43065fc7b56cdea2b2b135db506d402 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:24:28 +0100 Subject: [PATCH 34/99] Add test case for classifying straight angles --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 4 ++++ 1 file changed, 4 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 b84a5ba10..a8cffee50 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 @@ -21,4 +21,8 @@ test("Classifies obtuse angles", () => { assert.equal(getAngleType(91), "Obtuse angle"); assert.equal(getAngleType(135), "Obtuse angle"); assert.equal(getAngleType(179), "Obtuse angle"); +}); + +test("Classifies straight angles", () => { + assert.equal(getAngleType(180), "Straight angle"); }) From a54dbf349587c65e833386d9d300c2b24d861088 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:26:26 +0100 Subject: [PATCH 35/99] add angle classification logic for straight angle --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 3 ++- 1 file changed, 2 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 02e244185..64537d704 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -23,6 +23,7 @@ export function getAngleType(angle) { return "RIght angle"; } else if(angle > 90 && angle < 180){ return "Obtuse angle"; + } else if(angle === 180) { + return "Straight angle" } } -console.log(getAngleType(179)) From 59841f30ead6140c9f3acf67d8e2c9b695a81889 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:29:20 +0100 Subject: [PATCH 36/99] Add test cases for classifying reflex angles --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 6 ++++++ 1 file changed, 6 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 a8cffee50..0fcbeebc0 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 @@ -25,4 +25,10 @@ test("Classifies obtuse angles", () => { test("Classifies straight angles", () => { assert.equal(getAngleType(180), "Straight angle"); +}); + +test("Classifies reflex angles", () => { + assert.equal(getAngleType(181), "Reflex angle"); + assert.equal(getAngleType(270), "Reflex angle"); + assert.equal(getAngleType(359), "Reflex angle"); }) From 985fc65c666644e05a74678a4f2c995fd6cd8fc9 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:31:21 +0100 Subject: [PATCH 37/99] add angle classification logic for reflex angle --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 2 ++ 1 file changed, 2 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 64537d704..cb203635f 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -25,5 +25,7 @@ export function getAngleType(angle) { return "Obtuse angle"; } else if(angle === 180) { return "Straight angle" + } else if (angle < 180 && angle < 360){ + return "Reflex angle"; } } From e34c68016796013fcf4e84c5ef692fe50af10ac4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:34:58 +0100 Subject: [PATCH 38/99] Add test cases for classifying invalid angles --- .../1-get-angle-type.test.js | 7 +++++++ 1 file changed, 7 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 0fcbeebc0..32d473387 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 @@ -31,4 +31,11 @@ test("Classifies reflex angles", () => { assert.equal(getAngleType(181), "Reflex angle"); assert.equal(getAngleType(270), "Reflex angle"); assert.equal(getAngleType(359), "Reflex angle"); +}); + +test("Classifies invalid angles", () => { + assert.equal(getAngleType(0), "Invalid angle"); + assert.equal(getAngleType(360), "Invalid angle"); + assert.equal(getAngleType(400), "Invalid angle"); + assert.equal(getAngleType(-5), "Invalid angle"); }) From d04480383929a2db6995bbc3b7bd630cbcc673c6 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:36:29 +0100 Subject: [PATCH 39/99] Fix logic for invalid angle classification --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 2 ++ 1 file changed, 2 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 cb203635f..98057979d 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -27,5 +27,7 @@ export function getAngleType(angle) { return "Straight angle" } else if (angle < 180 && angle < 360){ return "Reflex angle"; + } else { + return "Invalid angle"; } } From dcbaa8af9542a205c6ef0be1b5ad7448e955f7f2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:43:45 +0100 Subject: [PATCH 40/99] Fix typo in angle classification for right angle --- 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 98057979d..a746f0d32 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -20,7 +20,7 @@ export function getAngleType(angle) { if(angle > 0 && angle < 90) { return "Acute angle"; } else if(angle === 90) { - return "RIght angle"; + return "Right angle"; } else if(angle > 90 && angle < 180){ return "Obtuse angle"; } else if(angle === 180) { From cafa444e61f56f57f010bc4dee0559298c9da991 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 18:44:11 +0100 Subject: [PATCH 41/99] Fix logic for reflex angle classification --- 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 a746f0d32..4ff290d94 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -25,7 +25,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 c864dae50e5242ebd81b33f9c02a1d2ef75bd13c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:19:42 +0100 Subject: [PATCH 42/99] Implement isProperFraction function to evaluate proper fractions --- .../implement/2-is-proper-fraction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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..f836922e4 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,5 +14,9 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if(Math.abs(numerator) < Math.abs(denominator)){ + return "true"; + } else { + return "false"; + } } From 25a95f7af9a8ce00d59b28f278f1dea832c2adc1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:25:08 +0100 Subject: [PATCH 43/99] Fix return values in isProperFraction function to boolean type and update test cases --- .../2-is-proper-fraction.test.js | 2 +- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 4 ++-- 2 files 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 a29084605..19768d74d 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 @@ -7,6 +7,6 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // What combinations of numerators and denominators should you test? test("Basic proper fraction", () => { - // Example: 1/2 is a proper fraction assert.equal(isProperFraction(1, 2), true); + assert.equal(isProperFraction(0, 5), true); }); 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 f836922e4..f56b51bf3 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -15,8 +15,8 @@ export function isProperFraction(numerator, denominator) { if(Math.abs(numerator) < Math.abs(denominator)){ - return "true"; + return true; } else { - return "false"; + return false; } } From a494567f59b40a86b9d353fafca6d07fc8f18e45 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:26:20 +0100 Subject: [PATCH 44/99] Add test case for negative numerator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 19768d74d..8ed3b6085 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 @@ -9,4 +9,5 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(0, 5), true); + assert.equal(isProperFraction(-1, 2), true); }); From f9957fb65b1dec3c65f519a4d513379708a4c723 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:27:20 +0100 Subject: [PATCH 45/99] Add test case for negative denominator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 8ed3b6085..2de4b9e7e 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,4 +10,5 @@ test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(0, 5), true); assert.equal(isProperFraction(-1, 2), true); + assert.equal(isProperFraction(1, -2), true); }); From 8ad8453a94a8a2e94a9b9ebc64b119ce3fc6a9e1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:28:01 +0100 Subject: [PATCH 46/99] Add test case for negative numerator and denominator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 2de4b9e7e..b659206a0 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 @@ -11,4 +11,5 @@ test("Basic proper fraction", () => { assert.equal(isProperFraction(0, 5), true); assert.equal(isProperFraction(-1, 2), true); assert.equal(isProperFraction(1, -2), true); + assert.equal(isProperFraction(-1, -2), true); }); From 583322972db28c74cc66f15e80217d85cf05ed8f Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:34:04 +0100 Subject: [PATCH 47/99] Add test case for improper fractions in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 b659206a0..3bdf052f0 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 @@ -12,4 +12,5 @@ test("Basic proper fraction", () => { assert.equal(isProperFraction(-1, 2), true); assert.equal(isProperFraction(1, -2), true); assert.equal(isProperFraction(-1, -2), true); + assert.equal(isProperFraction(5, 2), false) }); From 6735c73e4f96cf6a1b5a9344fd71a391a77c2d54 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:36:11 +0100 Subject: [PATCH 48/99] Add test case for basic improper fraction in isProperFraction function --- .../2-is-proper-fraction.test.js | 5 ++++- 1 file changed, 4 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 3bdf052f0..141b9eb9e 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 @@ -12,5 +12,8 @@ test("Basic proper fraction", () => { assert.equal(isProperFraction(-1, 2), true); assert.equal(isProperFraction(1, -2), true); assert.equal(isProperFraction(-1, -2), true); - assert.equal(isProperFraction(5, 2), false) }); + +test("Basic improper fraction", () => { + assert.equal(isProperFraction(5, 2), false); +}) From e2cac11765b4f92801390df2f6ed7e49df1496d3 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:37:08 +0100 Subject: [PATCH 49/99] Add test case for equal numerator and denominator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 141b9eb9e..cfe005a50 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 @@ -16,4 +16,5 @@ test("Basic proper fraction", () => { test("Basic improper fraction", () => { assert.equal(isProperFraction(5, 2), false); + assert.equal(isProperFraction(3, 3), false); }) From ebfa5cc764a7de5ae5fc6c6f50629db003f3c319 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:37:46 +0100 Subject: [PATCH 50/99] Add test case for zero denominator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 cfe005a50..8a1ff3b9a 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 @@ -17,4 +17,5 @@ test("Basic proper fraction", () => { test("Basic improper fraction", () => { assert.equal(isProperFraction(5, 2), false); assert.equal(isProperFraction(3, 3), false); + assert.equal(isProperFraction(5, 0), false); }) From 157c520a338274d8624ae6218080e16c92a14d2a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:41:02 +0100 Subject: [PATCH 51/99] Add test case for negative numerator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 8a1ff3b9a..5a9c76b0b 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 @@ -18,4 +18,5 @@ test("Basic improper fraction", () => { assert.equal(isProperFraction(5, 2), false); assert.equal(isProperFraction(3, 3), false); assert.equal(isProperFraction(5, 0), false); + assert.equal(isProperFraction(-5, 2), false); }) From 68c550109dcd0ea661277b7d5e9e3162271bcd1b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:42:31 +0100 Subject: [PATCH 52/99] Add test case for negative denominator in isProperFraction function --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 5a9c76b0b..4bcade9e8 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 @@ -19,4 +19,5 @@ test("Basic improper fraction", () => { assert.equal(isProperFraction(3, 3), false); assert.equal(isProperFraction(5, 0), false); assert.equal(isProperFraction(-5, 2), false); + assert.equal(isProperFraction(5, -2), false); }) From 7df31abc110e9fd3bb19039762f84adcce5be548 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 19:43:23 +0100 Subject: [PATCH 53/99] Add test case for negative numerator and denominator in isProperFraction function --- .../2-is-proper-fraction.test.js | 3 ++- 1 file changed, 2 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 4bcade9e8..75ebbe7fd 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 @@ -20,4 +20,5 @@ test("Basic improper fraction", () => { assert.equal(isProperFraction(5, 0), false); assert.equal(isProperFraction(-5, 2), false); assert.equal(isProperFraction(5, -2), false); -}) + assert.equal(isProperFraction(-5, -2), false); +}); From 39c47a261598baf362d3bdaefedec06ef81d9fdf Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:21:59 +0100 Subject: [PATCH 54/99] Implement valid suits array in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..df96c5d00 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,5 +24,5 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - // TODO: Implement this function + const validSuits = [u2660", "\u2665", "\u2666", "\u2663"];; } From ecd96e6674114f166da6b0197812ac7ddfa552e1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:22:34 +0100 Subject: [PATCH 55/99] Fix syntax error in validSuits array in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 df96c5d00..460987121 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,5 +24,5 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - const validSuits = [u2660", "\u2665", "\u2666", "\u2663"];; + const validSuits = ["u2660", "\u2665", "\u2666", "\u2663"]; } From 7efe47c845e22ffd64d761944dc80cf9a8527825 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:23:44 +0100 Subject: [PATCH 56/99] Add numberRanks array to getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) 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 460987121..96250952f 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,5 @@ export function getCardValue(card) { const validSuits = ["u2660", "\u2665", "\u2666", "\u2663"]; + const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; } From f85638bd72660875be38062d1ac9881328aafbe0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:24:39 +0100 Subject: [PATCH 57/99] Add faceRanks array to getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) 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 96250952f..64187f0b4 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -26,4 +26,5 @@ export function getCardValue(card) { const validSuits = ["u2660", "\u2665", "\u2666", "\u2663"]; const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; + const faceRanks = ["J", "Q", "K"]; } From d37ed99913844304a820fbfccecb135bd65020e3 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:26:08 +0100 Subject: [PATCH 58/99] Add faceRanks array to getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) 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 64187f0b4..1a4c9bf6d 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -27,4 +27,5 @@ export function getCardValue(card) { const validSuits = ["u2660", "\u2665", "\u2666", "\u2663"]; const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; const faceRanks = ["J", "Q", "K"]; + } From e1ddceb06cff3f4e54aa7e332c55a22c1907347a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:27:41 +0100 Subject: [PATCH 59/99] Add error handling for invalid card format in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 2 ++ 1 file changed, 2 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 1a4c9bf6d..31b3e6a82 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -28,4 +28,6 @@ export function getCardValue(card) { const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; const faceRanks = ["J", "Q", "K"]; + const error = new Error(`Expected a number followed by a suit, but got "${card}"`); + } From fcf852fca863451f0a2142ee423d2f6546b1f575 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:31:21 +0100 Subject: [PATCH 60/99] add initial validation for card input in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 31b3e6a82..5fde174a3 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,10 +24,15 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - const validSuits = ["u2660", "\u2665", "\u2666", "\u2663"]; + const validSuits = ["\u2660", "\u2665", "\u2666", "\u2663"]; const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; const faceRanks = ["J", "Q", "K"]; const error = new Error(`Expected a number followed by a suit, but got "${card}"`); + if(typeof card !== "string" || card.length < 2){ + throw error; + } + + } From c1b599d653901c5ed10e00823a54871262f9e0cb Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:34:02 +0100 Subject: [PATCH 61/99] Add suit and rank extraction with validation in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 6 ++++++ 1 file changed, 6 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 5fde174a3..fe2c5aabd 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -34,5 +34,11 @@ export function getCardValue(card) { throw error; } + const suit = card.slice(-1); + const rank = card.slice(0, -1); + + if(!validSuits.includes(suit)){ + throw error; + } } From 7567f280c2c0ecde9f5be914bc954d73bcc49015 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:36:28 +0100 Subject: [PATCH 62/99] Implement handling for Ace rank in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 4 ++++ 1 file changed, 4 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 fe2c5aabd..d832c5b8b 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -40,5 +40,9 @@ export function getCardValue(card) { if(!validSuits.includes(suit)){ throw error; } + if(rank === "A") { + return 11; + } + } From 93b333afd4aba85b91e74bb29b762bd54f77ec77 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:39:33 +0100 Subject: [PATCH 63/99] implement handling for faceRanks to return 10 for face cards --- implement-and-rewrite-tests/implement/3-get-card-value.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 d832c5b8b..08a0cf016 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -43,6 +43,8 @@ export function getCardValue(card) { if(rank === "A") { return 11; } - + if(faceRanks.includes(rank)){ + return 10; + } } From 1348019dcec8b6bc9b413ad951c75f6f37d42d3f Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:41:28 +0100 Subject: [PATCH 64/99] Refactor getCardValue function to ensure proper handling of number ranks and maintain error throwing for invalid inputs --- implement-and-rewrite-tests/implement/3-get-card-value.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 08a0cf016..7aff141b7 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -46,5 +46,8 @@ export function getCardValue(card) { if(faceRanks.includes(rank)){ return 10; } - + if(numberRanks.includes(rank)){ + return Number(rank); + } + throw error; } From e7cfd7bb9ad8bb4b22f89f6487240901d198fe50 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:45:52 +0100 Subject: [PATCH 65/99] Fix suit representation in getCardValue function to use Unicode characters for consistency --- implement-and-rewrite-tests/implement/3-get-card-value.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 7aff141b7..a666b2b85 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,7 +24,7 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - const validSuits = ["\u2660", "\u2665", "\u2666", "\u2663"]; + const validSuits = ["♠", "♥", "♦", "♣"]; const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; const faceRanks = ["J", "Q", "K"]; @@ -51,3 +51,5 @@ export function getCardValue(card) { } throw error; } + +console.log(getCardValue("A♦")) From cd4dc167731920ef7f089f20f1d6e845a00e1714 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:47:35 +0100 Subject: [PATCH 66/99] Comment out console log statement for getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a666b2b85..1b68bf598 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -52,4 +52,4 @@ export function getCardValue(card) { throw error; } -console.log(getCardValue("A♦")) +// console.log(getCardValue("A♦")); From d60f2bd3e3eac7966552faee2261d63570bc4007 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 20:49:52 +0100 Subject: [PATCH 67/99] Add test case for Ace card value --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++++ 1 file changed, 4 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 f5092d9b1..7ae4d5c79 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 @@ -9,6 +9,10 @@ test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); +test("Ace returns 11", () => { + assert.equal(getCardValue("A♠"), 11); +}); + test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From f38db7ff37303e279f109aba1545c16f6abe7c62 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 21:18:18 +0100 Subject: [PATCH 68/99] Add test cases for face cards to ensure they return a value of 10 --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 ++++++ 1 file changed, 6 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 7ae4d5c79..7feb7345a 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 @@ -13,6 +13,12 @@ test("Ace returns 11", () => { assert.equal(getCardValue("A♠"), 11); }); +test("Face cards return 10", () => { + assert.equal(getCardValue("J♣"), 10); + assert.equal(getCardValue("Q♦"), 10); + assert.equal(getCardValue("K♥"), 10); +}) + test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From c25755ded5a1e5274f7133cb60a12904bdb50b96 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 21:30:05 +0100 Subject: [PATCH 69/99] Add test case for number cards 2 to 10 to verify correct value returns --- .../implement-tests-with-node-test/3-get-card-value.test.js | 5 +++++ 1 file changed, 5 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 7feb7345a..bec6f17b0 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 @@ -19,6 +19,11 @@ test("Face cards return 10", () => { assert.equal(getCardValue("K♥"), 10); }) +test("Number cards 2 to 10 return their numbers", () => { + for(let n = 2; n <= 10; n++){ + assert.equal(getCardValue(`${n}♦`), n) + } +}) test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From f3c9bdad2f47cfcf75c94bb45df482002d7f6c75 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 21:30:41 +0100 Subject: [PATCH 70/99] Fix formatting in number card test for consistency --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 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 bec6f17b0..6be212480 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 @@ -20,10 +20,10 @@ test("Face cards return 10", () => { }) test("Number cards 2 to 10 return their numbers", () => { - for(let n = 2; n <= 10; n++){ - assert.equal(getCardValue(`${n}♦`), n) + for(let n = 2; n <= 10; n++) { + assert.equal(getCardValue(`${n}♦`), n); } -}) +}); test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From 84f32b87874fc72d52e540639dee41d514c9f8dc Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 21:36:19 +0100 Subject: [PATCH 71/99] Add test for valid double-digit '10' card to ensure correct value returns --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++++ 1 file changed, 4 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 6be212480..d7216d1e4 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 @@ -24,6 +24,10 @@ test("Number cards 2 to 10 return their numbers", () => { assert.equal(getCardValue(`${n}♦`), n); } }); + +test("Only valid double-digit '10' card", () => { + assert.equal(getCardValue("10♥"), 10); +}) test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From ea302ed3c6d93775e7f1e2aa05b26f83a4569d3a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 21:48:42 +0100 Subject: [PATCH 72/99] Add tests to ensure all four suits are accepted --- .../3-get-card-value.test.js | 9 ++++++++- 1 file changed, 8 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 d7216d1e4..f6b2099dc 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 @@ -27,7 +27,14 @@ test("Number cards 2 to 10 return their numbers", () => { test("Only valid double-digit '10' card", () => { assert.equal(getCardValue("10♥"), 10); -}) +}); + +test("Accepts all four suits", () => { + for (const suit of ["♠", "♥", "♦", "♣"]){ + assert.equal(getCardValue(`5${suit}`), 5); + } +}); + test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); From 78d0ff4a0019d872dc0ab37ea0a60c241a298d7c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:01:38 +0100 Subject: [PATCH 73/99] Add test for missing suit to validate error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++++ 1 file changed, 4 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 f6b2099dc..ab2384ab7 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 @@ -40,3 +40,7 @@ test("Arbitrary non-card string", () => { }); // TODO: What other invalid card cases can you think of? +test("Missing suit", () => { + assert.equal(getCardValue("7"), /Expected a number followed by a suit/); + assert.equal(getCardValue("A"), /Expected a number followed by a result/); +}); \ No newline at end of file From 6635d24700881b3b5089eda35de4bb4c5b2bd8b8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:19:24 +0100 Subject: [PATCH 74/99] Add test for missing ranks to validate error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 +++++- 1 file changed, 5 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 ab2384ab7..7a79f935e 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 @@ -43,4 +43,8 @@ test("Arbitrary non-card string", () => { test("Missing suit", () => { assert.equal(getCardValue("7"), /Expected a number followed by a suit/); assert.equal(getCardValue("A"), /Expected a number followed by a result/); -}); \ No newline at end of file +}); + +test("Missing ranks", () => { + assert.equal(() => getCardValue("♥"), /Expected a number followed by a suit/); +}) \ No newline at end of file From 700c2b9b5a721edfd879fe0c872c7da7edbce358 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:23:56 +0100 Subject: [PATCH 75/99] Fix tests for missing suit and ranks to ensure proper error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 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 7a79f935e..b7dd4cc9f 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 @@ -41,10 +41,10 @@ test("Arbitrary non-card string", () => { // TODO: What other invalid card cases can you think of? test("Missing suit", () => { - assert.equal(getCardValue("7"), /Expected a number followed by a suit/); - assert.equal(getCardValue("A"), /Expected a number followed by a result/); + assert.throws(() => getCardValue("7"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("A"), /Expected a number followed by a suit/); }); test("Missing ranks", () => { - assert.equal(() => getCardValue("♥"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("♥"), /Expected a number followed by a suit/); }) \ No newline at end of file From c06b70179d48f44d2defd4688618567734cfa458 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:25:53 +0100 Subject: [PATCH 76/99] Add test for empty strings to validate error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++++ 1 file changed, 4 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 b7dd4cc9f..963e9398d 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 @@ -47,4 +47,8 @@ test("Missing suit", () => { test("Missing ranks", () => { assert.throws(() => getCardValue("♥"), /Expected a number followed by a suit/); +}); + +test("Empty strings", () => { + assert.throws(() => getCardValue(""), /Expected a number followed by a suit/); }) \ No newline at end of file From bc54e01c7895665e97f05df58ee2cfa22688dd10 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:32:13 +0100 Subject: [PATCH 77/99] Add test for out-of-range number ranks to validate error handling --- .../3-get-card-value.test.js | 8 +++++++- 1 file changed, 7 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 963e9398d..80fcf901b 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 @@ -51,4 +51,10 @@ test("Missing ranks", () => { test("Empty strings", () => { assert.throws(() => getCardValue(""), /Expected a number followed by a suit/); -}) \ No newline at end of file +}); + +test("Out-of-range number ranks", () => { + for (const OOR of ["0♥", "1♠", "11♦", "100♣"]) { + assert.throws(() => getCardValue(OOR), /Expected a number followed by a suit/); + } +}); \ No newline at end of file From 47797b5489e4bc66ba4d154f2705d1cc6e00e5d9 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:44:20 +0100 Subject: [PATCH 78/99] Add test for unknown suit to validate error handling --- .../3-get-card-value.test.js | 7 ++++++- 1 file changed, 6 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 80fcf901b..874584bc0 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 @@ -57,4 +57,9 @@ test("Out-of-range number ranks", () => { for (const OOR of ["0♥", "1♠", "11♦", "100♣"]) { assert.throws(() => getCardValue(OOR), /Expected a number followed by a suit/); } -}); \ No newline at end of file +}); + +test("Unknown suit", () => { + assert.throws(() => getCardValue("A❤"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("AV"), /Expected a number followed by a suit/); +}) \ No newline at end of file From a6231b0801467acc4766704296d495b482756797 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:57:06 +0100 Subject: [PATCH 79/99] Add test for lowercase ranks to validate error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 5 +++++ 1 file changed, 5 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 874584bc0..2797d81d6 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 @@ -62,4 +62,9 @@ test("Out-of-range number ranks", () => { test("Unknown suit", () => { assert.throws(() => getCardValue("A❤"), /Expected a number followed by a suit/); assert.throws(() => getCardValue("AV"), /Expected a number followed by a suit/); +}); + +test("Lowercase ranks", () => { + assert.throws(() => getCardValue("a♦"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("k♥"), /Expected a number followed by a suit/); }) \ No newline at end of file From 20e286aa6fc18db320c2204fc4997e8b60ce38e7 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 22:59:01 +0100 Subject: [PATCH 80/99] Add test for suit before rank to validate error handling --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 +++++- 1 file changed, 5 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 2797d81d6..b5293b8b8 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 @@ -67,4 +67,8 @@ test("Unknown suit", () => { test("Lowercase ranks", () => { assert.throws(() => getCardValue("a♦"), /Expected a number followed by a suit/); assert.throws(() => getCardValue("k♥"), /Expected a number followed by a suit/); -}) \ No newline at end of file +}); + +test("Suit before rank", () => { + assert.throws(() => getCardValue("♣A"), /Expected a number followed by a suit/); +}); \ No newline at end of file From d91a6cbc7917c128e91ba811168e85fb3f402d60 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 23:19:04 +0100 Subject: [PATCH 81/99] Add tests for extra characters, spaces, and non-string inputs to validate error handling --- .../3-get-card-value.test.js | 11 +++++++++++ 1 file changed, 11 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 b5293b8b8..765ccd34d 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 @@ -71,4 +71,15 @@ test("Lowercase ranks", () => { test("Suit before rank", () => { assert.throws(() => getCardValue("♣A"), /Expected a number followed by a suit/); +}); + +test("Extra characters or spaces", () => { + for (const ExS of [" A♦", "A♦ ", "A♦♦", "A ♦"]){ + assert.throws(() => getCardValue(ExS), /Expected a number followed by a suit/); + } +}); + +test("Non-string input", () => { + assert.throws(() => getCardValue(undefined), /Expected a number followed by a suit/); + assert.throws(() => getCardValue(5), /Expected a number followed by a suit/); }); \ No newline at end of file From 2052992f641685a63050f40b99e8410ab631a27b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 23:20:46 +0100 Subject: [PATCH 82/99] Remove commented-out console log for getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 - 1 file changed, 1 deletion(-) 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 1b68bf598..05a47f6d2 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -52,4 +52,3 @@ export function getCardValue(card) { throw error; } -// console.log(getCardValue("A♦")); From e021e17f90c2d327596574148afebabaaaf072b4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 23:48:53 +0100 Subject: [PATCH 83/99] Remove formatAs12HourClock function and its tests due to refactoring --- format-clock-edge-cases/README.md | 15 ------- format-clock-edge-cases/timeConverter.js | 10 ----- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 3 files changed, 66 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index f4a24c094..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,10 +0,0 @@ -function formatAs12HourClock(time) { - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - const period = hours < 12 ? "am" : "pm"; - - const displayHour = hours % 12 || 12; - return `${displayHour}:${minutePart}${period}`; -} -export { formatAs12HourClock }; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index bc3a9a933..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { formatAs12HourClock } from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}); -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}); -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}); -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}); -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}); -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}); -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}); -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}); -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}); -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}); From 5c7ee795abcb5ed86094f5cac52f6e9626d59798 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 23:49:24 +0100 Subject: [PATCH 84/99] Add formatAs12HourClock function and corresponding tests for time conversion --- format-clock-edge-cases/README.md | 15 +++++++ format-clock-edge-cases/timeConverter.js | 10 +++++ format-clock-edge-cases/timeConverter.test.js | 41 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 format-clock-edge-cases/README.md 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/README.md b/format-clock-edge-cases/README.md new file mode 100644 index 000000000..8a43a9e96 --- /dev/null +++ b/format-clock-edge-cases/README.md @@ -0,0 +1,15 @@ +In your prep, you looked this `formatAs12HourClock` function: + +```js +function formatAs12HourClock(time) { + + const hours = Number(time.slice(0, 2)); + + if (hours > 12) { + return `${hours - 12}:00 pm`; + } + return `${time} am`; +} +``` + +It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..f4a24c094 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,10 @@ +function formatAs12HourClock(time) { + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + const period = hours < 12 ? "am" : "pm"; + + const displayHour = hours % 12 || 12; + return `${displayHour}:${minutePart}${period}`; +} +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..bc3a9a933 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,41 @@ +import { formatAs12HourClock } from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); + +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}); +test("converts exactly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}); +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}); +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}); +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}); +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}); +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}); +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}); +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}); +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}); From 1c195d74408b74006b8616826d58f3effbb8c41b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 8 Oct 2026 23:52:23 +0100 Subject: [PATCH 85/99] Remove formatAs12HourClock function and its tests due to refactoring --- format-clock-edge-cases/README.md | 15 ------- format-clock-edge-cases/timeConverter.js | 10 ----- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 3 files changed, 66 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index f4a24c094..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,10 +0,0 @@ -function formatAs12HourClock(time) { - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - const period = hours < 12 ? "am" : "pm"; - - const displayHour = hours % 12 || 12; - return `${displayHour}:${minutePart}${period}`; -} -export { formatAs12HourClock }; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index bc3a9a933..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { formatAs12HourClock } from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}); -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}); -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}); -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}); -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}); -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}); -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}); -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}); -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}); -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}); From 7a4a0c7539fcd0ea9d3ce81b1f81034e1461bf21 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 00:09:44 +0100 Subject: [PATCH 86/99] Implement formatAs12HourClock function with comprehensive tests for time conversion --- format-clock-edge-cases/README.md | 15 +++++++ format-clock-edge-cases/timeConverter.js | 31 ++++++++++++++ format-clock-edge-cases/timeConverter.test.js | 41 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 format-clock-edge-cases/README.md 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/README.md b/format-clock-edge-cases/README.md new file mode 100644 index 000000000..8a43a9e96 --- /dev/null +++ b/format-clock-edge-cases/README.md @@ -0,0 +1,15 @@ +In your prep, you looked this `formatAs12HourClock` function: + +```js +function formatAs12HourClock(time) { + + const hours = Number(time.slice(0, 2)); + + if (hours > 12) { + return `${hours - 12}:00 pm`; + } + return `${time} am`; +} +``` + +It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..d941da6e8 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,31 @@ +// function formatAs12HourClock(time) { + +// const hours = Number(time.slice(0, 2)); + +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export {formatAs12HourClock}; + +function formatAs12HourClock(time){ + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + let period; + if(hours < 12){ + period = "am"; + } else { + period = "pm"; + } + + let displayHour = hours % 12; + if(displayHour === 0){ + displayHour = 12; + } + return `${displayHour}:${minutePart}${period}`; +} +export {formatAs12HourClock}; +console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js new file mode 100644 index 000000000..ac64852b1 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,41 @@ +import {formatAs12HourClock} from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); + +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) +test("converts exactly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}) +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}) +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}) +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}) +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}) +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}) +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}) +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}) +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}) +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}) \ No newline at end of file From e313bdcccb580e9fe35eea247b27da738226a379 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 00:15:28 +0100 Subject: [PATCH 87/99] Remove formatAs12HourClock function and its tests due to refactoring --- format-clock-edge-cases/README.md | 15 ------- format-clock-edge-cases/timeConverter.js | 31 -------------- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 3 files changed, 87 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index d941da6e8..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,31 +0,0 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; - } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; -} -export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index ac64852b1..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import {formatAs12HourClock} from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file From c6ae2f73bdb8783fe33e8997fb289011cca3a3d0 Mon Sep 17 00:00:00 2001 From: Moses777 Date: Fri, 9 Oct 2026 00:18:43 +0100 Subject: [PATCH 88/99] Delete format-clock-edge-cases/timeConverter.js --- format-clock-edge-cases/timeConverter.js | 31 ------------------------ 1 file changed, 31 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 d941da6e8..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,31 +0,0 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; - } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; -} -export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) From 32535c774fb332672d03d9d6c5f1d152c478b47c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 00:22:30 +0100 Subject: [PATCH 89/99] Add formatAs12HourClock function and comprehensive tests for edge cases --- format-clock-edge-cases/README.md | 15 +++++++ format-clock-edge-cases/timeConverter.js | 31 ++++++++++++++ format-clock-edge-cases/timeConverter.test.js | 41 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 format-clock-edge-cases/README.md 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/README.md b/format-clock-edge-cases/README.md new file mode 100644 index 000000000..8a43a9e96 --- /dev/null +++ b/format-clock-edge-cases/README.md @@ -0,0 +1,15 @@ +In your prep, you looked this `formatAs12HourClock` function: + +```js +function formatAs12HourClock(time) { + + const hours = Number(time.slice(0, 2)); + + if (hours > 12) { + return `${hours - 12}:00 pm`; + } + return `${time} am`; +} +``` + +It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..d941da6e8 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,31 @@ +// function formatAs12HourClock(time) { + +// const hours = Number(time.slice(0, 2)); + +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export {formatAs12HourClock}; + +function formatAs12HourClock(time){ + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + let period; + if(hours < 12){ + period = "am"; + } else { + period = "pm"; + } + + let displayHour = hours % 12; + if(displayHour === 0){ + displayHour = 12; + } + return `${displayHour}:${minutePart}${period}`; +} +export {formatAs12HourClock}; +console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js new file mode 100644 index 000000000..ac64852b1 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,41 @@ +import {formatAs12HourClock} from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); + +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) +test("converts exactly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}) +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}) +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}) +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}) +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}) +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}) +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}) +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}) +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}) +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}) \ No newline at end of file From 46a0c2e163d9deca4d7c49f5aedbba180f78894e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 00:30:41 +0100 Subject: [PATCH 90/99] Complete Sprint 3 implement and rewrite exercises --- .../1-get-angle-type.test.js | 29 ++++++++ .../2-is-proper-fraction.test.js | 14 +++- .../3-get-card-value.test.js | 69 +++++++++++++++++++ .../implement/1-get-angle-type.js | 14 +++- .../implement/2-is-proper-fraction.js | 6 +- .../implement/3-get-card-value.js | 28 +++++++- 6 files changed, 156 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 cf50f6cad..32d473387 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,32 @@ test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + +test("Classifies acute angles", () => { + assert.equal(getAngleType(45), "Acute angle"); + assert.equal(getAngleType(1), "Acute angle"); + assert.equal(getAngleType(89), "Acute angle"); +}); + +test("Classifies obtuse angles", () => { + assert.equal(getAngleType(91), "Obtuse angle"); + assert.equal(getAngleType(135), "Obtuse angle"); + assert.equal(getAngleType(179), "Obtuse angle"); +}); + +test("Classifies straight angles", () => { + assert.equal(getAngleType(180), "Straight angle"); +}); + +test("Classifies reflex angles", () => { + assert.equal(getAngleType(181), "Reflex angle"); + assert.equal(getAngleType(270), "Reflex angle"); + assert.equal(getAngleType(359), "Reflex angle"); +}); + +test("Classifies invalid angles", () => { + assert.equal(getAngleType(0), "Invalid angle"); + assert.equal(getAngleType(360), "Invalid angle"); + assert.equal(getAngleType(400), "Invalid angle"); + assert.equal(getAngleType(-5), "Invalid angle"); +}) 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..75ebbe7fd 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 @@ -7,6 +7,18 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // What combinations of numerators and denominators should you test? test("Basic proper fraction", () => { - // Example: 1/2 is a proper fraction assert.equal(isProperFraction(1, 2), true); + assert.equal(isProperFraction(0, 5), true); + assert.equal(isProperFraction(-1, 2), true); + assert.equal(isProperFraction(1, -2), true); + assert.equal(isProperFraction(-1, -2), true); +}); + +test("Basic improper fraction", () => { + assert.equal(isProperFraction(5, 2), false); + assert.equal(isProperFraction(3, 3), false); + assert.equal(isProperFraction(5, 0), false); + assert.equal(isProperFraction(-5, 2), false); + assert.equal(isProperFraction(5, -2), false); + assert.equal(isProperFraction(-5, -2), false); }); 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..765ccd34d 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 @@ -9,8 +9,77 @@ test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); +test("Ace returns 11", () => { + assert.equal(getCardValue("A♠"), 11); +}); + +test("Face cards return 10", () => { + assert.equal(getCardValue("J♣"), 10); + assert.equal(getCardValue("Q♦"), 10); + assert.equal(getCardValue("K♥"), 10); +}) + +test("Number cards 2 to 10 return their numbers", () => { + for(let n = 2; n <= 10; n++) { + assert.equal(getCardValue(`${n}♦`), n); + } +}); + +test("Only valid double-digit '10' card", () => { + assert.equal(getCardValue("10♥"), 10); +}); + +test("Accepts all four suits", () => { + for (const suit of ["♠", "♥", "♦", "♣"]){ + assert.equal(getCardValue(`5${suit}`), 5); + } +}); + 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? +test("Missing suit", () => { + assert.throws(() => getCardValue("7"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("A"), /Expected a number followed by a suit/); +}); + +test("Missing ranks", () => { + assert.throws(() => getCardValue("♥"), /Expected a number followed by a suit/); +}); + +test("Empty strings", () => { + assert.throws(() => getCardValue(""), /Expected a number followed by a suit/); +}); + +test("Out-of-range number ranks", () => { + for (const OOR of ["0♥", "1♠", "11♦", "100♣"]) { + assert.throws(() => getCardValue(OOR), /Expected a number followed by a suit/); + } +}); + +test("Unknown suit", () => { + assert.throws(() => getCardValue("A❤"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("AV"), /Expected a number followed by a suit/); +}); + +test("Lowercase ranks", () => { + assert.throws(() => getCardValue("a♦"), /Expected a number followed by a suit/); + assert.throws(() => getCardValue("k♥"), /Expected a number followed by a suit/); +}); + +test("Suit before rank", () => { + assert.throws(() => getCardValue("♣A"), /Expected a number followed by a suit/); +}); + +test("Extra characters or spaces", () => { + for (const ExS of [" A♦", "A♦ ", "A♦♦", "A ♦"]){ + assert.throws(() => getCardValue(ExS), /Expected a number followed by a suit/); + } +}); + +test("Non-string input", () => { + assert.throws(() => getCardValue(undefined), /Expected a number followed by a suit/); + assert.throws(() => getCardValue(5), /Expected a number followed by a suit/); +}); \ No newline at end of file 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..4ff290d94 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -17,5 +17,17 @@ // execute the code to ensure all tests pass. export function getAngleType(angle) { - // TODO: Implement this function + if(angle > 0 && angle < 90) { + return "Acute angle"; + } else if(angle === 90) { + 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"; + } } 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..f56b51bf3 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,5 +14,9 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if(Math.abs(numerator) < Math.abs(denominator)){ + return true; + } else { + return false; + } } 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..05a47f6d2 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,5 +24,31 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - // TODO: Implement this function + const validSuits = ["♠", "♥", "♦", "♣"]; + const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; + const faceRanks = ["J", "Q", "K"]; + + const error = new Error(`Expected a number followed by a suit, but got "${card}"`); + + if(typeof card !== "string" || card.length < 2){ + throw error; + } + + const suit = card.slice(-1); + const rank = card.slice(0, -1); + + if(!validSuits.includes(suit)){ + throw error; + } + if(rank === "A") { + return 11; + } + if(faceRanks.includes(rank)){ + return 10; + } + if(numberRanks.includes(rank)){ + return Number(rank); + } + throw error; } + From 072555ca480349b5fcfde7266a3ad02451002274 Mon Sep 17 00:00:00 2001 From: Moses777 Date: Fri, 9 Oct 2026 00:50:38 +0100 Subject: [PATCH 91/99] Delete format-clock-edge-cases/timeConverter.test.js --- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 1 file changed, 41 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 ac64852b1..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import {formatAs12HourClock} from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file From 6bba53a7947145968b40776a9c5fb34a5a9d833c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 00:57:25 +0100 Subject: [PATCH 92/99] Exclude format-clock-edge-cases from PR --- format-clock-edge-cases/timeConverter.js | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 format-clock-edge-cases/timeConverter.js diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..d941da6e8 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,31 @@ +// function formatAs12HourClock(time) { + +// const hours = Number(time.slice(0, 2)); + +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export {formatAs12HourClock}; + +function formatAs12HourClock(time){ + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + let period; + if(hours < 12){ + period = "am"; + } else { + period = "pm"; + } + + let displayHour = hours % 12; + if(displayHour === 0){ + displayHour = 12; + } + return `${displayHour}:${minutePart}${period}`; +} +export {formatAs12HourClock}; +console.log(formatAs12HourClock("08:40")) From d11f6347a9a2ea22a619039aebad56913f5790f8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:00:12 +0100 Subject: [PATCH 93/99] Add unit tests for time conversion in timeConverter.js --- format-clock-edge-cases/timeConverter.test.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create 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 new file mode 100644 index 000000000..ac64852b1 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,41 @@ +import {formatAs12HourClock} from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); + +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) +test("converts exactly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}) +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}) +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}) +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}) +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}) +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}) +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}) +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}) +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}) +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}) \ No newline at end of file From 94742395f1e398c0f7a9a33075a6763d029597ae Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:31:22 +0100 Subject: [PATCH 94/99] Remove formatAs12HourClock function and associated tests --- format-clock-edge-cases/README.md | 15 ------- format-clock-edge-cases/timeConverter.js | 31 -------------- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 3 files changed, 87 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index d941da6e8..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,31 +0,0 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; - } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; -} -export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index ac64852b1..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import {formatAs12HourClock} from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file From 4a91c034fb63ebd8a6fd99b629ea64cd8fbf383b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:32:51 +0100 Subject: [PATCH 95/99] Remove formatAs12HourClock function and associated tests --- format-clock-edge-cases/README.md | 15 ------- format-clock-edge-cases/timeConverter.js | 31 -------------- format-clock-edge-cases/timeConverter.test.js | 41 ------------------- 3 files changed, 87 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js delete mode 100644 format-clock-edge-cases/timeConverter.test.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index d941da6e8..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,31 +0,0 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; - } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; -} -export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js deleted file mode 100644 index ac64852b1..000000000 --- a/format-clock-edge-cases/timeConverter.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import {formatAs12HourClock} from "./timeConverter.js"; -import assert from "node:assert"; -import test from "node:test"; - -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}); - -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file From a8d45ee98bbd2d541e15a99ce36d5a00c0c226ed Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:37:55 +0100 Subject: [PATCH 96/99] Add unit tests for time conversion in timeConverter.js --- format-clock-edge-cases/README.md | 15 ------------ format-clock-edge-cases/timeConverter.js | 31 ------------------------ 2 files changed, 46 deletions(-) delete mode 100644 format-clock-edge-cases/README.md delete mode 100644 format-clock-edge-cases/timeConverter.js diff --git a/format-clock-edge-cases/README.md b/format-clock-edge-cases/README.md deleted file mode 100644 index 8a43a9e96..000000000 --- a/format-clock-edge-cases/README.md +++ /dev/null @@ -1,15 +0,0 @@ -In your prep, you looked this `formatAs12HourClock` function: - -```js -function formatAs12HourClock(time) { - - const hours = Number(time.slice(0, 2)); - - if (hours > 12) { - return `${hours - 12}:00 pm`; - } - return `${time} am`; -} -``` - -It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js deleted file mode 100644 index d941da6e8..000000000 --- a/format-clock-edge-cases/timeConverter.js +++ /dev/null @@ -1,31 +0,0 @@ -// function formatAs12HourClock(time) { - -// const hours = Number(time.slice(0, 2)); - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; - } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; -} -export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) From e817ed0f7c13481f28e54c6165e816b382858cce Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:44:15 +0100 Subject: [PATCH 97/99] Implement formatAs12HourClock function and add comprehensive unit tests --- format-clock-edge-cases/README.md | 15 +++++++ format-clock-edge-cases/timeConverter.js | 31 ++++++++++++++ format-clock-edge-cases/timeConverter.test.js | 41 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 format-clock-edge-cases/README.md 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/README.md b/format-clock-edge-cases/README.md new file mode 100644 index 000000000..8a43a9e96 --- /dev/null +++ b/format-clock-edge-cases/README.md @@ -0,0 +1,15 @@ +In your prep, you looked this `formatAs12HourClock` function: + +```js +function formatAs12HourClock(time) { + + const hours = Number(time.slice(0, 2)); + + if (hours > 12) { + return `${hours - 12}:00 pm`; + } + return `${time} am`; +} +``` + +It still has bugs. Think of as many edge-cases as you can with this code. Write tests for all of them, and fix this code so that it works correctly for all valid inputs. You don't need to worry about invalid inputs (e.g. `"25:00"`). diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js new file mode 100644 index 000000000..d941da6e8 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.js @@ -0,0 +1,31 @@ +// function formatAs12HourClock(time) { + +// const hours = Number(time.slice(0, 2)); + +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export {formatAs12HourClock}; + +function formatAs12HourClock(time){ + const [hourPart, minutePart] = time.split(":"); + const hours = Number(hourPart); + + let period; + if(hours < 12){ + period = "am"; + } else { + period = "pm"; + } + + let displayHour = hours % 12; + if(displayHour === 0){ + displayHour = 12; + } + return `${displayHour}:${minutePart}${period}`; +} +export {formatAs12HourClock}; +console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js new file mode 100644 index 000000000..ac64852b1 --- /dev/null +++ b/format-clock-edge-cases/timeConverter.test.js @@ -0,0 +1,41 @@ +import {formatAs12HourClock} from "./timeConverter.js"; +import assert from "node:assert"; +import test from "node:test"; + +test("correctly convert time after 12:00", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}); + +test("converts a single-digit morning hour and drops leading zero", () => { + assert.equal(formatAs12HourClock("08:00"), "8:00am"); +}) +test("converts exactly to midnight", () => { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}) +test("converts time just after midnight", () => { + assert.equal(formatAs12HourClock("00:30"), "12:30am"); +}) +test("converts the last minute before noon", () => { + assert.equal(formatAs12HourClock("11:59"), "11:59am"); +}) +test("converts exact noon to pm", () => { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +}) +test("convert time just after noon", () => { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +}) +test("converts the first afternoon hour", () => { + assert.equal(formatAs12HourClock("13:00"), "1:00pm"); +}) +test("converts late evening hour", () => { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +}) +test("converts last minute of the day", () => { + assert.equal(formatAs12HourClock("23:59"), "11:59pm"); +}) +test("preserves minutes with leading zero", () => { + assert.equal(formatAs12HourClock("09:05"), "9:05am"); +}) +test("preserves non-zero minutes", () => { + assert.equal(formatAs12HourClock("14:45"), "2:45pm"); +}) \ No newline at end of file From d5895355956cad03a416c260a8b1c0b648e4bfb5 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 01:52:09 +0100 Subject: [PATCH 98/99] Revert unrelated format-clock-edge-cases changes --- format-clock-edge-cases/timeConverter.js | 32 +++------------ format-clock-edge-cases/timeConverter.test.js | 40 +++---------------- 2 files changed, 11 insertions(+), 61 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index d941da6e8..310c07bd9 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,31 +1,11 @@ -// function formatAs12HourClock(time) { +function formatAs12HourClock(time) { -// const hours = Number(time.slice(0, 2)); + const hours = Number(time.slice(0, 2)); -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export {formatAs12HourClock}; - -function formatAs12HourClock(time){ - const [hourPart, minutePart] = time.split(":"); - const hours = Number(hourPart); - - let period; - if(hours < 12){ - period = "am"; - } else { - period = "pm"; + if (hours > 12) { + return `${hours - 12}:00 pm`; } - - let displayHour = hours % 12; - if(displayHour === 0){ - displayHour = 12; - } - return `${displayHour}:${minutePart}${period}`; + return `${time} am`; } + export {formatAs12HourClock}; -console.log(formatAs12HourClock("08:40")) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index ac64852b1..88f2af094 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,40 +2,10 @@ import {formatAs12HourClock} from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("correctly convert time after 12:00", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +test("correctly convert time after 12:00", function(){ + assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); -test("converts a single-digit morning hour and drops leading zero", () => { - assert.equal(formatAs12HourClock("08:00"), "8:00am"); -}) -test("converts exactly to midnight", () => { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); -}) -test("converts time just after midnight", () => { - assert.equal(formatAs12HourClock("00:30"), "12:30am"); -}) -test("converts the last minute before noon", () => { - assert.equal(formatAs12HourClock("11:59"), "11:59am"); -}) -test("converts exact noon to pm", () => { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); -}) -test("convert time just after noon", () => { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); -}) -test("converts the first afternoon hour", () => { - assert.equal(formatAs12HourClock("13:00"), "1:00pm"); -}) -test("converts late evening hour", () => { - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); -}) -test("converts last minute of the day", () => { - assert.equal(formatAs12HourClock("23:59"), "11:59pm"); -}) -test("preserves minutes with leading zero", () => { - assert.equal(formatAs12HourClock("09:05"), "9:05am"); -}) -test("preserves non-zero minutes", () => { - assert.equal(formatAs12HourClock("14:45"), "2:45pm"); -}) \ No newline at end of file +test("can correctly convert morning time", function() { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); +}); From 0b0eac2afe04cf09c705642aa49b8feb3aa98009 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 9 Oct 2026 22:08:15 +0100 Subject: [PATCH 99/99] Add test case for zero numerator with negative denominator in isProperFraction --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 75ebbe7fd..a566b7d98 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 @@ -9,6 +9,7 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(0, 5), true); + assert.equal(isProperFraction(0, -5), true); assert.equal(isProperFraction(-1, 2), true); assert.equal(isProperFraction(1, -2), true); assert.equal(isProperFraction(-1, -2), true);