From 07075e1f51a97817b132e59fc7825a097e548ae2 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 15:39:07 +0000 Subject: [PATCH 01/20] I fixed the error and wrote a new code, it runs perfectly --- Sprint-2/1-key-errors/0.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..55fa5ac54 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,13 +1,18 @@ // Predict and explain first... // =============> write your prediction here +//I think it will give an error because we have `str` twice in line 10 we should only have return without `str` // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} + // =============> write your explanation here -// =============> write your new code here +// The error happened because 'str' was declared twice: once as a parameter and once with 'let' inside the function. +// Also, when calling the function, using a word without quotes caused a ReferenceError. +// After removing the duplicate declaration and passing a string with quotes, the function works correctly, +// =============> write your new code here +function capitalise(str) { + return `${str[0].toUpperCase()}${str.slice(1)}`; +} +console.log(capitalise("Hard")); From 7291d85a9b0ed8ce3e3fbbd8d8594ee4cf37d895 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 15:40:04 +0000 Subject: [PATCH 02/20] I fixed the error and wrote a new code, it runs perfectly --- Sprint-2/1-key-errors/0.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 55fa5ac54..468d80d17 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -5,10 +5,13 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring - +function capitalise(str) { + let str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} // =============> write your explanation here -// The error happened because 'str' was declared twice: once as a parameter and once with 'let' inside the function. +// The error happened because 'str' was declared twice, once as a parameter and once with 'let' inside the function. // Also, when calling the function, using a word without quotes caused a ReferenceError. // After removing the duplicate declaration and passing a string with quotes, the function works correctly, // =============> write your new code here From e838340a46ed32138e7cadf07cd51c1db6b3ed80 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 16:19:13 +0000 Subject: [PATCH 03/20] Fix convertToPercentage function; now returns correct 50% output --- Sprint-2/1-key-errors/1.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..e144e350c 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 +// =============> write your prediction here +// the error occur because the decimalNumber has already been declared. // Try playing computer with the example to work out what is going on @@ -15,6 +16,13 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here +// I tried to run the code it gives me SyntaxError,that the decimalNumber has already been declared, we can see in the parameter already has name decimalNumber. +// thats why declaring it again inside the function, causes an error. // Finally, correct the code to fix the problem // =============> write your new code here +function convertToPercentage(decimalNumber){ + const percentage = `${decimalNumber * 100}%`; + return percentage +} +console.log (convertToPercentage(0.5)); \ No newline at end of file From 9bcb86b735e4879b755ac2548ee12631de0e2574 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 17:01:58 +0000 Subject: [PATCH 04/20] I had to delete the broken code --- Sprint-2/1-key-errors/1.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index e144e350c..fc632156f 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,21 +1,17 @@ // Predict and explain first... // Why will an error occur when this program runs? + // =============> write your prediction here + // the error occur because the decimalNumber has already been declared. // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; - - return percentage; -} -console.log(decimalNumber); // =============> write your explanation here + // I tried to run the code it gives me SyntaxError,that the decimalNumber has already been declared, we can see in the parameter already has name decimalNumber. // thats why declaring it again inside the function, causes an error. From b4435a7d3386e67634ae5e32c923a22f34b6c2fd Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 17:04:17 +0000 Subject: [PATCH 05/20] Corrected square function; prints 9 for input 3 --- Sprint-2/1-key-errors/2.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..595c9532f 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -4,17 +4,20 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here +//I think it will give an error because the function parameter can not be a number like (3). -function square(3) { - return num * num; -} - -// =============> write the error message here +// =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here - +// the parameter can't be a number like (3),also changing num * num to number instead to match the parameter. // Finally, correct the code to fix the problem // =============> write your new code here +function square(number) { + return number * number; +} +console.log(square(3)); + From ccf9b9b13b77a831a88e7c9dac95efd82152c9f3 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 30 Oct 2025 17:32:10 +0000 Subject: [PATCH 06/20] Fixed multiply function to return correct output --- Sprint-2/2-mandatory-debug/0.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..14d3b6905 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,14 +1,17 @@ // Predict and explain first... // =============> write your prediction here - -function multiply(a, b) { - console.log(a * b); -} - -console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +// in console.log we should just write (multiply(10,32) because writing in plain english will give us an error, +// and it won't give the output. // =============> write your explanation here +// the code was broken because the console.log was inside the function it not a function, +//by using the return it gives us the correct output. // Finally, correct the code to fix the problem // =============> write your new code here +function multiply(a, b) { + return (a * b) +} + +console.log(multiply(10, 32)); From 3ae35f7a0531af328df1e5f3c0e6710bb924db05 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Sat, 1 Nov 2025 14:36:10 +0000 Subject: [PATCH 07/20] Updated variable names --- Sprint-1/2-mandatory-errors/0.js | 4 +-- Sprint-1/2-mandatory-errors/4.js | 4 +-- .../1-percentage-change.js | 2 +- Sprint-2/2-mandatory-debug/1.js | 14 ++++---- Sprint-2/2-mandatory-debug/2.js | 32 +++++++++++++++---- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..6a7a7f690 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 +// 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 diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..f0ab94e12 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 twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..5de10319e 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -2,7 +2,7 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..698328dc8 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,13 +1,15 @@ // Predict and explain first... // =============> write your prediction here +// The return statement is not in the right place, so the function doesn’t return the value. +// =============> write your explanation here +// The return statement is stopping the function too early, so it doesn’t return a + b. + +// Finally, correct the code to fix the problem +// =============> write your new code here function sum(a, b) { - return; - a + b; + return (a+b); } -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 +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..ac6a2d4e5 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -3,22 +3,40 @@ // Predict the output of the following code: // =============> Write your prediction here -const num = 103; +// const num = 103; -function getLastDigit() { - return num.toString().slice(-1); -} +// function getLastDigit() { +// 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)}`); +// 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)}`); // Now run the code and compare the output to your prediction // =============> write the output here +// the last digit of 42 is 3 +// the last digit of 105 is 3 +// the last digit of 806 is 3 // Explain why the output is the way it is // =============> write your explanation here +// we will always get number 3 because num is 103 in the last digit of it is 3. + // Finally, correct the code to fix the problem // =============> write your new code here +const num = 103; + +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 +// We need num in the function as a parameter. From f5a273adfe770c252b3b05967b8ccd7f4903d1dc Mon Sep 17 00:00:00 2001 From: khalidbih Date: Sat, 1 Nov 2025 15:16:54 +0000 Subject: [PATCH 08/20] I fixed errors and its able to run the code --- Sprint-2/1-key-errors/0.js | 8 ++++---- Sprint-2/1-key-errors/1.js | 2 +- Sprint-2/1-key-errors/2.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 468d80d17..d86ca61e5 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -5,10 +5,10 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} +// function capitalise(str) { +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } // =============> write your explanation here // The error happened because 'str' was declared twice, once as a parameter and once with 'let' inside the function. diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index fc632156f..00699d27d 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -13,7 +13,7 @@ // =============> write your explanation here // I tried to run the code it gives me SyntaxError,that the decimalNumber has already been declared, we can see in the parameter already has name decimalNumber. -// thats why declaring it again inside the function, causes an error. +// thats why declaring it again inside the function, causes an errors. // Finally, correct the code to fix the problem // =============> write your new code here diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index 595c9532f..6454e9b0a 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -11,7 +11,7 @@ // =============> explain this error message here // the parameter can't be a number like (3),also changing num * num to number instead to match the parameter. -// Finally, correct the code to fix the problem +// Finally, correct the code to fix the problem. // =============> write your new code here function square(number) { From 3960c5628c78961c436b1d44e37aff5d241b6034 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Sat, 1 Nov 2025 15:27:36 +0000 Subject: [PATCH 09/20] I changed the console.log --- Sprint-2/2-mandatory-debug/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 14d3b6905..b6f8ab512 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -5,8 +5,8 @@ // and it won't give the output. // =============> write your explanation here -// the code was broken because the console.log was inside the function it not a function, -//by using the return it gives us the correct output. +// the code was broken because the console.log was inside the function it not a function,by using the return it gives the outupt + // Finally, correct the code to fix the problem // =============> write your new code here From e7be3d32b70e9a4b0a4428ae9b997e67192b5ae4 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Sat, 1 Nov 2025 16:06:04 +0000 Subject: [PATCH 10/20] I fixed the return --- Sprint-2/2-mandatory-debug/1.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 698328dc8..696c0ce65 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -3,6 +3,7 @@ // The return statement is not in the right place, so the function doesn’t return the value. // =============> write your explanation here + // The return statement is stopping the function too early, so it doesn’t return a + b. // Finally, correct the code to fix the problem From 3557fef7a36f560ceace09a5c43f8dadb6b5c008 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Wed, 5 Nov 2025 20:14:04 +0000 Subject: [PATCH 11/20] exercise completed --- Sprint-2/3-mandatory-implement/1-bmi.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..fab3dfe3d 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,10 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { + let BMI = weight / (height * height); + let rounded = Math.round(BMI * 10) / 10; + return rounded; + +} +console.log(calculateBMI(70, 1.73)); // return the BMI of someone based off their weight and height -} \ No newline at end of file From 41416d5c041a323df189c4ee794bd8afc37a5474 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Wed, 5 Nov 2025 21:54:38 +0000 Subject: [PATCH 12/20] I used toUpperSnakeCase as the function name --- 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 5b0ef77ad..d047cede3 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 toUpperSnakeCase(inputString) { + return inputString.replaceAll(" ", "_").toUpperCase(); + + +} +console.log(toUpperSnakeCase("hello there")); +console.log (toUpperSnakeCase("lord of the rings")); \ No newline at end of file From 770c94ab7672a286611b3df09cb91b2cabe157a4 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Wed, 5 Nov 2025 23:30:12 +0000 Subject: [PATCH 13/20] I added reusable toPounds function --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..7b8f31f62 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,27 @@ // 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 +function toPounds (penceString) { + + +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"); + return `£${pounds}.${pence}`; +} + console.log (toPounds("399p")); + console.log (toPounds("400p")); + console.log (toPounds("243p")); + console.log (toPounds("9876p")); + console.log (toPounds("18p")); \ No newline at end of file From f425e8af83d6ef6d417d4eeffb6d0f64e98f847e Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 6 Nov 2025 15:57:38 +0000 Subject: [PATCH 14/20] This exercise complete --- Sprint-2/4-mandatory-interpret/time-format.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..322ba0c06 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -18,17 +18,24 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// It will be called 3 times hours,minutes and Seconds. // 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 first argument passed to pad (totalHours). +// totalHours = 0 // c) What is the return value of pad is called for the first time? // =============> write your answer here +// pad (totalHours) = pad(0) returns "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 called last time is num = 1 because that's the remainingSeconds which is 1 after +// we 61 divided by 60 = 1. // 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 +// The return value will be 01 because ToString gives "1" and padStart("2, 0") that adds 0 in the front \ No newline at end of file From b953519bc83daf547a06d1d616667d71a86299f7 Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 6 Nov 2025 23:22:58 +0000 Subject: [PATCH 15/20] I Fixed the code to get parts of filePath; runs correctly --- 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..c7024d0af 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,11 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable -const dir = ; -const ext = ; +const dir = filePath.slice(0, lastSlashIndex); +const ext = base.slice(base.lastIndexOf(".")); + +console.log(filePath, dir); +console.log(filePath, ext); + // https://www.google.com/search?q=slice+mdn \ No newline at end of file From f976015575851235e7fb8518610bd09e8c9ec21f Mon Sep 17 00:00:00 2001 From: khalidbih Date: Thu, 6 Nov 2025 23:49:50 +0000 Subject: [PATCH 16/20] format-time.js in Sprint-2 --- Sprint-2/5-stretch-extend/format-time.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b..9d5bc0b12 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -23,3 +23,7 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); +console.log(formatAs12HourClock("08:00")); +console.log(formatAs12HourClock("23:00")); +console.log(formatAs12HourClock("00:00")); +console.log(formatAs12HourClock("12:00")) \ No newline at end of file From 2579613c8bb0ce55eb17654ee90bbe1625050eca Mon Sep 17 00:00:00 2001 From: Khalid Date: Sat, 8 Nov 2025 14:12:17 +0000 Subject: [PATCH 17/20] I Removed unrelated Sprint-1 files from Sprint-2 PR Deleted unrelated Sprint-1 files that were mistakenly included in the Sprint-2 branch to keep the PR clean. --- Sprint-1/1-key-exercises/3-paths.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Sprint-1/1-key-exercises/3-paths.js diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js deleted file mode 100644 index c7024d0af..000000000 --- a/Sprint-1/1-key-exercises/3-paths.js +++ /dev/null @@ -1,27 +0,0 @@ -// The diagram below shows the different names for parts of a file path on a Unix operating system - -// ┌─────────────────────┬────────────┐ -// │ dir │ base │ -// ├──────┬ ├──────┬─────┤ -// │ root │ │ name │ ext │ -// " / home/user/dir / file .txt " -// └──────┴──────────────┴──────┴─────┘ - -// (All spaces in the "" line should be ignored. They are purely for formatting.) - -const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; -const lastSlashIndex = filePath.lastIndexOf("/"); -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 -// Create a variable to store the ext part of the variable - -const dir = filePath.slice(0, lastSlashIndex); -const ext = base.slice(base.lastIndexOf(".")); - -console.log(filePath, dir); -console.log(filePath, ext); - - -// https://www.google.com/search?q=slice+mdn \ No newline at end of file From 7f0b5389e2ea166da90714fd56b05b916ff3daf9 Mon Sep 17 00:00:00 2001 From: Khalid Date: Sat, 8 Nov 2025 14:14:27 +0000 Subject: [PATCH 18/20] I Removed unrelated Sprint-1 files from Sprint-2 PR Deleted unrelated Sprint-1 files that were mistakenly included in the Sprint-2 branch to keep the PR clean. --- Sprint-1/2-mandatory-errors/0.js | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/0.js diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js deleted file mode 100644 index 6a7a7f690..000000000 --- a/Sprint-1/2-mandatory-errors/0.js +++ /dev/null @@ -1,2 +0,0 @@ -// 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 From e679e6816d0583797fce34c90f897331dfe9515a Mon Sep 17 00:00:00 2001 From: Khalid Date: Sat, 8 Nov 2025 14:23:36 +0000 Subject: [PATCH 19/20] I Removed unrelated Sprint-1 files from Sprint-2 PR Deleted unrelated Sprint-1 files that were mistakenly included in the Sprint-2 branch to keep the PR clean. --- .../1-percentage-change.js | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 Sprint-1/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js deleted file mode 100644 index 5de10319e..000000000 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ /dev/null @@ -1,22 +0,0 @@ -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? From 34ea90174f840195a1f25c16e7c52a81d31cfa59 Mon Sep 17 00:00:00 2001 From: Khalid Date: Sat, 8 Nov 2025 14:24:31 +0000 Subject: [PATCH 20/20] I removed Sprint-1 files from Sprint-2 PR Deleted unrelated Sprint-1 files that were mistakenly included in the Sprint-2 branch to keep the PR clean. --- Sprint-1/2-mandatory-errors/4.js | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/4.js diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js deleted file mode 100644 index f0ab94e12..000000000 --- a/Sprint-1/2-mandatory-errors/4.js +++ /dev/null @@ -1,2 +0,0 @@ -const twelveHourClockTime = "20:53"; -const twentyFourHourClockTime = "08:53"; \ No newline at end of file