Skip to content

Commit 48b94e2

Browse files
committed
completed task 2-time-format
1 parent e44ee66 commit 48b94e2

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎Sprint-2/3-mandatory-interpret/1-percentage-change.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ console.log(`The percentage change is ${percentageChange}`);
1717

1818
// 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?
1919
// Answer: The error is coming from line 5, spotting at the Number(priceAfterOneYear.replaceAll("," ""));
20-
// // It's a synthax error missing a comma
20+
// It's a synthax error missing a comma
2121

2222
// c) Identify all the lines that are variable reassignment statements
2323

@@ -28,4 +28,5 @@ console.log(`The percentage change is ${percentageChange}`);
2828
// Answer: Line 1,2,7 and 8 are variable declearations
2929

3030
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
31+
3132
// Answer: ReplaceAll() function clears out all the commas in the strings, the number() converts the strings to numbers to help with calculation

‎Sprint-2/3-mandatory-interpret/2-time-format.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,27 @@ console.log(result);
1313

1414
// a) How many variable declarations are there in this program?
1515

16+
// Answer: There is only 6 variable declearation altogether in this program
17+
1618
// b) How many function calls are there?
1719

20+
// Answer: There is only 1 call function in this program
21+
1822
// c) Using documentation, explain what the expression movieLength % 60 represents
1923
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2024

25+
// Answer: The % symbol represent the remainder (modulo) operator, it calculates the leftover/remainder after integer division.
26+
// Answer: % 60 divides the movieLength by 60 and returns only the remainder.
27+
2128
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2229

30+
// Answer: Line 4 expression helps to eliminate any remainder from the equation, so its left with a clean multiple of 60 to avoid any decimal
31+
2332
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2433

34+
// Answer: It represent the total duration of the movie formatted into hours, minutes and seconds
35+
// Answer: A better name could be "totalMovieDuration"
36+
2537
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
38+
39+
// Answer: It will work for integer values and will give us clear and clean result using this code. However, the result would not be clean as this using float values

0 commit comments

Comments
 (0)