From dc1ecca8b104c6c1ae30fd8a29ca2956d793dadd Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 13:52:05 +0100 Subject: [PATCH 01/23] made a prediction on what the error could be and gave value by calling the function --- Sprint-3/1-key-errors/0.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..fa3163882 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,13 @@ // Predict and explain first... -// =============> write your prediction here +// on line 8, let declaring with name the same as the parameter // 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 +console.log(capitalise("error") +// // =============> write your new code here From ff58b1908bb702d408680913cfd8cee140fc10b5 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 14:14:39 +0100 Subject: [PATCH 02/23] gave explanation on the error message and wrote a code to fix the error --- Sprint-3/1-key-errors/0.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index fa3163882..60cd87621 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -3,11 +3,18 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -// +//It says syntax error Identifier 'str' has already been declared. +// function parameter and let which is inside the funtion can never +// be the same because both variables are in the same scope function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } console.log(capitalise("error") // -// =============> write your new code here +// function capitalise(firstLetter){ +// let str =`${str[0].toUpperCase()${str.slice(1)}`; +// return str; +// } +// + From a09f7dfb4f31b5852aead1cd965707d1e3b6a269 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 15:04:04 +0100 Subject: [PATCH 03/23] wrote the fixed code and made the code with the bag comment --- Sprint-3/1-key-errors/0.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 60cd87621..ef1564faf 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -6,15 +6,15 @@ //It says syntax error Identifier 'str' has already been declared. // function parameter and let which is inside the funtion can never // be the same because both variables are in the same scope -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} -console.log(capitalise("error") +// function capitalise(str) { + //let str = `${str[0].toUpperCase()}${str.slice(1)}`; + //return str; +//} +//console.log(capitalise("error") // -// function capitalise(firstLetter){ -// let str =`${str[0].toUpperCase()${str.slice(1)}`; -// return str; -// } -// + function capitalise(firstLetter){ + let str =`${firstLetter[0].toUpperCase()}${firstLetter.slice(1)}` + return str; +} + console.log(capitalise("error")); From 772f4abed34d772a63ccf513bcbc0cbc4f890535 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 15:16:47 +0100 Subject: [PATCH 04/23] run prettier --- Sprint-3/1-key-errors/0.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index ef1564faf..2c591fd7e 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -3,18 +3,17 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -//It says syntax error Identifier 'str' has already been declared. -// function parameter and let which is inside the funtion can never +//It says syntax error Identifier 'str' has already been declared. +// function parameter and let which is inside the funtion can never // be the same because both variables are in the same scope // function capitalise(str) { - //let str = `${str[0].toUpperCase()}${str.slice(1)}`; - //return str; +//let str = `${str[0].toUpperCase()}${str.slice(1)}`; +//return str; //} //console.log(capitalise("error") -// - function capitalise(firstLetter){ - let str =`${firstLetter[0].toUpperCase()}${firstLetter.slice(1)}` - return str; +// +function capitalise(firstLetter) { + let str = `${firstLetter[0].toUpperCase()}${firstLetter.slice(1)}`; + return str; } - console.log(capitalise("error")); - +console.log(capitalise("error")); From 34272f8862424bf1fa73f87c1450a843e72ed449 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 19:48:57 +0100 Subject: [PATCH 05/23] add predict and explain about the code --- Sprint-3/1-key-errors/1.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..d67efedff 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,7 +1,12 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// / to calculate the percentage it has used the value from +// convertToPercentage() function so there will be error because +// the variable name for the parameter and const is the same. and console.log is called +// to print decimalNumber which is not known outside the function +// instead of printing the retun value of the function. + // Try playing computer with the example to work out what is going on From cdb17fe6396879b9f9ac5d0d78fcaf1dd785021d Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 22:30:02 +0100 Subject: [PATCH 06/23] Interpret the error message --- Sprint-3/1-key-errors/1.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index d67efedff..9924ba4a9 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -19,7 +19,8 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// the error was syntaxError it is stating decimalNumber has already been declared +//the parameter of the function convertToPercentage() and the const variable is the same // Finally, correct the code to fix the problem -// =============> write your new code here + From aa750f6e629a115e4b2ee9e92f4ad8abbe08aefe Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:06:17 +0100 Subject: [PATCH 07/23] correct code 1. --- Sprint-3/1-key-errors/1.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 9924ba4a9..0555c4aa1 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -23,4 +23,15 @@ console.log(decimalNumber); //the parameter of the function convertToPercentage() and the const variable is the same // Finally, correct the code to fix the problem - + // There can be two ways to fix the problem +// 1. to change const variable and the name decimalNumber in line 15. +// but still need to call the function convertToPercentage() in the consol.log() + +// function convertToPercentage(decimalNumber){ + // const numeral = 0.5; + // const percentage = `${numeral*100}%`; + // return percentage; + // } + // console.log(convertToPercentage()); + + // \ No newline at end of file From 5816a40e98e51535e9b40f56164b36140ab28126 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:09:34 +0100 Subject: [PATCH 08/23] correct code 2 --- Sprint-3/1-key-errors/1.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 0555c4aa1..38ec4a596 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,13 +1,12 @@ // Predict and explain first... // Why will an error occur when this program runs? -// / to calculate the percentage it has used the value from -// convertToPercentage() function so there will be error because -// the variable name for the parameter and const is the same. and console.log is called +// / to calculate the percentage it has used the value from +// convertToPercentage() function so there will be error because +// the variable name for the parameter and const is the same. and console.log is called // to print decimalNumber which is not known outside the function // instead of printing the retun value of the function. - // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { @@ -20,18 +19,27 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // the error was syntaxError it is stating decimalNumber has already been declared -//the parameter of the function convertToPercentage() and the const variable is the same +//the parameter of the function convertToPercentage() and the const variable is the same // Finally, correct the code to fix the problem - // There can be two ways to fix the problem +// There can be two ways to fix the problem // 1. to change const variable and the name decimalNumber in line 15. // but still need to call the function convertToPercentage() in the consol.log() - + // function convertToPercentage(decimalNumber){ - // const numeral = 0.5; - // const percentage = `${numeral*100}%`; - // return percentage; - // } - // console.log(convertToPercentage()); - - // \ No newline at end of file +// const numeral = 0.5; +// const percentage = `${numeral*100}%`; +// return percentage; +// } +// console.log(convertToPercentage()); + +//2 .The second one is to call the function with value in it. +// and to keep the code as it is except change the const variable name/or delet +// the const numeral with its value because there is no poin of keeping it. +// +// function convertToPercentage(decimalNumber){ +// const numeral = 0.5; +// const percentage = `${decimalNumber*100}%`; +// return percentage; +// } +// console.log(convertToPercentage()); From f51c24c7b05b9142257bebc4cf82e760c4a45c9c Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:36:04 +0100 Subject: [PATCH 09/23] Predict and explain what the error might be --- Sprint-3/1-key-errors/2.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..6a1d7d9e2 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,9 +1,12 @@ // Predict and explain first BEFORE you run any code... + + // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> function square(), shouldnt give a value to it , we can only pass +// an argument when the function is called, with value in it which is called argument. function square(3) { return num * num; From 83b4a7bd569097203d08033e351b5ac45363f2fa Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:46:59 +0100 Subject: [PATCH 10/23] run the code by calling the vanction with no value and the error message --- Sprint-3/1-key-errors/2.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 6a1d7d9e2..381232e15 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -5,14 +5,15 @@ // this function should square any number but instead we're going to get an error -// =============> function square(), shouldnt give a value to it , we can only pass +// =============> function square(), shouldn't give a value to it , we can only pass // an argument when the function is called, with value in it which is called argument. function square(3) { return num * num; -} +} +console.log(square()) -// =============> write the error message here +// =============> Unexpected number // =============> explain this error message here From 22b0b87c6fb879d38546b807a6dcaeae3027e8c5 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:52:55 +0100 Subject: [PATCH 11/23] Explain the error message --- Sprint-3/1-key-errors/2.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 381232e15..002f44bc0 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -15,10 +15,13 @@ console.log(square()) // =============> Unexpected number -// =============> explain this error message here +// =============> unexpected number in the function, there should be only parameter there but here +// number is assigned instead of the variable name // Finally, correct the code to fix the problem // =============> write your new code here + + From 71935b53cbace2deebdc7f6150966cb18575c959 Mon Sep 17 00:00:00 2001 From: Maharit Date: Fri, 25 Sep 2026 23:59:48 +0100 Subject: [PATCH 12/23] correcet code that fixed the error --- Sprint-3/1-key-errors/2.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 002f44bc0..39b639397 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,17 +1,14 @@ - // Predict and explain first BEFORE you run any code... - - // this function should square any number but instead we're going to get an error // =============> function square(), shouldn't give a value to it , we can only pass // an argument when the function is called, with value in it which is called argument. -function square(3) { - return num * num; -} -console.log(square()) +//function square(3) { +// return num * num; +//} +//console.log(square()) // =============> Unexpected number @@ -21,7 +18,7 @@ console.log(square()) // Finally, correct the code to fix the problem // =============> write your new code here - - - - +function square(num) { + return num * num; +} +console.log(square(3)); From 031eaf3de8572f78bb0cdebe036837bbd3c87b44 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sat, 26 Sep 2026 16:52:46 +0100 Subject: [PATCH 13/23] predit error and expplain outcome --- Sprint-3/2-mandatory-debug/0.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..07b4db39e 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// =============> there is no return,to return the value to the function call function multiply(a, b) { console.log(a * b); @@ -8,7 +8,8 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> the error is it is not printing out the function call in line 9. +// and returning is as undefined // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> From 54e0afb253c55fb1ddf71e662f8a836a19974ecf Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 12:36:27 +0100 Subject: [PATCH 14/23] correct code for o.js 2-mandatory debug --- Sprint-3/2-mandatory-debug/0.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 07b4db39e..9aaa0eb72 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -8,8 +8,11 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> the error is it is not printing out the function call in line 9. -// and returning is as undefined +// =============> the error is it is not printing out the function call in line 9. +// and returning is as undefined. // Finally, correct the code to fix the problem -// =============> +// Functiion multiply(a,b){ +// return a*b +// } +// console.log (`The result of multiplying 10 and 32 is ${multiply(10, 32)}`) From b4c7cf20bbdc59285e7ebfbe3623bdeeb2ae57d3 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 12:41:18 +0100 Subject: [PATCH 15/23] write a preditction and explain --- Sprint-3/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..e65e74d63 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> what does return value going to give out?,the expression is written after return. function sum(a, b) { return; From 3923291a3c036201ea47d751459d90e935ad2221 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 12:52:56 +0100 Subject: [PATCH 16/23] editted the prediction(wrote prediction and explanation in the same line) and wrote the code --- Sprint-3/2-mandatory-debug/1.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index e65e74d63..a082469e4 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> what does return value going to give out?,the expression is written after return. +// =============> return value is written before the expression. function sum(a, b) { return; @@ -8,6 +8,13 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> when the expression evaluates a value it will +// need a return statment,but the return statment is before the expression +// which will result in undefined outcome because the function that is passing +// an argument is not receiving output of the expression. // Finally, correct the code to fix the problem -// =============> write your new code here +// +// function sum(a, a){ +// return a+b; +//} +// console.log(`the sum of 10 and 32 is ${sum(10,32)}`); From 364a5e98ca3fe5dcb8e09e32f852a7a83a499672 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 13:18:26 +0100 Subject: [PATCH 17/23] predicted and explained the error of the code --- Sprint-3/2-mandatory-debug/2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..3296e54ae 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,7 +1,9 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> I think the num variable can be accesed by the funtion getLastDigit() +// so it means it is not using the argument that is passed by the function. +// the output for the three of function calls will be 3. const num = 103; From 96440cbdf6d1122f61b42bc6c7b253ee810eceb4 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 13:40:24 +0100 Subject: [PATCH 18/23] wrote the code again by fixing error --- Sprint-3/2-mandatory-debug/2.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 3296e54ae..7d7f03b49 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -17,10 +17,28 @@ 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 output is + // * 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 output is the way it is because it was taking the num value +// from the variable num that has been declared and initialized outside the function. +// and const num has a global scope.if the function hasn't declared a variable num +// inisde the function it will use the gobaly declared and insialized variable num // Finally, correct the code to fix the problem -// =============> write your new code here +// =============>function getLastDigit() { + 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 From fe28db63f4dea880f867a4059d4a43ef739ae32f Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 13:55:39 +0100 Subject: [PATCH 19/23] made the first code and run and checked the newcode, displayed the outcome. --- Sprint-3/2-mandatory-debug/2.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 7d7f03b49..aa7d03e84 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -5,15 +5,15 @@ // so it means it is not using the argument that is passed by the function. // the output for the three of function calls will be 3. -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 @@ -41,4 +41,8 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. + // yes it does tell the last digit of each number + // The last digit of 42 is 2 +// The last digit of 105 is 5 +// The last digit of 806 is 6 // Explain why getLastDigit is not working properly - correct the problem From 6a25d506628fbeb05a07d81be036d6ebfe67e15a Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 15:00:12 +0100 Subject: [PATCH 20/23] Wrote the code and tested --- Sprint-3/3-mandatory-implement/1-bmi.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..51fe1866b 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,4 +16,10 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height + return (weight / (height* height)).toString().slice(0,4); + } +console.log(`Your BMI is ${calculateBMI(79,1.73)} `); + +//The out come is + // Your BMI is 26.3 \ No newline at end of file From dfbeb6765fd13aec7368e112550c2ebab9f2c79d Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 16:27:28 +0100 Subject: [PATCH 21/23] wrote the code foe UPPER_SNAKE_CASE --- Sprint-3/3-mandatory-implement/2-cases.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..f6ea5d518 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,9 @@ // 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 upperSnakeCase(string){ + + return string.toUpperCase().replaceAll(" ", "_") +} + console.log(upperSnakeCase("lord of the Rings.")); \ No newline at end of file From 92253f5e5275cc879022f6bc2cb687563e7f2439 Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 20:19:00 +0100 Subject: [PATCH 22/23] wrote the code and tested the code with different value --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..0bc732b95 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,19 @@ // 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){ + let withOutP = penceString.substring( 0,penceString.length - 1); + let paddedPenceNumberString = withOutP.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("502p")); + + +//output for 4050p is £40.50 +//output for 29p is £0.29 +//output for 502 is £5.02 \ No newline at end of file From 3301df8c2c1733f1d28a2d637f8e11203c30e40e Mon Sep 17 00:00:00 2001 From: Maharit Date: Sun, 27 Sep 2026 21:16:45 +0100 Subject: [PATCH 23/23] run the code and answered the questions --- Sprint-3/4-mandatory-interpret/time-format.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..e9a1d1382 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -15,24 +15,35 @@ 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 // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> 3 times pad() will be called // 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 +// =============> 0 is the value assigned to num. // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// =============> 00 is the value of pad when it was called for the first time. // 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 +// =============> 1 is the value of num when the pad is called for the last time. The last time pad is called is + // by by putting "remaining seconds" which is 1 in the function pad . // e) What is the return value of pad when it is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> 01 is the return value of pad.when pad()is called with the value of num 1 the expression +// inside the pad function evaluates to a value 01. If we go through the code +// function pad(num) { + //let numString = num.toString();===> the value of numstring becomes "1" + //while (numString.length < 2) { ===> this line it is checking if numString.length< 2, numString.length is 1 in this line + //numString = "0" + numString; ===> in this line numString will be 01. and again will go to while again to check if + // } numString.length is <2 and it is not then pad() will return 01. + // + //