From d54399470c9191928932abfe745b2b7761baee5d Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Sun, 28 Sep 2025 17:50:06 +0100 Subject: [PATCH 01/20] explained what line 3 is doing --- Sprint-1/1-key-exercises/1-count.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..6240b9a7c 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,4 @@ 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 +//It assigns the variable"count" a new value of "count+1" which is "1" \ No newline at end of file From a7cc13e8b12884388bac11f79c7179f8fcd4213a Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Sun, 28 Sep 2025 17:59:05 +0100 Subject: [PATCH 02/20] extracted initials --- Sprint-1/1-key-exercises/2-initials.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..3527fc490 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,14 @@ 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.charAt(0)+middleName.charAt(0)+lastName.charAt(0); + +//or + +let initials=firstName[0]+middleName[0]+lastName[0] + + // https://www.google.com/search?q=get+first+character+of+string+mdn +// I really can't understand any of the documentation from developer.mozilla \ No newline at end of file From cb1e645fa66d9682d707655c32f7c8b4b7f181db Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Sun, 28 Sep 2025 18:51:20 +0100 Subject: [PATCH 03/20] assigned values to dir and ext --- Sprint-1/1-key-exercises/3-paths.js | 6 ++++-- 1 file changed, 4 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..a5bcbf83c 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,9 @@ 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(1,lastSlashIndex); + +const extPart=base.lastIndexOf(".") +const ext = base.slice(extPart); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 2d115ce677be1ec62e3b17b276b0328da1217695 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:00:02 +0100 Subject: [PATCH 04/20] described what each method does and the order each expression is evaluated --- Sprint-1/1-key-exercises/4-random.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..6614a7bd9 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -4,6 +4,17 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // In this exercise, you will need to work out what num represents? + //num represents a variable with the a random number as its value + // Try breaking down the expression and using documentation to explain what it means + //Math.random() returns a pseudo random number that's >=0 and <1 + //Math.floor() rounds down to the nearest integer + // It will help to think about the order in which expressions are evaluated + //this first (maximum-minimum+1) then this Math.random()* then this Math.floor() then this +minimum + // Try logging the value of num and running the program several times to build an idea of what the program is doing + //it returns a pseudo random number that's >=0 and <1 + + +console.log(num); From f6b6842712dec1ffc9aa2f5e87c646a2ca2ca866 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:23:31 +0100 Subject: [PATCH 05/20] added"//" so that the instructions don't get executed --- Sprint-1/2-mandatory-errors/0.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..4bbbd75b3 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,3 @@ -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? +// By commenting out the lines \ No newline at end of file From a4b365b38ef88d215948235c78872011135decce Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:35:43 +0100 Subject: [PATCH 06/20] explained why we can't reassign a variable when using "const" --- Sprint-1/2-mandatory-errors/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..9cdc3db32 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,5 @@ const age = 33; age = age + 1; +//the "age" variable has been declared with a const and already assigned a value and it can not +// be reassigned another value because of the "const" \ No newline at end of file From f8be9ecc1e8e8cadf0d4a34cefa4d9d20a45ad83 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:38:16 +0100 Subject: [PATCH 07/20] a variable needs to be declared before being initialized --- Sprint-1/2-mandatory-errors/2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..9ecde63ec 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,4 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; +//a variable needs to be declared before being initialized \ No newline at end of file From 6631cd9bd2c9f330e85e3aad86e6593f2c8513bd Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:46:43 +0100 Subject: [PATCH 08/20] updated the code by turning the value of cardNumber in to a string --- Sprint-1/2-mandatory-errors/3.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..58e0c46b2 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,7 @@ -const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +// const cardNumber = 4533787178994213; +// const last4Digits = cardNumber.slice(-4); + + // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +9,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 + + +//prediction: it won't work because the value of cardNumber is a number and slice() is a string method +const cardNumber = "4533787178994213"; +const last4Digits = cardNumber.slice(-4); +console.log(last4Digits); From 357720bcb7d0a9fb7175857a496fe2f865f1b08e Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 09:49:38 +0100 Subject: [PATCH 09/20] updated the names of the variables so that they dont't start with numbers --- Sprint-1/2-mandatory-errors/4.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..6a4500538 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,7 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +// const 12HourClockTime = "20:53"; +// const 24hourClockTime = "08:53"; + +//the name of a variable can not start with a number + +const twelveHourClockTime = "20:53"; +const twenty4hourClockTime = "08:53"; \ No newline at end of file From f6c81bf288dfa4a16a0b89e2018e4195bc8f19d9 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:12:42 +0100 Subject: [PATCH 10/20] answerred the questions and added a "," --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..3c6537a0f 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,17 @@ 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 + // 5 function calls: Number(),replaceAll(),Number(),replaceAll(),console.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? + //line 5, there was no "," between arguments // c) Identify all the lines that are variable reassignment statements + //line4,line5 // d) Identify all the lines that are variable declarations + //line1,line2,line7,line8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + //it replaces "," from the carPrice with an empty string, basically deleting the commas, and then turning the string "10000" + // in to a number 10000 From 54c1b63c18c70b4eb6bdf3b2d10a02b37362f3be Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:25:56 +0100 Subject: [PATCH 11/20] added explanations for variable declarations, function calls, and expressions in comments --- 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 47d239558..e7291be90 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,20 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? + //6 variable declarations // b) How many function calls are there? + //1 function call // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators + //% it's the remainder operator and it tells us how many seconds are left out of a whole minute // d) Interpret line 4, what does the expression assigned to totalMinutes mean? + //total time in minutes without the remaining seconds // e) What do you think the variable result represents? Can you think of a better name for this variable? + //"Movie length" // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + //it will work with all values as long as they are numbers, From 62b453fe698255c0d83183a7bf606b5d065084a3 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:47:10 +0100 Subject: [PATCH 12/20] commented what each line of code does --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..47f358c3d 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,15 +1,15 @@ -const penceString = "399p"; +const penceString = "399p"; const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1 -); +); //399 -const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); //399 const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2 -); +); //3 const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2) @@ -25,3 +25,22 @@ 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 = penceString.substring( +// 0, +// penceString.length - 1 +// ); : it creates a variable with the value "399" by eliminating the character at index penceString.length - 1 + +//3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");:initialises a string variable of at least 3 characters, +// if it has les than 3 characters it adds 0 to make up for it + +//4.const pounds = paddedPenceNumberString.substring( + //0, +// paddedPenceNumberString.length - 2 +// );:initialises a string variable with the value of paddedPenceNumberString except the last 2 characters + +//5.const pence = paddedPenceNumberString + // .substring(paddedPenceNumberString.length - 2) + // .padEnd(2, "0");: takes the last 2 characters from paddedPenceNumberString , it has to be 2 characters long if not it will add a 0 for + // every missing character + //it adds a dot between pounds and pence and logs 3.99 From 92647711daf21980c5514e4d5bf38ceefeb5a8fb Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:59:12 +0100 Subject: [PATCH 13/20] add explanations for the effects of the `prompt` function and its return value --- Sprint-1/4-stretch-explore/chrome.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..4db70f19a 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -15,4 +15,7 @@ What effect does calling the `alert` function have? Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? +It generates an input field + What is the return value of `prompt`? +whatever is introduced int hte input field From 2cb91c37d8442f84d9a931fd6cf5897a47fd7451 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:02:39 +0100 Subject: [PATCH 14/20] add explanations for the output of `console` and the syntax of `console.log` --- Sprint-1/4-stretch-explore/objects.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..d20545421 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -13,4 +13,7 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? +it stores properties + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +the dot allows to access the properties of the object "console" From 6b61b4cefadd66739ac9e66ca37fdf5cc0271025 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:17:16 +0100 Subject: [PATCH 15/20] fix: correct the slice start index for the dir part of the filePath --- Sprint-1/1-key-exercises/3-paths.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index a5bcbf83c..0cd458cb6 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,9 +17,10 @@ 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(1,lastSlashIndex); +const dir = filePath.slice(0,lastSlashIndex); const extPart=base.lastIndexOf(".") const ext = base.slice(extPart); -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +// https://www.google.com/search?q=slice+mdn + From c77d6f36d4d20b026658d5cf058e0647b0d0131a Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:22:14 +0100 Subject: [PATCH 16/20] fix: update comments to clarify the use of const and suggest using let for reassignment --- Sprint-1/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 9cdc3db32..770862b7e 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -3,4 +3,5 @@ const age = 33; age = age + 1; //the "age" variable has been declared with a const and already assigned a value and it can not -// be reassigned another value because of the "const" \ No newline at end of file +// be reassigned another value because of the "const" +// "age" should be declared with "let" to be able to change it's value \ No newline at end of file From fc023eb34f35a85ab684482c17df9075d7f766ba Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:23:58 +0100 Subject: [PATCH 17/20] fix: reorder variable declaration and console.log to ensure proper execution --- Sprint-1/2-mandatory-errors/2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index 9ecde63ec..7082ffcbb 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,6 +1,6 @@ // 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}`); const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); + //a variable needs to be declared before being initialized \ No newline at end of file From 594550113a875c2ffafa75b55bcd98dc3546aecc Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:37:46 +0100 Subject: [PATCH 18/20] fix: update comment to clarify the representation of the result variable --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 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 e7291be90..09de38e24 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -25,7 +25,7 @@ console.log(result); //total time in minutes without the remaining seconds // e) What do you think the variable result represents? Can you think of a better name for this variable? - //"Movie length" + //it represents the total movie time , so.... const totalMovieTime perhaps // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer //it will work with all values as long as they are numbers, From f091869dadddcb1d6b9c81c56d18920cbfcc3f5d Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:42:10 +0100 Subject: [PATCH 19/20] changed movielength, for testing --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 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 09de38e24..2b978cf42 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 = 5464557657; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; From ab656e847911b71421922130e8b56d2bf2d2b363 Mon Sep 17 00:00:00 2001 From: alexandru-pocovnicu <109530683+alexandru-pocovnicu@users.noreply.github.com> Date: Thu, 23 Oct 2025 12:57:03 +0100 Subject: [PATCH 20/20] fix: update movieLength value and rename result variable for clarity --- Sprint-1/3-mandatory-interpret/2-time-format.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 2b978cf42..91c1f6b76 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,13 +1,18 @@ -const movieLength = 5464557657; // length of movie in seconds +const movieLength = 1237401; // length of movie in seconds const remainingSeconds = movieLength % 60; + const totalMinutes = (movieLength - remainingSeconds) / 60; const remainingMinutes = totalMinutes % 60; const totalHours = (totalMinutes - remainingMinutes) / 60; -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; -console.log(result); +const timeInHhMmSs = `${totalHours + .toString() + .padStart(2, "0")}:${remainingMinutes + .toString() + .padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`; +console.log(timeInHhMmSs); // For the piece of code above, read the code and then answer the following questions @@ -25,7 +30,7 @@ console.log(result); //total time in minutes without the remaining seconds // e) What do you think the variable result represents? Can you think of a better name for this variable? - //it represents the total movie time , so.... const totalMovieTime perhaps + //it represents the total movie time , so.... const timeInHhMmSs perhaps // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer //it will work with all values as long as they are numbers,