From 8be0a945cb4d04b820f33afb0994f383af6bf484 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 19:37:46 +0100 Subject: [PATCH 01/70] i declared prediction --- Sprint-2/1-key-errors/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..2445d911f 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -10,4 +10,4 @@ function capitalise(str) { } // =============> write your explanation here -// =============> write your new code here +// =============> write your new code here \ No newline at end of file From 15b03d8264c7d8f3d5fd8e20b28b24b817166ecf Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 19:41:43 +0100 Subject: [PATCH 02/70] i declared percentage conversion --- Sprint-2/1-key-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..987186f20 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -17,4 +17,4 @@ console.log(decimalNumber); // =============> write your explanation here // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> write your new code here \ No newline at end of file From 021bf84cef6117ca3d15f2f07da19ea6c0cabae7 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:18:36 +0100 Subject: [PATCH 03/70] i fix error problems --- Sprint-2/1-key-errors/2.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..269ab8a3c 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -17,4 +17,3 @@ function square(3) { // =============> write your new code here - From 692c65499ea2a6e58d03a564bc679ef1d9301027 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:21:25 +0100 Subject: [PATCH 04/70] i predict --- Sprint-2/1-key-errors/2.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index 269ab8a3c..8db2f38ce 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -1,19 +1,14 @@ +// Predict and explain first... -// Predict and explain first BEFORE you run any code... +// =============> write your prediction here -// this function should square any number but instead we're going to get an error - -// =============> write your prediction of the error here - -function square(3) { - return num * num; +function multiply(a, b) { + console.log(a * b); } -// =============> write the error message here +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> explain this error message here +// =============> write your explanation here // Finally, correct the code to fix the problem - -// =============> write your new code here - +// =============> write your new code here \ No newline at end of file From c2d19c18204d1c1825fa146bac61dbaff9813480 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:24:27 +0100 Subject: [PATCH 05/70] sun of function --- Sprint-2/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..718468166 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -10,4 +10,4 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> write your new code here \ No newline at end of file From f5dab8918960b6827257a836e3b118b00f457d3b Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:27:40 +0100 Subject: [PATCH 06/70] i declared the prediction of an output --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..fdcc23862 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -21,4 +21,4 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // =============> write your new code here // 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 - correct the problem \ No newline at end of file From c75033d915d98eb060620605ab50c91ac30de850 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:32:33 +0100 Subject: [PATCH 07/70] i declared diffrent cases --- Sprint-2/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..9327e98c4 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -13,4 +13,4 @@ // 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 +// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase \ No newline at end of file From 8aeaa412eef98e2aa7b4c029c2c05882e4ed33ee Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:35:02 +0100 Subject: [PATCH 08/70] i declared program written --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..99ce20539 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -3,4 +3,4 @@ // You will need to take this code and turn it into a reusable block of code. // 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 +// You should call this function a number of times to check it works for different inputs \ No newline at end of file From 7008404cb7e5d986389cb15ace201ed59c865067 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 20:37:54 +0100 Subject: [PATCH 09/70] i declared former time display --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..f9b0d8570 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -31,4 +31,4 @@ function formatTimeDisplay(seconds) { // =============> write your answer here // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here \ No newline at end of file From 50d5fb45b18398c630e5aab58c8d755a8b058ba3 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 21:57:09 +0100 Subject: [PATCH 10/70] i declared calculation --- Sprint-2/3-mandatory-implement/1-bmi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..d2b705b55 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -6,7 +6,7 @@ // squaring your height: 1.73 x 1.73 = 2.99 // dividing 70 by 2.99 = 23.41 -// Your result will be displayed to 1 decimal place, for example 23.4. +// Your result will be displayed to 1 decimal place, for example 23.4 // You will need to implement a function that calculates the BMI of someone based off their weight and height @@ -15,5 +15,5 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height +// return the BMI of someone based off their weight and height } \ No newline at end of file From 01a09def84140c1c713f58bd73a1fcb304d3760e Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Thu, 25 Dec 2025 22:03:06 +0100 Subject: [PATCH 11/70] i declared cuurent output --- Sprint-2/5-stretch-extend/format-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b..2cfcba511 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -22,4 +22,4 @@ const targetOutput2 = "11:00 pm"; console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` -); +); \ No newline at end of file From 93981cafddaa56e1db26e6904b83bd835f968eb1 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 13:21:32 +0100 Subject: [PATCH 12/70] i declared string representing --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..16461f05e 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,4 +24,18 @@ console.log(`£${pounds}.${pence}`); // Try and describe the purpose / rationale behind each step // To begin, we can start with -// 1. const penceString = "399p": initialises a string variable with the value "399p" +// 1. const penceString = "399p": initialise a string variable with the value "399p" + +// 3. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length -1); +// cleaning the trailing P character. it uses the string´s length minus 1 as the end index for substring(), this leave only the numeric value while drop the last character. + +// 8. const paddedPenceNumberString = penceStringWithoutTrailingP.padStar(3, "0"); Padding- ensure the numeric string is at least three characters long by prepending zeros. +// this is important for separating pounds from pence especially when values is less than 100p + +// 9. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); Extracting pounds component, this uses substring() +// to take all character from the start (index 0) up to, but not including the last two characters, they are always pence. + +// 14. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); Extracting and formatting price- +// Extracts the pence component (the last two digits) and ensures they are always two digits long by padding the end with a zero if needed (though not needed for "99"). + +// 18. console.log(\£${pounds}.${pence}`);` Output: Format the extracted components into the standard currency display £3.99. \ No newline at end of file From 42bd4f41db0197d00af0865f753358ad8df69860 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 14:38:26 +0100 Subject: [PATCH 13/70] i declared functions --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index f9b0d8570..600040bfc 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -11,7 +11,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } -// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit +// You will need to play computer with this example - use the Python Visualizer https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions // Questions From 5b14359cd8293535908ca82f00342da473fe15e4 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:29:52 +0100 Subject: [PATCH 14/70] i declared variable --- Sprint-1/1-key-exercises/1-count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..b8580c502 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -3,4 +3,4 @@ let count = 0; 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 +// Describe what line 3 is doing, in particular focus on what = is doing \ No newline at end of file From 6b1e71e15ee8c769b06cecfc245db5667c13532e Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:32:16 +0100 Subject: [PATCH 15/70] i declared initails --- Sprint-1/1-key-exercises/2-initials.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..673e79791 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -8,4 +8,3 @@ let lastName = "Johnson"; let initials = ``; // https://www.google.com/search?q=get+first+character+of+string+mdn - From 5f7e836bc1536bcaa25119f0146d491e6cdc50d6 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:40:47 +0100 Subject: [PATCH 16/70] i declared filepath variable --- Sprint-1/1-key-exercises/3-paths.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..3dff4769d 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -15,9 +15,13 @@ const base = filePath.slice(lastSlashIndex + 1); console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable +const dir = filePath.slice(0, lastSlashIndex); + // Create a variable to store the ext part of the variable +const extIndex = base.lastIndexOf("."); +const ext = base.slice(extIndex + 1); -const dir = ; -const ext = ; +console.log(`The directory part is ${dir}`); +console.log(`The extension part is ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From ce69949c18e1dadafd1e39215627fed4367ebb85 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:42:50 +0100 Subject: [PATCH 17/70] i declared math.floor --- Sprint-1/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..91406cd27 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -6,4 +6,4 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // In this exercise, you will need to work out what num represents? // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated -// Try logging the value of num and running the program several times to build an idea of what the program is doing +// Try logging the value of num and running the program several times to build an idea of what the program is doing \ No newline at end of file From 33872c103d1482ddfce6c788d9b7e999a2d31b14 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:46:09 +0100 Subject: [PATCH 18/70] i declared how to solve problem --- Sprint-1/2-mandatory-errors/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..69da8d68a 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,2 @@ This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file From 853223864a08122b1f7acd058a2145657c96643b Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:47:34 +0100 Subject: [PATCH 19/70] i declared variable creation --- Sprint-1/2-mandatory-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..43dac0020 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,4 @@ // trying to create an age variable and then reassign the value by 1 const age = 33; -age = age + 1; +age = age + 1; \ No newline at end of file From 0878a26ea63680d0db5c5a3eb754514c9c9fbfa5 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:49:42 +0100 Subject: [PATCH 20/70] i declared error --- Sprint-1/2-mandatory-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..b446a4233 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -2,4 +2,4 @@ // what's the error ? console.log(`I was born in ${cityOfBirth}`); -const cityOfBirth = "Bolton"; +const cityOfBirth = "Bolton"; \ No newline at end of file From 63331ef1a9e044633562c1026b0864a913fbfd05 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:50:54 +0100 Subject: [PATCH 21/70] i declared updating expression --- Sprint-1/2-mandatory-errors/3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..2278c96a9 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -6,4 +6,4 @@ const last4Digits = cardNumber.slice(-4); // Before running the code, make and explain a prediction about why the code won't work // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? -// Then try updating the expression last4Digits is assigned to, in order to get the correct value +// Then try updating the expression last4Digits is assigned to, in order to get the correct value \ No newline at end of file From a33708d1d3258d2ebe3e0d8aac72bc99eadbbbfe Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:54:07 +0100 Subject: [PATCH 22/70] i declared the clocktime --- Sprint-1/2-mandatory-errors/4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..683baac4f 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,2 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const hour12ClockTime = "20:53"; // Changed to start with a letter +const hour24ClockTime = "08:53"; // Also changed for consistency From 77cbd879ff8d04653711e6f91346773e0f23e2a9 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 16:57:39 +0100 Subject: [PATCH 23/70] i declared instruction --- .../1-percentage-change.js | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..76f30b5bc 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -1,22 +1,2 @@ -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; - -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); - -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; - -console.log(`The percentage change is ${percentageChange}`); - -// Read the code and then answer the questions below - -// a) How many function calls are there in this file? Write down all the lines where a function call is made - -// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? - -// c) Identify all the lines that are variable reassignment statements - -// d) Identify all the lines that are variable declarations - -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// This is just an instruction for the first activity - but it is just for human consumption +// We don't want the computer to run these 2 lines From 48d2bd7772d4b6ce4ee1255d87544b962945638d Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:00:39 +0100 Subject: [PATCH 24/70] i declared variable first --- .../3-mandatory-interpret/2-time-format.js | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..29dce0016 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,25 +1,2 @@ -const movieLength = 8784; // length of movie in seconds - -const remainingSeconds = movieLength % 60; -const totalMinutes = (movieLength - remainingSeconds) / 60; - -const remainingMinutes = totalMinutes % 60; -const totalHours = (totalMinutes - remainingMinutes) / 60; - -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; -console.log(result); - -// For the piece of code above, read the code and then answer the following questions - -// a) How many variable declarations are there in this program? - -// b) How many function calls are there? - -// c) Using documentation, explain what the expression movieLength % 60 represents -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators - -// d) Interpret line 4, what does the expression assigned to totalMinutes mean? - -// e) What do you think the variable result represents? Can you think of a better name for this variable? - -// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +const cityOfBirth = "Bolton"; // Declare the variable first +console.log(`I was born in ${cityOfBirth}`); // Now you can use it From d4695a24b010ffa3cdb570116aa6684c632bf13b Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:04:48 +0100 Subject: [PATCH 25/70] i declared working on errors --- Sprint-1/3-mandatory-interpret/2-time-format.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 29dce0016..b446a4233 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,2 +1,5 @@ -const cityOfBirth = "Bolton"; // Declare the variable first -console.log(`I was born in ${cityOfBirth}`); // Now you can use it +// Currently trying to print the string "I was born in Bolton" but it isn't working... +// what's the error ? + +console.log(`I was born in ${cityOfBirth}`); +const cityOfBirth = "Bolton"; \ No newline at end of file From 82849572761921d45a864497d905cfb57cc830de Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:06:59 +0100 Subject: [PATCH 26/70] i declared first activity --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 76f30b5bc..32ea7fc1b 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -1,2 +1,2 @@ // This is just an instruction for the first activity - but it is just for human consumption -// We don't want the computer to run these 2 lines +// We don't want the computer to run these 2 lines \ No newline at end of file From a3df74406f562eca5c7743083718e8099754ebf2 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:09:01 +0100 Subject: [PATCH 27/70] i declared totalminutes --- .../3-mandatory-interpret/2-time-format.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index b446a4233..85efdba75 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,5 +1,25 @@ -// Currently trying to print the string "I was born in Bolton" but it isn't working... -// what's the error ? +const movieLength = 8784; // length of movie in seconds -console.log(`I was born in ${cityOfBirth}`); -const cityOfBirth = "Bolton"; \ No newline at end of file +const remainingSeconds = movieLength % 60; +const totalMinutes = (movieLength - remainingSeconds) / 60; + +const remainingMinutes = totalMinutes % 60; +const totalHours = (totalMinutes - remainingMinutes) / 60; + +const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; +console.log(result); + +// For the piece of code above, read the code and then answer the following questions + +// a) How many variable declarations are there in this program? + +// b) How many function calls are there? + +// c) Using documentation, explain what the expression movieLength % 60 represents +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators + +// d) Interpret line 4, what does the expression assigned to totalMinutes mean? + +// e) What do you think the variable result represents? Can you think of a better name for this variable? + +// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer \ No newline at end of file From 3e611190a324e08c9049e69781dd1e3fb7c553e7 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:11:22 +0100 Subject: [PATCH 28/70] i declared initialize string --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 16461f05e..43b8f6448 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,7 +24,7 @@ console.log(`£${pounds}.${pence}`); // Try and describe the purpose / rationale behind each step // To begin, we can start with -// 1. const penceString = "399p": initialise a string variable with the value "399p" +// 1. const penceString = "399p": initialize a string variable with the value "399p" // 3. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length -1); // cleaning the trailing P character. it uses the string´s length minus 1 as the end index for substring(), this leave only the numeric value while drop the last character. From ee5c6d91ffc014c2112c58f1c5158e63dcaa312c Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:13:01 +0100 Subject: [PATCH 29/70] i declared function alert --- Sprint-1/4-stretch-explore/chrome.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..b0682aecd 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -15,4 +15,4 @@ What effect does calling the `alert` function have? Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? -What is the return value of `prompt`? +What is the return value of `prompt`? \ No newline at end of file From 7820bd067ebd407fdb509a1057f0ab6ad181bbb2 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Fri, 26 Dec 2025 17:19:11 +0100 Subject: [PATCH 30/70] i declared consolelog --- Sprint-1/4-stretch-explore/objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..c0f324774 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -13,4 +13,4 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? \ No newline at end of file From 7739b5d3f9d2b0aeb906fe6aeac3fc54ccb59c69 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 14:48:24 +0100 Subject: [PATCH 31/70] I implemented the function of getAngleTypes and run test case by case --- Sprint-3/1-key-implement/1-get-angle-type.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 08d1f0cba..861e3f248 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -8,8 +8,8 @@ // Then, write the next test! :) Go through this process until all the cases are implemented function getAngleType(angle) { - if (angle === 90) return "Right angle"; - // read to the end, complete line 36, then pass your test here +if (angle === 90) return "Right angle"; +// read to the end, complete line 36, then pass your test here } // we're going to use this helper function to make our assertions easier to read From 8afb4a94b9aa30cec12414f88e498ea274ba8621 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 14:53:12 +0100 Subject: [PATCH 32/70] I implemented isProperFraction --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 91583e941..99fa81e58 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -51,3 +51,4 @@ const equalFraction = isProperFraction(3, 3); // Stretch: // What other scenarios could you test for? + From 0a80e2c8519e383c6b8b49e4b0cfdaa91904e217 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 14:56:44 +0100 Subject: [PATCH 33/70] I implemented getCardValue --- Sprint-3/1-key-implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index aa1cc9f90..58151b745 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -49,3 +49,4 @@ const fiveofHearts = getCardValue("5♥"); // Given a card with an invalid rank (neither a number nor a recognized face card), // When the function is called with such a card, // Then it should throw an error indicating "Invalid card rank." + From 01d1107873da32fcf102cefbf900baba7aa4ca8f Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:10:53 +0100 Subject: [PATCH 34/70] I provided a function on getAngleType --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js index d61254bd7..f4bc1f9ac 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js @@ -15,4 +15,4 @@ function getAngleType(angle) { // Jest uses CommonJS module syntax by default as it's quite old // We will upgrade our approach to ES6 modules in the next course module, so for now // we have just written the CommonJS module.exports syntax for you -module.exports = getAngleType; \ No newline at end of file +module.exports = getAngleType; From b8c9082445e25a557b43299a5fe2e024151f0f13 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:13:15 +0100 Subject: [PATCH 35/70] I provided a getAngleType when required --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index b62827b7c..f2f1d8e8e 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -22,3 +22,5 @@ test("should identify right angle (90°)", () => { // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" + + From 787ef526a4f239c1b719a0d029dd8e1c3cae8c2f Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:17:40 +0100 Subject: [PATCH 36/70] I provided a getAngleTypetest --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index f2f1d8e8e..7a20c0e34 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -24,3 +24,4 @@ test("should identify right angle (90°)", () => { // Then the function should return "Reflex angle" + From 51dc2de5fa4b99f8cf5c72630a4ffdffe4b255ce Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:19:11 +0100 Subject: [PATCH 37/70] I generated isProperFraction --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js index 9836fe398..89d4bf903 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js @@ -3,4 +3,4 @@ function isProperFraction(numerator, denominator) { // add your completed function from key-implement here } -module.exports = isProperFraction; \ No newline at end of file +module.exports = isProperFraction; From 30083f4baa8d1d563ed5a78f399e9a00bdd82f35 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:21:03 +0100 Subject: [PATCH 38/70] I provided a required isProperFraction --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index ff1cc8173..e33daa3c9 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -9,3 +9,4 @@ test("should return true for a proper fraction", () => { // Case 3: Identify Negative Fractions: // Case 4: Identify Equal Numerator and Denominator: + From 45f285cffc643888a73f756b3a49e885f40d93e8 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:22:32 +0100 Subject: [PATCH 39/70] I generated a getCardValue --- Sprint-3/2-mandatory-rewrite/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js index 0d95d3736..328773567 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js @@ -2,4 +2,4 @@ function getCardValue(card) { // replace with your code from key-implement return 11; } -module.exports = getCardValue; \ No newline at end of file +module.exports = getCardValue; From 8b93a1d9849f61c6ed5c03327008a09589727a14 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:23:50 +0100 Subject: [PATCH 40/70] I provided a required getCardValue --- Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 03a8e2f34..9f8e6d332 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -9,3 +9,4 @@ test("should return 11 for Ace of Spades", () => { // Case 3: Handle Face Cards (J, Q, K): // Case 4: Handle Ace (A): // Case 5: Handle Invalid Cards: + From 743af28381436172adb80b0b2aae6e13422ad766 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:29:07 +0100 Subject: [PATCH 41/70] I provided a countcharater --- Sprint-3/3-mandatory-practice/implement/count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/count.js b/Sprint-3/3-mandatory-practice/implement/count.js index fce249650..fefebd4ea 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.js +++ b/Sprint-3/3-mandatory-practice/implement/count.js @@ -2,4 +2,4 @@ function countChar(stringOfCharacters, findCharacter) { return 5 } -module.exports = countChar; \ No newline at end of file +module.exports = countChar; From ce3b1a6c7017d34dd2ec6e29ff7cf6dc6e1c20fe Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:30:42 +0100 Subject: [PATCH 42/70] I provided a required countchar --- Sprint-3/3-mandatory-practice/implement/count.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/3-mandatory-practice/implement/count.test.js b/Sprint-3/3-mandatory-practice/implement/count.test.js index 42baf4b4b..943bbf027 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.test.js +++ b/Sprint-3/3-mandatory-practice/implement/count.test.js @@ -22,3 +22,4 @@ test("should count multiple occurrences of a character", () => { // And a character char that does not exist within the case-sensitive str, // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. + From 4109e2ee37dead499462c826c7dbde9776262338 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:32:15 +0100 Subject: [PATCH 43/70] I provided a getOrdinalNumber --- Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 24f528b0d..2aa3e8e93 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -2,4 +2,4 @@ function getOrdinalNumber(num) { return "1st"; } -module.exports = getOrdinalNumber; \ No newline at end of file +module.exports = getOrdinalNumber; From ea53d0aee9faa42fa2f6fee81fd8c2defda4d414 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:33:46 +0100 Subject: [PATCH 44/70] I provided a required getOrdinalNumber --- .../3-mandatory-practice/implement/get-ordinal-number.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 6d55dfbb4..8a23ca998 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -11,3 +11,4 @@ const getOrdinalNumber = require("./get-ordinal-number"); test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); + From f4a3d6d19a0d2d014ecfde5a1f0376c2e49752c1 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:35:34 +0100 Subject: [PATCH 45/70] I repeat a function --- Sprint-3/3-mandatory-practice/implement/repeat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.js b/Sprint-3/3-mandatory-practice/implement/repeat.js index 621f9bd35..ae0379e1d 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.js @@ -2,4 +2,4 @@ function repeat() { return "hellohellohello"; } -module.exports = repeat; \ No newline at end of file +module.exports = repeat; From 0a7170fa528fd49bd2b60bf183bbb70d8211445d Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:36:44 +0100 Subject: [PATCH 46/70] i repeated a test function --- Sprint-3/3-mandatory-practice/implement/repeat.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.test.js b/Sprint-3/3-mandatory-practice/implement/repeat.test.js index 8a4ab42ef..9da127be0 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.test.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.test.js @@ -30,3 +30,4 @@ test("should repeat the string count times", () => { // Given a target string str and a negative integer count, // When the repeat function is called with these inputs, // Then it should throw an error or return an appropriate error message, as negative counts are not valid. + From 482d66c8ccbb17a25e35a7de067dcbec70815c67 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:38:06 +0100 Subject: [PATCH 47/70] I provided a credit card --- Sprint-3/4-stretch-investigate/card-validator.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/4-stretch-investigate/card-validator.md b/Sprint-3/4-stretch-investigate/card-validator.md index e39c6ace6..2b265c977 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.md +++ b/Sprint-3/4-stretch-investigate/card-validator.md @@ -33,3 +33,4 @@ These are the requirements your project needs to fulfill: - Return a boolean from the function to indicate whether the credit card number is valid. Good luck! + From f6f2fa4dee74835b9fabd67f48a59fbe5ea738b9 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:39:45 +0100 Subject: [PATCH 48/70] I find a function --- Sprint-3/4-stretch-investigate/find.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/4-stretch-investigate/find.js b/Sprint-3/4-stretch-investigate/find.js index c7e79a2f2..dcc3e6bea 100644 --- a/Sprint-3/4-stretch-investigate/find.js +++ b/Sprint-3/4-stretch-investigate/find.js @@ -23,3 +23,4 @@ console.log(find("code your future", "z")); // b) What is the if statement used to check // c) Why is index++ being used? // d) What is the condition index < str.length used for? + From 940de781f9cfd2d2062dd10073a400d47df7fc82 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:41:07 +0100 Subject: [PATCH 49/70] I provided a passwordvalidator --- Sprint-3/4-stretch-investigate/password-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index b55d527db..12dd1accf 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -3,4 +3,4 @@ function passwordValidator(password) { } -module.exports = passwordValidator; \ No newline at end of file +module.exports = passwordValidator; From 1a5ffff3194f0d34caea21feb9f4ec0d8f341762 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Sat, 10 Jan 2026 15:57:55 +0100 Subject: [PATCH 50/70] I provided password validation --- Sprint-3/4-stretch-investigate/password-validator.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 8fa3089d6..5909192b6 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -23,4 +23,4 @@ test("password has at least 5 characters", () => { // Assert expect(result).toEqual(true); } -); \ No newline at end of file +); From 50f77c00071324daaa2eaeef0e1fcbabe920348b Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:03:18 +0100 Subject: [PATCH 51/70] I implemented the function getAngletype --- Sprint-3/1-key-implement/1-get-angle-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 861e3f248..388573697 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -53,4 +53,4 @@ const obtuse = getAngleType(120); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" -// ====> write your test here, and then add a line to pass the test in the function above \ No newline at end of file +// ====> write your test here, and then add a line to pass the test in the function above From bd998225990ca28a61b9234a6f67bdeb56757bf2 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:08:52 +0100 Subject: [PATCH 52/70] I implemented a proper fraction --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 99fa81e58..0ec3272df 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -52,3 +52,4 @@ const equalFraction = isProperFraction(3, 3); // Stretch: // What other scenarios could you test for? + From 9345de9d2adb5c1192587763ee730fd7b9daf5ce Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:10:47 +0100 Subject: [PATCH 53/70] I implemented getCardValue --- Sprint-3/1-key-implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index 58151b745..fb70af0b9 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -50,3 +50,4 @@ const fiveofHearts = getCardValue("5♥"); // When the function is called with such a card, // Then it should throw an error indicating "Invalid card rank." + From 3ea6dbaafb62b4f16dfeda6c901500882e43edbd Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:24:35 +0100 Subject: [PATCH 54/70] implementing function of return --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js index f4bc1f9ac..18485e410 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js @@ -6,13 +6,9 @@ function getAngleType(angle) { - - - - - // Don't get bogged down in this detail // Jest uses CommonJS module syntax by default as it's quite old // We will upgrade our approach to ES6 modules in the next course module, so for now // we have just written the CommonJS module.exports syntax for you module.exports = getAngleType; + From 01a58603d19cdb79d8f88dea279277231cc48124 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:27:14 +0100 Subject: [PATCH 55/70] implementing getAngleType --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js index 18485e410..d6db07a95 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js @@ -1,5 +1,17 @@ function getAngleType(angle) { if (angle === 90) return "Right angle"; + if (angle < 90) return "Acute angle"; + if (angle > 90 && angle < 180) return "Obtuse angle"; + if (angle === 180) return "Straight angle"; + if (angle > 180 && angle < 360) return "Reflex angle"; +} + + +// Don't get bogged down in this detail +// Jest uses Common JS module syntax by default as it's quite old +// We will upgrade our approach to ES6 modules in the next course module, so for now +// we have just written the CommonJS module.exports syntax for you +module.exports = getAngleType; // replace with your completed function from key-implement } From 2d879fac67395b25042d28e8ecdec50c052a4ff3 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:30:46 +0100 Subject: [PATCH 56/70] identifying reflex angle --- .../2-mandatory-rewrite/1-get-angle-type.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index 7a20c0e34..61335b5b2 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -10,18 +10,33 @@ test("should identify right angle (90°)", () => { // Case 2: Identify Acute Angles: // When the angle is less than 90 degrees, // Then the function should return "Acute angle" +test("should identify acute angle (<90°)", () => { + expect(getAngleType(45)).toEqual("Acute angle"); +}); + // Case 3: Identify Obtuse Angles: // When the angle is greater than 90 degrees and less than 180 degrees, // Then the function should return "Obtuse angle" +test("should identify obtuse angle (>90° and <180°)", () => { + expect(getAngleType(120)).toEqual("Obtuse angle"); +}); // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, // Then the function should return "Straight angle" +test("should identify straight angle (180°)", () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" +test("should identify reflex angle (>180° and <360°)", () => { + expect(getAngleType(270)).toEqual("Reflex angle"); +}); + + From 8ac608d30dc17b9777391a03235fc99c166d4b02 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:36:28 +0100 Subject: [PATCH 57/70] implementing ProperFraction --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js index 89d4bf903..46ddce752 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js @@ -1,6 +1,11 @@ function isProperFraction(numerator, denominator) { if (numerator < denominator) return true; // add your completed function from key-implement here + if (numerator > denominator) return false; + if (numerator <= 0 || denominator <= 0) return false; + if (numerator === denominator) return false; + return false; + } module.exports = isProperFraction; From 6cb0939826feafc4157fda4ba8d273d46945f20c Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:38:33 +0100 Subject: [PATCH 58/70] identifying negative fraction --- .../2-is-proper-fraction.test.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index e33daa3c9..64aa001c4 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -4,9 +4,20 @@ test("should return true for a proper fraction", () => { expect(isProperFraction(2, 3)).toEqual(true); }); -// Case 2: Identify Improper Fractions: +// Case 2: Identify Improper Fractions: +test("should return false for an improper fraction", () => { + expect(isProperFraction(5, 4)).toEqual(false); +}); + + // Case 3: Identify Negative Fractions: +test("should return false for a negative fraction", () => { + expect(isProperFraction(-2, 3)).toEqual(true); +}); -// Case 4: Identify Equal Numerator and Denominator: +// Case 4: Identify Equal Numerator and Denominator: +test("should return false when numerator equals denominator", () => { + expect(isProperFraction(4, 4)).toEqual(false); +}); \ No newline at end of file From fad0f12e1aeeee59c1f52acebcb80a26f35764f4 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:41:17 +0100 Subject: [PATCH 59/70] identifying equal number --- .../2-mandatory-rewrite/3-get-card-value.js | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js index 328773567..d9647ff2a 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js @@ -1,5 +1,23 @@ -function getCardValue(card) { - // replace with your code from key-implement - return 11; -} -module.exports = getCardValue; +const isProperFraction = require("./2-is-proper-fraction"); + +test("should return true for a proper fraction", () => { + expect(isProperFraction(2, 3)).toEqual(true); +}); + +// Case 2: Identify Improper Fractions: +test("should return false for an improper fraction", () => { + expect(isProperFraction(5, 4)).toEqual(false); +}); + + + +// Case 3: Identify Negative Fractions: +test("should return false for a negative fraction", () => { + expect(isProperFraction(-2, 3)).toEqual(true); +}); + + +// Case 4: Identify Equal Numerator and Denominator: +test("should return false when numerator equals denominator", () => { + expect(isProperFraction(4, 4)).toEqual(false); +}); From 58bca4e36c213ea85bcb9ea0fc1a1c376c600c1f Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:42:58 +0100 Subject: [PATCH 60/70] handling invalid cards --- .../3-get-card-value.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 9f8e6d332..7f1d382e0 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -6,7 +6,24 @@ test("should return 11 for Ace of Spades", () => { }); // Case 2: Handle Number Cards (2-10): +test("should return 7 for Seven of Hearts", () => { + const sevenOfHearts = getCardValue("7♥"); + expect(sevenOfHearts).toEqual(7); + }); // Case 3: Handle Face Cards (J, Q, K): +test("should return 10 for King of Diamonds", () => { + const kingOfDiamonds = getCardValue("K♦"); + expect(kingOfDiamonds).toEqual(10); + }); // Case 4: Handle Ace (A): -// Case 5: Handle Invalid Cards: +test("should return 11 for Ace of Clubs", () => { + const aceOfClubs = getCardValue("A♣"); + expect(aceOfClubs).toEqual(11); + }); +// Case 5: Handle Invalid Cards: +test("should throw an error for invalid card rank", () => { + expect(() => { + getCardValue("1♠"); + }).toThrow("Invalid card rank."); + }); \ No newline at end of file From 8be9a146c802c7be40a086f8d53123b61545b739 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:45:05 +0100 Subject: [PATCH 61/70] implement findCharacter --- .../3-mandatory-practice/implement/count.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/count.js b/Sprint-3/3-mandatory-practice/implement/count.js index fefebd4ea..b65bca97f 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.js +++ b/Sprint-3/3-mandatory-practice/implement/count.js @@ -1,5 +1,22 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 -} + let count = 0; + let arrOfChars = stringOfCharacters.split(""); + console.log(arrOfChars) -module.exports = countChar; + arrOfChars.forEach(char => { + if (char === findCharacter) count++ + + }) + + return count; + + + }; + + + console.log( + countChar("abcdefg", "c")); + + + +module.exports = countChar; \ No newline at end of file From c895483390578514d82b5631c22253cf6d965dd9 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:47:34 +0100 Subject: [PATCH 62/70] I implement countChar --- .../3-mandatory-practice/implement/count.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/count.test.js b/Sprint-3/3-mandatory-practice/implement/count.test.js index 943bbf027..78ddb840f 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.test.js +++ b/Sprint-3/3-mandatory-practice/implement/count.test.js @@ -17,9 +17,24 @@ test("should count multiple occurrences of a character", () => { expect(count).toEqual(5); }); + + + // Scenario: No Occurrences // Given the input string str, // And a character char that does not exist within the case-sensitive str, // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. +test("should return 0 when character does not exist in string", () => { + const str = "Joseph"; + const char = "z"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); + + +module.exports = countChar; + + + From 466cf0d0d41fb862da916741ddbafa3b50f1921a Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:48:59 +0100 Subject: [PATCH 63/70] identifying module exports --- .../implement/get-ordinal-number.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 2aa3e8e93..980adbcf5 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -1,5 +1,17 @@ function getOrdinalNumber(num) { - return "1st"; + const j = num % 10; + const k = num % 100; + if (j === 1 && k !== 11) { + return num + "st"; + } + if (j === 2 && k !== 12) { + return num + "nd"; + } + if (j === 3 && k !== 13) { + return num + "rd"; + } + return num + "th"; } module.exports = getOrdinalNumber; + From bc4333f5c40e44e3df09d6cdfa26244d7fbd54bd Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:52:08 +0100 Subject: [PATCH 64/70] implementing getOrdinalNumber --- .../implement/get-ordinal-number.test.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 8a23ca998..a4056202a 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -11,4 +11,22 @@ const getOrdinalNumber = require("./get-ordinal-number"); test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); - + +test("should return '2nd' for 2", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); + }); + +test("should return '3rd' for 3", () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); +}); + +test("should return '11th', '12th', and '13th' for teens", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); +}); + +test("should return '21st' for 21", () => { + expect(getOrdinalNumber(21)).toEqual("21st"); +}); + From 9993c58f6ccbd0450245d70929f5a734e67835c1 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:56:21 +0100 Subject: [PATCH 65/70] implement function repeat --- Sprint-3/3-mandatory-practice/implement/repeat.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.js b/Sprint-3/3-mandatory-practice/implement/repeat.js index ae0379e1d..1a563ba1a 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.js @@ -1,5 +1,12 @@ -function repeat() { - return "hellohellohello"; +function repeat(str, count) { + if (count < 0) throw new Error("Count must be non-negative"); + + let result = ""; + for (let i = 0; i < count; i++) { + result += str; + } + return result; } module.exports = repeat; + From b3e710631425512458ad1d9e7e040bcd77990c99 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 20:59:00 +0100 Subject: [PATCH 66/70] implementing negative count --- .../3-mandatory-practice/implement/repeat.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.test.js b/Sprint-3/3-mandatory-practice/implement/repeat.test.js index 9da127be0..4bfaefa19 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.test.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.test.js @@ -21,13 +21,28 @@ test("should repeat the string count times", () => { // When the repeat function is called with these inputs, // Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition. +test("should return the original string when count is 1", () => { + expect(repeat("hello", 1)).toEqual("hello"); +}); + + // case: Handle Count of 0: // Given a target string str and a count equal to 0, // When the repeat function is called with these inputs, // Then it should return an empty string, ensuring that a count of 0 results in an empty output. +test("should return an empty string when count is 0", () => { + expect(repeat("hello", 0)).toEqual(""); +}); + // case: Negative Count: // Given a target string str and a negative integer count, // When the repeat function is called with these inputs, // Then it should throw an error or return an appropriate error message, as negative counts are not valid. +test("should throw an error when count is negative", () => { + expect(() => repeat("hello", -1)).toThrow("Count must be non-negative"); +}); + + + From 5f9fbe55564148ab63a2fc65558d8a3a8904003a Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 21:01:27 +0100 Subject: [PATCH 67/70] implementing find function --- Sprint-3/4-stretch-investigate/find.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-3/4-stretch-investigate/find.js b/Sprint-3/4-stretch-investigate/find.js index dcc3e6bea..9aa1242b9 100644 --- a/Sprint-3/4-stretch-investigate/find.js +++ b/Sprint-3/4-stretch-investigate/find.js @@ -10,9 +10,12 @@ function find(str, char) { return -1; } + console.log(find("code your future", "u")); console.log(find("code your future", "z")); + + // The while loop statement allows us to do iteration - the repetition of a certain number of tasks according to some condition // See the docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while @@ -20,7 +23,18 @@ console.log(find("code your future", "z")); // Pay particular attention to the following: // a) How the index variable updates during the call to find +//// The index variable starts at 0 (the beginning of the string). After every unsuccessful check in the if statement, index++ adds 1 to the value. +// This allows the function to move sequentially from left to right through the string (0, 1, 2, 3...). + // b) What is the if statement used to check +//The if statement checks for equality. It looks at the character currently stored at str[index] and compares it to the char argument. +// If they are an exact match, the function stops immediately and returns the current position. + // c) Why is index++ being used? + //This is the "iterator." Without index++, the loop would be stuck on index 0 forever because the condition index < str.length would always stay true. +// This would cause an infinite loop, likely crashing your browser or terminal. + // d) What is the condition index < str.length used for? +// This is the boundary condition. It ensures the loop only runs while there are still characters left to check. +// Once index reaches the length of the string, it means we have checked every character and should stop to avoid looking for "ghost" characters that don't exist. From f7e50ace83683f9be893d6b94328b1d909068114 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 21:03:19 +0100 Subject: [PATCH 68/70] implementing password --- Sprint-3/4-stretch-investigate/password-validator.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index 12dd1accf..cb7381e2f 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -2,5 +2,16 @@ function passwordValidator(password) { return password.length < 5 ? false : true } +function isValidPassword(password, previousPasswords = []) { + if (password.length < 5) return false; + if (!/[A-Z]/.test(password)) return false; + if (!/[a-z]/.test(password)) return false; + if (!/[0-9]/.test(password)) return false; + if (!/[^A-Za-z0-9]/.test(password)) return false; + if (previousPasswords.includes(password)) return false; + return true; +} + module.exports = passwordValidator; + From b5a1347c19a0185b572cbe17a77f9e17f35553b2 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 21:05:07 +0100 Subject: [PATCH 69/70] implement ValidPassword --- .../password-validator.test.js | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 5909192b6..3108b3473 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -14,13 +14,65 @@ To be valid, a password must: You must breakdown this problem in order to solve it. Find one test case first and get that working */ + const isValidPassword = require("./password-validator"); test("password has at least 5 characters", () => { - // Arrange const password = "12345"; - // Act const result = isValidPassword(password); - // Assert expect(result).toEqual(true); } ); + +test("password has at least one uppercase letter", () => { + const password = "abcD1!"; + const result = isValidPassword(password); + expect(result).toEqual(true); +} +); + +test("password has at least one lowercase letter", () => { + const password = "ABCd1!"; + const result = isValidPassword(password); + expect(result).toEqual(true); +} +); + +test("password has at least one number", () => { + const password = "Abcde!2"; + const result = isValidPassword(password); + expect(result).toEqual(true); +} +); + +test("password has at least one non-alphanumeric symbol", () => { + const password = "Abcde1"; + const result = isValidPassword(password); + expect(result).toEqual(true); +} +); + +test("password is not in the previous passwords array", () => { + const password = "Password1!"; + const previousPasswords = ["Password1!", "Password2@", "Password3#"]; + const result = isValidPassword(password, previousPasswords); + expect(result).toEqual(true); +} +); + +test("valid password meets all criteria", () => { + const password = "Valid1!"; + const previousPasswords = ["Password1!", "Password2@", "Password3#"]; + const result = isValidPassword(password, previousPasswords); + expect(result).toEqual(true); +} +); +test("invalid password fails multiple criteria", () => { + const password = "inv"; + const previousPasswords = ["inv", "Password2@", "Password3#"]; + const result = isValidPassword(password, previousPasswords); + expect(result).toEqual(false); +} +); + + + From 333404bd23ff57cd11213361900f60a3cc7a3237 Mon Sep 17 00:00:00 2001 From: Gbemisola Date: Mon, 26 Jan 2026 21:07:08 +0100 Subject: [PATCH 70/70] implement credit card --- Sprint-3/4-stretch-investigate/card-validator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.md b/Sprint-3/4-stretch-investigate/card-validator.md index 2b265c977..42be5e453 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.md +++ b/Sprint-3/4-stretch-investigate/card-validator.md @@ -30,7 +30,7 @@ These are the requirements your project needs to fulfill: - Make a JavaScript file with a name that describes its contents. - Create a function with a descriptive name which makes it clear what the function does. The function should take one argument, the credit card number to validate. - Write at least 2 comments that explain to others what a line of code is meant to do. -- Return a boolean from the function to indicate whether the credit card number is valid. +- Return a boolean from the function to indicate whether the credit card number is valid; + -Good luck!