From 32407f92f9fd0ce28e3fba5ec44b26a38b344a5e Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 09:52:22 +0000 Subject: [PATCH 01/14] Update .gitignore to include .vscode directory --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bde36e5302..a4da420804 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules .DS_Store -.vscode -**/.DS_Store \ No newline at end of file +.vscode/ +**/.DS_Store From bfbcbe1125a50f17bfb109da5fe152edcbe42a18 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 20:16:38 +0000 Subject: [PATCH 02/14] explained error and removed let --- Sprint-2/1-key-errors/0.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..1d134af3dd 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// I think this function capitalise is meant to make the first letter of a string into uppercase then return the string // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,5 +9,11 @@ function capitalise(str) { return str; } -// =============> write your explanation here -// =============> write your new code here +// I got the error "SyntaxError: Identifier 'str' has already been declared" +// to fix this, I just removed the word let in line 8. This gave a value to str without trying to declare it again +// I ran the new code and there were no errors + +// function capitalise(str) { +// str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } From 2b742f7463b2d8a3e7e7642b8694b4e24de43740 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:01:10 +0000 Subject: [PATCH 03/14] prediction, explanation and correct code --- Sprint-2/1-key-errors/1.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..1c02b767a9 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,7 +1,7 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> decimalNumber is defined within the function so it will not be recognised in console.log(decimalNumber); // Try playing computer with the example to work out what is going on @@ -14,7 +14,24 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// =============> this is a function to convert a decimal number to a percentage - function declared +// the decimal number is declared as 0.5 +// percentage is calculated by multiplying the decimal // number by 100 and then adding the % symbol +// the answer returned is named percentage and gives a // number followed by % +// the answer will be printed in console // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> // the error was actually 'decimalNumber' has already been declared +// this was because decimalNumber was declared inside the function convertToPercentage(decimalNumber) +// and declared again within the function with the const statement +// once const decimalNumber = 0.5; was moved outside the function this error was resolved +// that way the global decimalNumber exists and the function can still accept it as an argument + + +// const decimalNumber = 0.5; +// function convertToPercentage(decimalNumber) { +// const percentage = `${decimalNumber * 100}%`; +// return percentage; +// } +// console.log(decimalNumber); + From 4c0e0ebafdbb1af7ee13d325066c6ab23da1bacd Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:05:47 +0000 Subject: [PATCH 04/14] predict, explain and code --- Sprint-2/1-key-errors/2.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..5922044d4b 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,18 +3,33 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> I think that return can only return a value not do a calculation +// so this will return an error because it is trying to do a calculation instead of returning a value function square(3) { return num * num; } -// =============> write the error message here -// =============> explain this error message here +function square(3) { + return num * num; +} + +// =============> SyntaxError: Unexpected number + +// =============> this is because variables and parameters in functions cannot start with a number or be a number +// however, return can be used for calculations so my prediction was wrong + // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +// function square (num) { +// return num * num; +// } +// console.log(square(5)); + +// ran console.log to ensure it works + From 3f9d9b636ab382741aa92f98ed21a8c5d33cea49 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:09:32 +0000 Subject: [PATCH 05/14] predict explain and fix code --- Sprint-2/2-mandatory-debug/0.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..7dc01ccb95 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,9 @@ // Predict and explain first... -// =============> write your prediction here +// =============> when the console.log outside the function is performed $(multiply(10, 32)) +// it will print the text The result of multiplying by 10 and 32 is +// but then will state undefined for the value + function multiply(a, b) { console.log(a * b); @@ -8,7 +11,21 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> there is no return +// console.log(a*B) printed the result of multiplying a and b but because there is no return +// the answer was not returned to the function so the console.log outside the function did not +// receive the value and printed undefined instead + // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +// function multiply(a, b) { +// return a * b; +// } +// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); + +// I removed the first console.log because it didn't seem necessary to print out 320 +// if you need to print 320 as well as the final console-log statement then console.log(a * b) +// can be added back in but it would need to be before the return statement because if it is +// after the return statement it will never be reached and the value will not be printed out + From 966c2c247a4ee30089ed5b1c27f3fccb7ba1a919 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:15:11 +0000 Subject: [PATCH 06/14] precting, explain and new code --- Sprint-2/2-mandatory-debug/1.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..b4a4cbf474 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,7 @@ // Predict and explain first... -// =============> write your prediction here +// =============> the function will not perform a + b and will return undefined in the + console.log function + function sum(a, b) { return; @@ -8,6 +10,14 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> there shouldn't be a semi-colon after return +// this will signify the end of function so a + b will not be performed therefore there +// is no answer to return to print in the console.log function + // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +// function sum(a, b) { +// return a + b; +// } +// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); + From 4dc8fb6d63c3e48dce686ccb1e2e5d879de6be79 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:30:00 +0000 Subject: [PATCH 07/14] tests and amendments --- Sprint-2/2-mandatory-debug/2.js | 38 +++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..18863ec5f5 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,7 +1,10 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> the function has no parameter so will use the +// global value of num for num.toString which means it will always +// return 3 which is the last digit of 103 + const num = 103; @@ -14,11 +17,38 @@ 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 +// =============> the function has no parameter so will use the +// global value of num for num.toString + // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +// function getLastDigit(num) { +// return num.toString().slice(-1); +// } + +// console.log(`The last digit of 42 is ${getLastDigit(42)}`); +// console.log(`The last digit of 105 is ${getLastDigit(105)}`); +// console.log(`The last digit of 806 is ${getLastDigit(806)}`); + +// removed const num = 103; and then added num as a parameter to the function +// getLastDigit so that it can take in the value of num when the function is +// called and return the last digit of that number instead of always using +// the global value of num which was 103. // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem + +// num was not declared within the function so the global value of num in the +// the const declaraton was used for each number +//I corrected this by putting num as a parmaeter for the function so that it can take +//in the value of num when the function is run for any number and return the last digit +//of the number instead of always using the fixed value of num which was 103. +//I also removed the const declaration of num because it was not needed and was causing +//confusion as to which value of num was being used in the function. + From 32001701cb6092c5695a0dcf3628639ae616fece Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:33:22 +0000 Subject: [PATCH 08/14] amended calculations for BMI --- Sprint-2/3-mandatory-implement/1-bmi.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1b..3630b45c7f 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,4 +16,7 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} \ No newline at end of file + const bmi = weight / (height * height); //calculation to calculate BMI + return bmi.toFixed(1); +} +console.log(calculateBMI(70, 1.73)); From c3f25c22ad9ac23aa088be4a5ce1776d6fdcf053 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:35:50 +0000 Subject: [PATCH 09/14] upperSnake solution --- Sprint-2/3-mandatory-implement/2-cases.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad9..4e4e04d3c2 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,19 @@ // 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(str) { + + return str.toUpperCase().split('').map(function(c) { + // splits string into individual characters and maps each character to a new value + + return /[A-Z0-9]/.test(c) ? c : '_'; + // checks if the character is an uppercase letter or a digit + + }).join(''); + // joins the array of characters back into a single string and replaces spaces with underscores +} + +console.log(toUpperSnakeCase("there-once was/a young lady from+London")); +console.log(toUpperSnakeCase("hello.world! test+123")); + From f2897ab95e674b9003c86185582bd9e7367b4cab Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:37:53 +0000 Subject: [PATCH 10/14] created function getPenceString --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..a08c01ca8d 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,21 @@ // 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 getPenceString(penceString){ + +const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); + //removes p +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + //puts zeros in front of number if less than 3 digits +const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); + //removes last 2 digits to get pounds +const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + //gets last 2 digits to get pence, if less than 2 digits adds zeros to end of string but shouldnt be less than 3 + //due to padStart above +return `£${pounds}.${pence}`; + // returns string with pounds and pence in correct format +} + +console.log(getPenceString("399p")); + // tested with 123p 1200p 24589p 89p 9p and 0p From 849f01e0f097799432424cd4fbabbb65c757befb Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:43:36 +0000 Subject: [PATCH 11/14] answered questions --- Sprint-2/4-mandatory-interpret/time-format.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8c..2b6cf0ea85 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -10,6 +10,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +console.log(formatTimeDisplay(61)); // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions @@ -17,18 +18,34 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> pad will be called 3 times, once for pad(totalHours, +// once for (pad)remainingMinutes and once for (pad)remainingSeconds + // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> The first call to pad is pad(totalHours). +//totalHours is calculated as totalMinutes // 60. +//For the input 61, seconds is 61, remainingSeconds is 1, and totalMinutes is 1. +//So, totalHours is 1 // 60 = 0. +//Therefore, num is assigned the value 0 when pad is called for the first time. + // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> The first call to pad is pad(totalHours). +//totalHours is calculated as totalMinutes // 60. +//For the input 61, totalMinutes is (61 - 1) // 60 = 1. +//So, totalHours is 1 // 60 = 0. +//pad(0) returns the string representation of 0, padded with zeros to a minimum length of 2, which is "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 +// =============> We look at the last call to pad, which is pad(remaining_seconds). +//remaining_seconds is calculated as seconds % 60. +//For the input 61, seconds % 60 equals 1. +//So, pad(remaining_seconds) is equivalent to pad(1). The value assigned to num in the last call to pad is 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 +// =============> For the input 61, remaining_seconds will be 1. So, pad(1) will return "01". Therefore, the value assigned to num is 1. From 8be3b9d3cc3602b972edc78cfc302e393e4b5813 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:46:57 +0000 Subject: [PATCH 12/14] amendments --- Sprint-2/4-mandatory-interpret/time-format.js | 3 ++- Sprint-2/5-stretch-extend/format-time.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 2b6cf0ea85..683ed89ba6 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -48,4 +48,5 @@ console.log(formatTimeDisplay(61)); // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> For the input 61, remaining_seconds will be 1. So, pad(1) will return "01". Therefore, the value assigned to num is 1. +// =============> For the input 61, remaining_seconds will be 1. So, pad(1) will return "01". +// Therefore, the value assigned to num is 1. diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b8..2ac536f761 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -23,3 +23,5 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); + +console.log formatAs12HourClock("14:00"); // should return "2:00 pm" From d6e7596bf2904f55c26e9901d47fa756592a4342 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Thu, 5 Mar 2026 22:56:56 +0000 Subject: [PATCH 13/14] trigger workflow From af41f53eb5c6944b3519666770e094aba0521466 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Sat, 7 Mar 2026 00:34:02 +0000 Subject: [PATCH 14/14] amendments made --- Sprint-2/3-mandatory-implement/1-bmi.js | 5 ++++- Sprint-2/3-mandatory-implement/2-cases.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 3630b45c7f..1ac2f387c0 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,7 +16,10 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height + // this will be a number to 1 decimal place const bmi = weight / (height * height); //calculation to calculate BMI - return bmi.toFixed(1); + return Number(bmi.toFixed(1)); } console.log(calculateBMI(70, 1.73)); + +// tested and it works, the function calculates the BMI correctly and returns it to 1 decimal place. diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 4e4e04d3c2..a9b0237c7e 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -24,7 +24,8 @@ function toUpperSnakeCase(str) { // checks if the character is an uppercase letter or a digit }).join(''); - // joins the array of characters back into a single string and replaces spaces with underscores + // joins the array of characters back into a single string and replaces spaces or special + // characters such as "?" with underscores } console.log(toUpperSnakeCase("there-once was/a young lady from+London"));