From 4c6240085f9e3d7d73593f31f2ef4ff60a798c0d Mon Sep 17 00:00:00 2001 From: Jorvan White Date: Wed, 10 Jun 2026 12:20:39 +0100 Subject: [PATCH 01/27] updated 1-count.js with an explanation of line 3 --- Sprint-1/1-key-exercises/1-count.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..b150e6b932 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,7 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing + +// = is assigning the value of 'count', +// 'let' is a declararation than enables its subject (count) to be changed +// line 3 is taking the current value in line 1 (0) and by using '=' it is reassigning the value of 'count' to equal itself plus 1 \ No newline at end of file From 376a6b01cc4999bf60a0b87527c15cde540554dd Mon Sep 17 00:00:00 2001 From: JorvanW Date: Sat, 27 Jun 2026 11:47:24 +0100 Subject: [PATCH 02/27] added answers to 0.js --- Sprint-2/1-key-errors/0.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..4eacc94f29 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// =============> The fuction intends to capitalize the first letter of the input string +// from th left starting with the first character (str[0]). // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,5 +10,7 @@ function capitalise(str) { return str; } -// =============> write your explanation here -// =============> write your new code here +// =============> str has already been declared as a parameter function, so it cannot be redeclared within the function body. This will cause a syntax error. To fix this, we should use a different variable name for the new string we are creating. +// =============> function capitalise(str) { +// str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; From 2323e101560b0537b907a05193dbee0334bf0e57 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Sat, 27 Jun 2026 12:00:41 +0100 Subject: [PATCH 03/27] Added notes for 1.js --- Sprint-2/1-key-errors/1.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..eff952dc5c 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,7 +1,8 @@ // Predict and explain first... -// Why will an error occur when this program runs? -// =============> write your prediction here +// Why will an error occur when this program runs? +// =============> decimalNumber is a constant variable, and cannot be changed. +// The code is attempting to change it which will cause an error. // Try playing computer with the example to work out what is going on @@ -14,7 +15,12 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// =============> The code is attempting to get the percentage of decimalNumber // Finally, correct the code to fix the problem -// =============> write your new code here +function convertToPercentage(decimalNumber) { + decimalNumber = 0.5; + const percentage = `${decimalNumber * 100}%`; + return percentage; +} +console.log (convertToPercentage(0.5)); \ No newline at end of file From 87fbee5134b7cedff178c060e00e940c928563f8 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Sat, 27 Jun 2026 12:17:06 +0100 Subject: [PATCH 04/27] added notes for 2.js --- Sprint-2/1-key-errors/2.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..f8b6621567 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,18 +3,22 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> num is not defined which causes an error. function square(3) { return num * num; } -// =============> write the error message here +// =============> 1. "Uncaught SyntaxError: Unexpected number" Means the "3" is not valid there. +// 2. Uncaught SyntaxError: Illegal return statement. Means "num" has no idea of what it should be -// =============> explain this error message here // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> by adding square(num) the function will work when given a number +function square(num) { + return num * num; +} +console.log(square(3)) From 57e3a65741c6be3cc4537ce35d8ede213e9132e4 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Mon, 29 Jun 2026 10:43:21 +0100 Subject: [PATCH 05/27] added notes to 0.js --- Sprint-2/1-key-errors/0.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 4eacc94f29..3a843eda2b 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -11,6 +11,7 @@ function capitalise(str) { } // =============> str has already been declared as a parameter function, so it cannot be redeclared within the function body. This will cause a syntax error. To fix this, we should use a different variable name for the new string we are creating. -// =============> function capitalise(str) { -// str = `${str[0].toUpperCase()}${str.slice(1)}`; -// return str; +// =============> + function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; \ No newline at end of file From bf5c3320dad52e8b6d4cb5a2e8ab1fc23d1c27df Mon Sep 17 00:00:00 2001 From: JorvanW Date: Mon, 29 Jun 2026 10:58:56 +0100 Subject: [PATCH 06/27] added answer to 0.js --- Sprint-2/2-mandatory-debug/0.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..26b87fd105 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// =============> Code is attempting to multiple a & b but there is no return value function multiply(a, b) { console.log(a * b); @@ -8,7 +8,11 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> because there is no return value, the outcome stays as undefined while giving the answer +// to fix this, change "console.log" in the second row to "return" +// // Finally, correct the code to fix the problem -// =============> write your new code here +function multiply(a, b) { + return (a * b); +} From 4ca3f91c41793395c203b9d0bf4e535988d61362 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Mon, 29 Jun 2026 11:19:08 +0100 Subject: [PATCH 07/27] added notes to 1.js --- Sprint-2/2-mandatory-debug/1.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..a4e2e1d976 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// =============> the function is attempting to add "a" & "b" together +// but the return is formatted wrong. function sum(a, b) { return; @@ -8,6 +9,12 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> because of the way line 6 and 7 is written the answer will be undefined. +//remove the semi colon from line 6 and then add line 7 to it. // Finally, correct the code to fix the problem -// =============> write your new code here + +function sum(a, b) { + return (a + b); +} + +console.log(sum(10, 32)) From 185c7e745d4c586e16ba493666ed32b4698ff21a Mon Sep 17 00:00:00 2001 From: JorvanW Date: Mon, 29 Jun 2026 11:29:41 +0100 Subject: [PATCH 08/27] added answers to 2.js --- Sprint-2/2-mandatory-debug/2.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..b145646d95 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,7 +1,8 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> The function is trying to get the last digit of "num" +// but because on "const", the "num" is always locked to "103" leaving the return always "3" const num = 103; @@ -14,11 +15,22 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction -// =============> write the output here +// =============> Just as predicted, the function is trying to get the last digit, which is always "3" // Explain why the output is the way it is -// =============> write your explanation here +// =============> because of "const" the num is always locked to "103" // Finally, correct the code to fix the problem -// =============> write your new code here + +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + // This program should tell the user the last digit of each number. -// Explain why getLastDigit is not working properly - correct the problem +// Explain why getLastDigit is not working properly +// It's not working properly because of the "const num = 103" +// to fix, I have removed the line and added "(num)" after "function getLastDigit" +// In order to define what "num" is. From 195189aa7cd5b896c67e360ebd03c4e5114f9f90 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Sat, 4 Jul 2026 15:38:10 +0100 Subject: [PATCH 09/27] completed. 1-bmi --- Sprint-2/3-mandatory-implement/1-bmi.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1b..55f462875e 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,4 +16,11 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} \ No newline at end of file +} + +function calculateBMI(weight, height) { + const bmi = weight / (height * height); + return parseFloat(bmi.toFixed(1)); +} + +console.log(calculateBMI(70, 1.73)); \ No newline at end of file From 3f957a175bd3e263e8f6910223550b5ee50b5978 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Sat, 4 Jul 2026 15:45:33 +0100 Subject: [PATCH 10/27] Answered the questions for 2-cases.js --- Sprint-2/3-mandatory-implement/2-cases.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad9..3ae8e664d5 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,11 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase + + +function Capitalise(inputString) { + return inputString.toUpperCase() + +} + +Console.log(Capitalise("hello there")); \ No newline at end of file From b48031e6e1ec90f1c16f1a91521f3c042323af2d Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 8 Jul 2026 15:10:30 +0100 Subject: [PATCH 11/27] Added answers to the questions in the time-format.js file. --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..cfd2bf1b46 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,23 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs + +const penceString = "399p"; + +const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 +); + +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 +); + +const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); + +console.log(`£${pounds}.${pence}`); + From 216221aa5f92c63e4b9efbe244e5b16b5fa0ade6 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Tue, 14 Jul 2026 11:32:24 +0100 Subject: [PATCH 12/27] Created code for 1-get-angle-type.js --- Sprint-2/4-mandatory-interpret/time-format.js | 10 +++++----- .../CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt | 1 + .../implement/1-get-angle-type.js | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 160000 Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01e..def76acebe 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -21,18 +21,18 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> Pad will be called 3 times, once for totalHours, once for remainingMinutes, and once for remainingSeconds. // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> The value will be 0 // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> The return value will be "00" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> The value assigned to num when pad is called for the last time in this program will be 1.Because it is the value of the remainingSeconds variable, which is calculated as 61 % 60 = 1. // e) What is the return value of pad when it is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> The output is "01" because the pad function adds a leading zero to the number 1, resulting in a two-character string "01". diff --git a/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt b/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt new file mode 160000 index 0000000000..3e66462a26 --- /dev/null +++ b/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt @@ -0,0 +1 @@ +Subproject commit 3e66462a26c1d68cc2ac562b0d3ad7b3c2210fa1 diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e2..5beae94ed0 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -35,3 +35,18 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + +let getAngleType(angle) { + if (angle > 0 && angle < 90) { + return "Acute angle";} + if (angle === 90) { + return "Right angle";} + if (angle > 90 && angle < 180) { + return "Obtuse angle";} + if (angle === 180) { + return "Straight angle";} + if (angle > 180 && angle < 360) { + return "Reflex angle";} + return "Invalid angle"; +} + From d10fc3c577b3d917a771e5684d69850f77079bdf Mon Sep 17 00:00:00 2001 From: JorvanW Date: Tue, 14 Jul 2026 11:44:09 +0100 Subject: [PATCH 13/27] fixed error in 'get-angle-types' and changed "let" to "function". --- .../implement/1-get-angle-type.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 5beae94ed0..01c095b67d 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -36,17 +36,22 @@ function assertEquals(actualOutput, targetOutput) { const right = getAngleType(90); assertEquals(right, "Right angle"); -let getAngleType(angle) { +function getAngleType(angle) { if (angle > 0 && angle < 90) { - return "Acute angle";} + return "Acute angle"; + } if (angle === 90) { - return "Right angle";} + return "Right angle"; + } if (angle > 90 && angle < 180) { - return "Obtuse angle";} + return "Obtuse angle"; + } if (angle === 180) { - return "Straight angle";} + return "Straight angle"; + } if (angle > 180 && angle < 360) { - return "Reflex angle";} + return "Reflex angle"; + } return "Invalid angle"; } From 60638b4e3fe09813326a17d4eb7f43f99d3e4f7a Mon Sep 17 00:00:00 2001 From: JorvanW Date: Tue, 14 Jul 2026 11:53:52 +0100 Subject: [PATCH 14/27] wrote code for "is-proper-fraction" function and added test cases for it --- .../implement/2-is-proper-fraction.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 970cb9b641..d6d09fee24 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -31,3 +31,14 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); + +function isProperFraction(numerator, denominator) { + if (denominator === 0) { + return false; + } + if (numerator < denominator && numerator > 0) { + return true; + } + return false; +} +console.log(isProperFraction(2,3)); // true From 2ac2702daa278215ca72e65c69bdcd0bce0c7728 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Tue, 14 Jul 2026 13:54:39 +0100 Subject: [PATCH 15/27] Added code for 1-get-angle-type.test.js to include a test case for each angle type. --- .../implement/3-get-card-value.js | 1 + .../1-get-angle-type.test.js | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index ff5c532e1d..5dd4f90fdf 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -52,3 +52,4 @@ try { } // What other invalid card cases can you think of? + diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d777f348d3..0023552484 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -14,7 +14,36 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when (angle === 90)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(90)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles -// Case 4: Straight angle +test(`should return "Obtuse angle" when (90 < angle < 180)`, () => { + // Test various obtuse angles, including boundary cases + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(135)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); + +// Case 4: Straight angle +test(`should return "Straight angle" when (angle === 180)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 < angle < 360)`, () => { + // Test various reflex angles, including boundary cases + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(270)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => { + // Test various invalid angles + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); From f8cf7cf8d65d4085ea1e3227f2b6dd164c03d5f1 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Tue, 14 Jul 2026 14:00:07 +0100 Subject: [PATCH 16/27] added code to test 2-is-proper-fraction.test.js --- .../2-is-proper-fraction.test.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 7f087b2ba1..ea40fcd99a 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -8,3 +8,31 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +test(`should return false when numerator is zero`, () => { + expect(isProperFraction(0, 1)).toEqual(false); +}); + +test(`should return false when numerator is negative`, () => { + expect(isProperFraction(-1, 2)).toEqual(false); +}); + +test(`should return false when denominator is negative`, () => { + expect(isProperFraction(1, -2)).toEqual(false); +}); + +test(`should return false when both numerator and denominator are negative`, () => { + expect(isProperFraction(-1, -2)).toEqual(false); +}); + +test(`should return true when numerator is less than denominator`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +test(`should return false when numerator is equal to denominator`, () => { + expect(isProperFraction(2, 2)).toEqual(false); +}); + +test(`should return false when numerator is greater than denominator`, () => { + expect(isProperFraction(3, 2)).toEqual(false); +}); \ No newline at end of file From f3f69db6af839d59de792cae53a38bcda8bd8e6b Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 15 Jul 2026 11:36:47 +0100 Subject: [PATCH 17/27] Add count function and tests --- Sprint-3/2-practice-tdd/count.js | 8 +++++++- Sprint-3/2-practice-tdd/count.test.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d4..0cefa00ed4 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,11 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 + let count = 0 + for (const char of stringOfCharacters) { + if (char === findCharacter) { + count++ + } + } + return count } module.exports = countChar; diff --git a/Sprint-3/2-practice-tdd/count.test.js b/Sprint-3/2-practice-tdd/count.test.js index 179ea0ddf7..fd0c84400a 100644 --- a/Sprint-3/2-practice-tdd/count.test.js +++ b/Sprint-3/2-practice-tdd/count.test.js @@ -22,3 +22,17 @@ test("should count multiple occurrences of a character", () => { // And a character `char` that does not exist within `str`. // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of `char` were found. + +test("should return 0 when character is not found", () => { + const str = "hello"; + const char = "z"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); + +test("should return the number of occurrences of a character in a string with different characters", () => { + const str = "london"; + const char = "o"; + const count = countChar(str, char); + expect(count).toEqual(2); +}); \ No newline at end of file From f6f3d1d34204005cae5a7c04f6d86a110fe21668 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 15 Jul 2026 11:40:35 +0100 Subject: [PATCH 18/27] Remove CLI-Treasure-Hunt subproject from Sprint-2 --- Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt diff --git a/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt b/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt deleted file mode 160000 index 3e66462a26..0000000000 --- a/Sprint-2/CLI-Treasure-Hunt/Project-CLI-Treasure-Hunt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3e66462a26c1d68cc2ac562b0d3ad7b3c2210fa1 From 0bdef75513fb687c7f3186bd8ca0ef84097dd7cd Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 15 Jul 2026 12:32:12 +0100 Subject: [PATCH 19/27] Add functions and test for get-ordinal-number.js --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 8 +++++++- Sprint-3/2-practice-tdd/get-ordinal-number.test.js | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index f95d71db13..86eafbe4fb 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,5 +1,11 @@ function getOrdinalNumber(num) { - return "1st"; + if (num % 100 === 11) { + return num + "th"; + } else if (num % 10 === 1) { + return num + "st"; + } else { + return num + } } module.exports = getOrdinalNumber; diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js index adfa58560f..e760f8fa53 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -18,3 +18,10 @@ test("should append 'st' for numbers ending with 1, except those ending with 11" expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); + +// Case 2: Numbers ending with 11 +test("should append 'th' for numbers ending with 11", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(111)).toEqual("111th"); + expect(getOrdinalNumber(211)).toEqual("211th"); +}); \ No newline at end of file From 630c5021a71e17d23816b18845e3854a3862a7ab Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 15 Jul 2026 14:28:42 +0100 Subject: [PATCH 20/27] removed unnecessary code and simplified it in excersie-1.js --- Sprint-3/2-practice-tdd/repeat-str.js | 10 ++++++---- Sprint-3/2-practice-tdd/repeat-str.test.js | 9 +++++++++ Sprint-3/3-dead-code/exercise-1.js | 6 +----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 2af0a2cea7..a0ddedbb71 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,7 +1,9 @@ -function repeatStr() { - // Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat). - // The goal is to re-implement that function, not to use it. - return "hellohellohello"; +function repeatStr(str, times) { + if (times === 0) { + return ""; + } else if (times < 0) { + return "error"; + } } module.exports = repeatStr; diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index a3fc1196c4..56ddaa01a4 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -21,11 +21,20 @@ test("should repeat the string count times", () => { // When the repeatStr function is called with these inputs, // Then it should return the original `str` without repetition. +test("should return the original string when count is 1", () => { + const str = "world"; + const count = 1; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual("world"); +} + // Case: Handle count of 0: // Given a target string `str` and a `count` equal to 0, // When the repeatStr function is called with these inputs, // Then it should return an empty string. + + // Case: Handle negative count: // Given a target string `str` and a negative integer `count`, // When the repeatStr function is called with these inputs, diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..209fadc9b8 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,17 +1,13 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. -let testName = "Jerry"; +let testName = "Aman"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -testName = "Aman"; - const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!' From 55740a49003eeb07493467b8a7f8ac957ce9f597 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 15 Jul 2026 14:41:01 +0100 Subject: [PATCH 21/27] Removed dead code in exercise-2 --- Sprint-3/3-dead-code/exercise-2.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..b1c2362d34 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -2,13 +2,8 @@ // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; -const capitalisedPets = pets.map((pet) => pet.toUpperCase()); const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} - function countAndCapitalisePets(petsArr) { const petCount = {}; From 6994606decdf3831fca4fe405cde990218e6a0e4 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Fri, 17 Jul 2026 17:15:14 +0100 Subject: [PATCH 22/27] Added code for repeat-string .js --- Sprint-3/2-practice-tdd/repeat-str.js | 8 +++++++- Sprint-3/2-practice-tdd/repeat-str.test.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index a0ddedbb71..946a71c5bf 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -4,6 +4,12 @@ function repeatStr(str, times) { } else if (times < 0) { return "error"; } -} + + let repeatedString = ""; + for (let i = 0; i < times; i++) { + repeatedString += str; + } + return repeatedString; +} module.exports = repeatStr; diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index 56ddaa01a4..50c5f02f8f 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -26,7 +26,7 @@ test("should return the original string when count is 1", () => { const count = 1; const repeatedStr = repeatStr(str, count); expect(repeatedStr).toEqual("world"); -} +}); // Case: Handle count of 0: // Given a target string `str` and a `count` equal to 0, @@ -38,4 +38,4 @@ test("should return the original string when count is 1", () => { // Case: Handle negative count: // Given a target string `str` and a negative integer `count`, // When the repeatStr function is called with these inputs, -// Then it should throw an error, as negative counts are not valid. +// Then it should throw an error, as negative counts are not valid. \ No newline at end of file From e54bbd59aa2105f8523ae2bfc2adddf575679f38 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 22 Jul 2026 15:25:38 +0100 Subject: [PATCH 23/27] added code for 3-get-card-value.js --- .../implement/3-get-card-value.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index 5dd4f90fdf..6684090cc0 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -22,9 +22,31 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + const suit = card.slice(-1); + const rank = card.slice(0, -1); + + const validSuits = ["♠", "♥", "♦", "♣"]; + + if (!validSuits.includes(suit)) { + throw new Error("Invalid card"); + } + + if (rank === "A") { + return 11; + } + + if (["J", "Q", "K"].includes(rank)) { + return 10; + } + + if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(rank)) { + return Number(rank); + } + + throw new Error("Invalid card"); } + // The line below allows us to load the getCardValue function into tests in other files. // This will be useful in the "rewrite tests with jest" step. module.exports = getCardValue; From 9aaaa7eee04f317a74ebad9fc9bc297bbfe7c6e6 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 22 Jul 2026 16:05:22 +0100 Subject: [PATCH 24/27] added tests for 3-get-card-value.test.js --- .../3-get-card-value.test.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index cf7f9dae2e..c24a7f7d4f 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -10,10 +10,28 @@ test(`Should return 11 when given an ace card`, () => { }); // Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards +// Case 2 Number Cards (2-10) + test(`Should return the same number when given a number card of any suit`, () => { + expect(getCardValue("3♠")).toEqual(3); +}); + +// Case 3 Face Cards (J, Q, K) +test(`Should return 10 when given an any face card`, () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♥")).toEqual(10) + expect(getCardValue("K♦")).toEqual(10) +}); + +// Invalid Cards +// test(`Cards without suits return as Invalid card`, () => { +// expect(getCardValue("10")).toEqual(new Error); +// }); +test('Cards without suits return as Invalid card', () => { + expect(() => { + getCardValue("10"); + }).toThrow("Invalid card"); +}); // To learn how to test whether a function throws an error as expected in Jest, // please refer to the Jest documentation: // https://jestjs.io/docs/expect#tothrowerror From 7cacfb4f0c197d7e254a3eeb2bd542f0af842499 Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 22 Jul 2026 16:08:03 +0100 Subject: [PATCH 25/27] added notes for 3-get-card-value.js --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index 6684090cc0..1fa56059c9 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -74,4 +74,6 @@ try { } // What other invalid card cases can you think of? +// logging cards without suits to throw error + From a6131ab7b445f499f5d264af93366b38a9e7732b Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 22 Jul 2026 16:19:12 +0100 Subject: [PATCH 26/27] updated formatting errors in 1-get-angle-types and 2-is-proper-faction --- .../implement/1-get-angle-type.js | 39 ++++++++++--------- .../implement/2-is-proper-fraction.js | 7 ++-- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 01c095b67d..7e35feedc3 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -15,6 +15,26 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { + { + if (angle > 0 && angle < 90) { + return "Acute angle"; + } + if (angle === 90) { + return "Right angle"; + } + if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } + if (angle === 180) { + return "Straight angle"; + } + if (angle > 180 && angle < 360) { + return "Reflex angle"; + } + return "Invalid angle"; +} + + // TODO: Implement this function } @@ -36,22 +56,5 @@ function assertEquals(actualOutput, targetOutput) { const right = getAngleType(90); assertEquals(right, "Right angle"); -function getAngleType(angle) { - if (angle > 0 && angle < 90) { - return "Acute angle"; - } - if (angle === 90) { - return "Right angle"; - } - if (angle > 90 && angle < 180) { - return "Obtuse angle"; - } - if (angle === 180) { - return "Straight angle"; - } - if (angle > 180 && angle < 360) { - return "Reflex angle"; - } - return "Invalid angle"; -} + diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index d6d09fee24..93ce42cb8e 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -10,9 +10,6 @@ // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. -function isProperFraction(numerator, denominator) { - // TODO: Implement this function -} // The line below allows us to load the isProperFraction function into tests in other files. // This will be useful in the "rewrite tests with jest" step. @@ -42,3 +39,7 @@ function isProperFraction(numerator, denominator) { return false; } console.log(isProperFraction(2,3)); // true + + +module.exports = isProperFraction; + From a85a823f202567b6260e160ee895b43bce4db86c Mon Sep 17 00:00:00 2001 From: JorvanW Date: Wed, 22 Jul 2026 17:55:19 +0100 Subject: [PATCH 27/27] updated code and added tests for repeat.str --- Sprint-3/2-practice-tdd/repeat-str.js | 2 +- Sprint-3/2-practice-tdd/repeat-str.test.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 946a71c5bf..e13c465c15 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -2,7 +2,7 @@ function repeatStr(str, times) { if (times === 0) { return ""; } else if (times < 0) { - return "error"; + throw new Error("error"); } let repeatedString = ""; diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index 50c5f02f8f..08eb9e9ba3 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -33,9 +33,23 @@ test("should return the original string when count is 1", () => { // When the repeatStr function is called with these inputs, // Then it should return an empty string. - +test("should return an empty string when count is 0", () => { + const str = "world"; + const count = 0; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual(""); +}); // Case: Handle negative count: // Given a target string `str` and a negative integer `count`, // When the repeatStr function is called with these inputs, -// Then it should throw an error, as negative counts are not valid. \ No newline at end of file +// Then it should throw an error, as negative counts are not valid. + +test("should throw an error when count is negative", () => { + const str = "world"; + const count = -1; + + expect(() => { + repeatStr(str, count); + }).toThrow("error"); +});