Skip to content

Commit d0c0bd7

Browse files
committed
until time format is finished.
1 parent 8ccf3b2 commit d0c0bd7

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let carPrice = "10,000";
22
let priceAfterOneYear = "8,543";
33

44
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
5+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
66

77
const priceDifference = carPrice - priceAfterOneYear;
88
const percentageChange = (priceDifference / carPrice) * 100;
@@ -20,3 +20,17 @@ console.log(`The percentage change is ${percentageChange}`);
2020
// d) Identify all the lines that are variable declarations
2121

2222
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
23+
24+
25+
// a) There are 3 function calls in this file:
26+
// `carPrice.replaceAll(",", "")` on line 5
27+
// `priceAfterOneYear.replaceAll(",", "")` on line 6
28+
// `Number(...)` on lines 5 and 6
29+
// b) The error occurs on line 5 there's a missing comma.
30+
//c) The variable reassignment statements are:
31+
// `carPrice = Number(carPrice.replaceAll(",", ""));` on line 5
32+
// `priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));` on line 6
33+
// d) The variable declarations are:
34+
// `let carPrice = "10,000";` on line 1
35+
// `let priceAfterOneYear = "8,543";` on line 2
36+
// e) The expression `Number(carPrice.replaceAll(",", ""))` is converting carprice, which contains a comma, into a number.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,30 @@ console.log(result);
2323
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2424

2525
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
26+
27+
28+
// a) There are 6 variable declarations in this program:
29+
// which are:
30+
31+
// movieLength
32+
33+
// remainingSeconds
34+
35+
// totalMinutes
36+
37+
// remainingMinutes
38+
39+
// totalHours
40+
41+
// result
42+
43+
// b) There are 2 function calls in this program.
44+
45+
// c) Expression movieLength %60 represents remainder of division by 60.
46+
47+
// d) expression assigned to totalminutes means minutes in the movie by removing the remaining seconds and dividing by 60.
48+
49+
// e) Result variable represents the total time. A better name would be totalTime.
50+
51+
// f) Yes code will work for all the values of movielength. It'll always return the total time with no problems. But It's not working if movielength less than 60 seconds, more than 24 hours or negative values.
52+

0 commit comments

Comments
 (0)