From 215f710d1b16d80909ef435f9f47ffa24f066d32 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Thu, 9 Jul 2026 18:03:36 +0100 Subject: [PATCH 01/10] Sprint 2 - 1 key errors - 0.js - Answered questions. --- Sprint-2/1-key-errors/0.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..27134a725c 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,6 +1,8 @@ // Predict and explain first... // =============> write your prediction here +//I know that its going to say str has allready been declared. + // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -10,4 +12,14 @@ function capitalise(str) { } // =============> write your explanation here +/* + I think its because of been called multiple times, at "let str" after "funtion capitalise(str)" + changing "let str" to "let capitalised" should help the issue. +*/ // =============> write your new code here +/* +function capitalise(str) { + let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; + return capitalised; +} +*/ From 43314e7dae0e858846e0fadced32fda7c34dcb9c Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 11:23:59 +0100 Subject: [PATCH 02/10] Sprint 2 - 1 Key errors - 1.js Added answers to questions. --- Sprint-2/1-key-errors/0.js | 2 +- Sprint-2/1-key-errors/1.js | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 27134a725c..9527e1f388 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,7 +1,7 @@ // Predict and explain first... // =============> write your prediction here -//I know that its going to say str has allready been declared. +//str has allready been declared. // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..4b1edbfd5f 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -2,7 +2,11 @@ // Why will an error occur when this program runs? // =============> write your prediction here - +/* +Yes an error will occur. +decimalNumber has been declared +an error will another errour would be for, decimalNumber is not defined +*/ // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { @@ -15,6 +19,19 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here - +/* +decimalNumber has been called and set as a const. +"console.log(decimalNumber)" wont work as decimalNumber only excistes inside the function not outside it. +*/ // Finally, correct the code to fix the problem // =============> write your new code here +/* +function convertToPercentage(decimalNumber) { + const decimal = 0.5; + const percentage = `${decimal * 100}%`; + + return percentage; + +} + console.log(convertToPercentage) +*/ From bc09e54d7172de85cc7877cbc935c70fe2ad9a37 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 11:42:33 +0100 Subject: [PATCH 03/10] Sprint 2 - 1 key errors - 2.js Added answers to the questions --- Sprint-2/1-key-errors/2.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..54c10f809f 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -1,6 +1,5 @@ // 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 @@ -10,11 +9,17 @@ function square(3) { } // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here - +// the (3) is a value not a variable or parimitor name, it should be num instead for the functino to work corretly. // Finally, correct the code to fix the problem // =============> write your new code here - - +/* + function square(num) { + return num * num; + } + + console.log (square(3)); +*? \ No newline at end of file From 3860339c77db850fcf4cc016ee9e16146a122ecd Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 11:51:38 +0100 Subject: [PATCH 04/10] Sprint 2 - 2 mandatory debug - 0.js Added answers to the questions. --- Sprint-2/2-mandatory-debug/0.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..61b63482f2 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,7 @@ // Predict and explain first... // =============> write your prediction here +// is going to have undefined function multiply(a, b) { console.log(a * b); @@ -9,6 +10,17 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here - +/* +its going to have undefined for the ${multiply(10, 32) as in teh function it has console.log. +It needs to have "return" in order for it to keep teh vaule for the function as it is only displying it right now. +*? // 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)}`); + +*/ From 16cb2955d08bbf2f9a8c5cecae4fc25a756aaad7 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 11:56:14 +0100 Subject: [PATCH 05/10] Sprint 2 - 2 Mandatory debug - 1.js added answer to questions asked. --- Sprint-2/2-mandatory-debug/1.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..8a20ff68ce 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,6 @@ // Predict and explain first... // =============> write your prediction here +// return undefined for ${sum(10, 32)} function sum(a, b) { return; @@ -9,5 +10,13 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// in the function return is split from a + b by ; // 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)}`); +*/ \ No newline at end of file From 26932f6450edd9f8b4cb9956543b596b19370abf Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 12:08:42 +0100 Subject: [PATCH 06/10] Sprint 2 - 2 Mandatory debug - 2.js Added answers to the questions asked. --- Sprint-2/2-mandatory-debug/2.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..0a1472fba4 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,7 @@ // Predict the output of the following code: // =============> Write your prediction here +// There wont be an error warning shown, it will show 3 request. const num = 103; @@ -15,10 +16,27 @@ 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 +/* Simply the "const num = 103" is forcing return num to be 103 at all times. + This can be fixed by putting num in getLastDigit(num), removing the "const num = 103" as it isnt needed. // Finally, correct the code to fix the problem // =============> write your new code here +/* +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); +*/ + // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From b337899941ab037d24be36d22ddc6c6475c4f9ad Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 12:48:01 +0100 Subject: [PATCH 07/10] Sprint 2 - 3 Mandatory implement - 1-bmi.js Added code for the bmi calculator, --- 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 17b1cbde1b..97ba4e2190 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 squaredHeight = (height * height); + let baseBmi = (weight / squaredHeight); + return bmi = Math.round(baseBmi * 10) / 10; +} +console.log (`BMI is ${calculateBMI(70,1.73)}`); + // return the BMI of someone based off their weight and height -} \ No newline at end of file From 7fe8f432e4e38dd0b08536a04023f7e967275be6 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 13:40:41 +0100 Subject: [PATCH 08/10] Sprint 2 - 3 mandatory implement - 2-cases.js Completed the code required for the task. --- Sprint-2/3-mandatory-implement/2-cases.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad9..883fe9c79a 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 UpperSnake(text) { + let upperCase = text.toUpperCase(); + let snakeCase = upperCase.replaceAll(" ","_"); + return snakeCase; +} + +console.log(UpperSnake("hello there bob")); \ No newline at end of file From 120157ae9491e5fdf0fd207494b8259bd00e4c07 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 14:03:27 +0100 Subject: [PATCH 09/10] Sprint 2 - 3 Mandatory implement - 3-to-pounds.js Added the simple code for converting to pounds, using kilograms. --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 5 +++++ 1 file changed, 5 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..dfbb772c00 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,8 @@ // 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(weight) { + return (weight * 2.204); +} + +console.log(toPounds(70)) \ No newline at end of file From d79d235e4d7036a76a2e3fd9ce234db8e235a4b3 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 10 Jul 2026 15:51:09 +0100 Subject: [PATCH 10/10] Sprint 2 - 4 mandatory interpret - time-format.js Answered questions required. --- Sprint-2/4-mandatory-interpret/time-format.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01e..7eee877fbf 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -21,18 +21,18 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> 3 times // 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 +// =============> 61 // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> "61" // 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, when pad is last called its at ${pad(remainingSeconds)} where the value left is 1 // e) What is the return value of pad when it is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> 1 at const remainingSexonds = seconds % 60 gives 1 \ No newline at end of file