From d6c5c0bcf37726f1317730bd14c6c28995c497ad Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:34:05 +0100 Subject: [PATCH 01/16] Described what line 3 is doing --- Sprint-1/1-key-exercises/1-count.js | 2 ++ Sprint-1/1-key-exercises/2-initials.js | 4 +++- Sprint-1/1-key-exercises/3-paths.js | 5 +++-- Sprint-1/1-key-exercises/4-random.js | 15 +++++++++++++++ Sprint-1/2-mandatory-errors/0.js | 7 +++++-- Sprint-1/2-mandatory-errors/1.js | 9 ++++++++- Sprint-1/2-mandatory-errors/2.js | 4 +++- Sprint-1/2-mandatory-errors/3.js | 13 ++++++++++++- Sprint-1/2-mandatory-errors/4.js | 14 +++++++++++++- .../3-mandatory-interpret/1-percentage-change.js | 14 +++++++++++++- Sprint-1/3-mandatory-interpret/2-time-format.js | 15 ++++++++++++++- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 11 +++++++++++ 12 files changed, 102 insertions(+), 11 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..b42fea075 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,5 @@ 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 +// Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the +// left. \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..758aeb86b 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,9 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials = ``; +let initials = firstName[0]+middleName[0]+lastName[0]; + +console.log(initials) // https://www.google.com/search?q=get+first+character+of+string+mdn diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..e402782c7 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,8 @@ 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(lastSlashIndex+1); +const ext = base.slice(base.lastIndexOf(".") + 1); +console.log(dir) // https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..bf468194c 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,18 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // 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 + + +// num represents the result of equation at the right hand side of the operator = + +// Step-1 ---> Math.random() generates a random decimal, +// Step-2 ---> (maximum-minumum +1) is evaluated +// Step-3 ---> Math.random() is multiplied by (maximum-minumum +1) +// Step-4 ---> the resukt of Step-3 is round by the method Math.floor +// Step-5 ---> minimum is added to the result of Step-4 + +// Thus, num represents random numbers generated between minimum 1 and maximum 100. As we run the code several times it +// generates new numbers. + + +console.log(num); \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..bf619b422 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,5 @@ -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? + +// We have solved it by adding two forward slashes (//) at the beginning of each line. +// The computer does not run this line too. \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..c7a1b7e13 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,11 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +//const age = 33; + +// we need to replace "const" with "let" + +let age = 33; age = age + 1; + + +console.log(age); \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..73edf9c6e 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,7 @@ // 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}`); +// The variable cityOfBirth was called before it was defined, so we need to bring that variable first const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); + diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..43671ab62 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,10 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +//const last4Digits = cardNumber.slice(-4); + +const last4Digits = cardNumber.toString().slice(-4); + + +console.log(last4Digits); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +12,9 @@ const last4Digits = cardNumber.slice(-4); // 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 + +// I think the code does not work because cardNumber variable is not stored as string. + +// My guess was right. + +// Therefore first we need to change CardNumber variable into string before we use the slice method. \ 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..6c8ed1ed0 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,14 @@ const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const 24hourClockTime = "08:53"; + +// Alternatively the above variable names can be corrected as follows: + +// Option-1 + +const twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; + +// Option -2 + +const hour12ClockTime = "20:53"; +const hour24ClockTime = "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..975f4a740 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; @@ -12,11 +12,23 @@ 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 + +// Ans: There are five (5) function calls, Line 4 Number() and replaceAll(), Line 5, Number() and replaceAll() + // Line 10 log(). // 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? +// Ans: The error is coming from line 5 "("," ""));"" a comma was missing. Putting a comma solved the problem. + // c) Identify all the lines that are variable reassignment statements + +// Ans: Line 4 carPrice and Line 5 priceAfterOneyear are variable reassignments. // d) Identify all the lines that are variable declarations +// Ans: 4 variable declaration Line 1, Line 2, Line 7 and Line 8 + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + +// Ans: The purpose of the expression Number(carPrice.replaceAll(",","")) is to change a string argument the contains commas passed to replaceAll() +// function into number, first the function replaceAll() removes the commas and then the function Number() changes it into number. diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..25133a3df 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = -3500; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -13,13 +13,26 @@ console.log(result); // a) How many variable declarations are there in this program? +// Ans: There are 6 variable declaration: Line 1, Line 3, Line 4, Line 6, Line 7, Line 9, + // b) How many function calls are there? +// Ans: There is one function call ... log() + // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// Ans: The expression movieLength % 60 returns the reminder after totalMinutes is divided by 60. + // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// The expression is calculating how many full minutes are in the movie’s total length by removing leftover seconds(less than 60) + // e) What do you think the variable result represents? Can you think of a better name for this variable? +// Ans: the variable result represent total movie lenght, Movie duration_hr_min_sec would be better name. + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + +// Ans: I have tried with different values and it seems to work for all values, but it needs to validate to avoid entering negative values +// I inserted --3500 and returned 0: -58: -20 which does not mean real time representation. diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..3782a9ae5 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,14 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. const penceStringWithoutTrailingP = a string value "399" is reassigned to penceStringWithoutTrailingP after + // the the letter p is removed from "399p" +// 3. const paddedPenceNumberString = declared new variable, padStart ensures any argument passed is at least 3 digits long. +// 4. Line 9 a new variable pence is declared and its value comes from the padded string by removing the last two strings. + // eg. 399 removing 99 get 3 if the intial amount was 55 after padding it would be 055 and the pound result would be 0 + +// 5. Line 14 const pence = declared a variable and the variable is the result after extracts the last two digits + // from the pence string and pads it to 2 characters to have two digit pence string. + +// 6. Line 18- console.log(`£${pounds}.${pence}`); returns money amount combining pound and pence alog with the symbol £. +// eg. £3.99 \ No newline at end of file From 2ae5aaa1c568d566a9363627e3efdd89a17aafa6 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:37:27 +0100 Subject: [PATCH 02/16] Declare a variable called initials that stores the first character of each string --- Sprint-1/1-key-exercises/2-initials.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 758aeb86b..80b438941 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -11,3 +11,5 @@ console.log(initials) // https://www.google.com/search?q=get+first+character+of+string+mdn +// Declared a variable named initials + From ebd4d3e880b99001683eac11049d6b53c6f0c313 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:40:58 +0100 Subject: [PATCH 03/16] Describe what line 3 is doing. --- Sprint-1/1-key-exercises/1-count.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index b42fea075..f02a352cf 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -5,4 +5,6 @@ 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 // Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the -// left. \ No newline at end of file +// left. + +// Describe what line 3 is doing. \ No newline at end of file From 7eb19b306a9aeddd24ddeeaf77938f03aff0e8a9 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:42:44 +0100 Subject: [PATCH 04/16] Described what line three is doing. --- 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 f02a352cf..58d7441e1 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -7,4 +7,4 @@ count = count + 1; // Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the // left. -// Describe what line 3 is doing. \ No newline at end of file +// Described what line three is doing. \ No newline at end of file From f683d85bbe2b9e01704689ae06f48f0cc1f55250 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:43:48 +0100 Subject: [PATCH 05/16] Described what line three is doing. From 76e6a400f3dcf5f7f3974fdbf7aaf6dbf65b979c Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 19:58:51 +0100 Subject: [PATCH 06/16] Declared a variable named initials From b9a5530c2e83d0863c616033b979b0c7b87ee7b6 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 20:00:01 +0100 Subject: [PATCH 07/16] Created dir and ext variables From fc1f2d412b6b40b3094e02f37890022d5565a0f4 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Fri, 17 Oct 2025 20:00:58 +0100 Subject: [PATCH 08/16] Described what the prpgram is doing From 927521cdfc49f122a4d471b4e4fb9d5c3471ba2a Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 14:37:20 +0100 Subject: [PATCH 09/16] Modified --- Sprint-1/2-mandatory-errors/2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index 73edf9c6e..fa05bb6b6 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -5,3 +5,5 @@ const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); +// Problem fixed + From 7db8109ce38d18d3fb5e05f18413dd985656671a Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 14:39:14 +0100 Subject: [PATCH 10/16] Modified --- Sprint-1/1-key-exercises/1-count.js | 36 +++++++++++++++++++++++--- Sprint-1/1-key-exercises/2-initials.js | 11 ++++++++ Sprint-1/2-mandatory-errors/2.js | 2 +- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 58d7441e1..8f4a1b751 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,10 +1,40 @@ -let count = 0; +//let count = 0; -count = count + 1; +//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 // Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the // left. -// Described what line three is doing. \ No newline at end of file +// Described what line three is doing. + +function drawStairs(n) { + let result = ""; + if (n < 1) return result; // nothing to do + + let iCount = 0; + while (iCount < n) { + // add spaces before the I (for all lines after the first) + let spaceCount = 0; + while (spaceCount < iCount) { + result = result.concat(" "); + spaceCount = spaceCount + 1; + } + + // add the "I" + result = result.concat("I"); + + // add a newline after each line except the last one + if (iCount < n - 1) { + result = result.concat("\n"); + } + + // update the count + iCount = iCount + 1; + } + + return result; +} + +console.log(drawStairs(10)); diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 80b438941..48aff5749 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -13,3 +13,14 @@ console.log(initials) // Declared a variable named initials +function drawStairs(n) { + let result = []; + + for (let i = 0; i < n; i++) { + result[i] = `${' '.repeat(i)}I`; + } + + return result.join('\n'); +} +console.log(drawStairs(5)); + diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index fa05bb6b6..a624c246f 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -5,5 +5,5 @@ const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); -// Problem fixed +// Problem has been fixed From 97637ad04f22368c0164356ec5144a5b40ed4773 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 14:43:13 +0100 Subject: [PATCH 11/16] Added codewar related code --- Sprint-1/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 8f4a1b751..3f097c13b 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -9,6 +9,8 @@ // Described what line three is doing. +// Example from codewar (from programming workshop) + function drawStairs(n) { let result = ""; if (n < 1) return result; // nothing to do From 5dab8a68501256cadea71af1516e018933b0d5af Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 15:15:31 +0100 Subject: [PATCH 12/16] Used template string to display initials --- Sprint-1/1-key-exercises/1-count.js | 13 +++++++++++++ Sprint-1/1-key-exercises/2-initials.js | 17 ++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 3f097c13b..36a9843e8 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -40,3 +40,16 @@ function drawStairs(n) { } console.log(drawStairs(10)); + +/// Another example + +function drawStairs(n) { + let result = []; + + for (let i = 0; i < n; i++) { + result[i] = `${' '.repeat(i)}I`; + } + + return result.join('\n'); +} +console.log(drawStairs(5)); diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 48aff5749..c65df8273 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,9 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials = firstName[0]+middleName[0]+lastName[0]; +//let initials = firstName[0] + middleName[0] + lastName[0]; + +let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; console.log(initials) @@ -13,14 +15,7 @@ console.log(initials) // Declared a variable named initials -function drawStairs(n) { - let result = []; - - for (let i = 0; i < n; i++) { - result[i] = `${' '.repeat(i)}I`; - } - - return result.join('\n'); -} -console.log(drawStairs(5)); +// Used template string to display initials Line 10 + + From 6e76b0d9bf078297a9e8f9b5671bcaaeffc29e47 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 15:23:57 +0100 Subject: [PATCH 13/16] Differentiated const and let --- Sprint-1/2-mandatory-errors/1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index c7a1b7e13..cd331def8 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,7 +2,10 @@ //const age = 33; -// we need to replace "const" with "let" +// we need to replace "const" with "let", in javascript "const" is usd for variable +// that will nor change / will be kept constant troughout the code, where is "let" +// lets us to reassign variable later as we have done in the lines below the variabel age +// gets updated by one... let age = 33; age = age + 1; From 6ac30150ae38ef06e395259b2b43a06385c547ca Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 15:26:17 +0100 Subject: [PATCH 14/16] Corrected typo --- Sprint-1/3-mandatory-interpret/2-time-format.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 25133a3df..31562dae7 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -22,7 +22,7 @@ console.log(result); // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators -// Ans: The expression movieLength % 60 returns the reminder after totalMinutes is divided by 60. +// Ans: The expression movieLength % 60 returns the remainder after totalMinutes is divided by 60. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? @@ -36,3 +36,6 @@ console.log(result); // Ans: I have tried with different values and it seems to work for all values, but it needs to validate to avoid entering negative values // I inserted --3500 and returned 0: -58: -20 which does not mean real time representation. + + +// Corrected typo reminder -----> remainder From 1e97c2e34119ac5c096cb7d9ab0c8199e591fa68 Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 15:33:13 +0100 Subject: [PATCH 15/16] Suggested better names in "camel case" --- Sprint-1/3-mandatory-interpret/2-time-format.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 31562dae7..c3c86860c 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -32,6 +32,11 @@ console.log(result); // Ans: the variable result represent total movie lenght, Movie duration_hr_min_sec would be better name. +// In a "camel case" the following options would be better names +// 1. MovieDurationHrMinSec +// 2. TotalMovieSpan +// 3. TotalMoviePeriod + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer // Ans: I have tried with different values and it seems to work for all values, but it needs to validate to avoid entering negative values @@ -39,3 +44,4 @@ console.log(result); // Corrected typo reminder -----> remainder +// Suggested better names in "camel case" a convention in Javascript From 4010b4dbdbdfa2c793335f4acc2962ba178e1dac Mon Sep 17 00:00:00 2001 From: UbunMen Date: Sat, 18 Oct 2025 15:42:07 +0100 Subject: [PATCH 16/16] corrected name suggestion according to camelCase --- Sprint-1/3-mandatory-interpret/2-time-format.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index c3c86860c..ff8df7259 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -33,9 +33,9 @@ console.log(result); // Ans: the variable result represent total movie lenght, Movie duration_hr_min_sec would be better name. // In a "camel case" the following options would be better names -// 1. MovieDurationHrMinSec -// 2. TotalMovieSpan -// 3. TotalMoviePeriod +// 1. movieDurationHrMinSec +// 2. totalMovieSpan +// 3. totalMoviePeriod // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer @@ -45,3 +45,5 @@ console.log(result); // Corrected typo reminder -----> remainder // Suggested better names in "camel case" a convention in Javascript + +// corrected name suggestion according to camelCase