Skip to content

Commit 34c796a

Browse files
committed
Added Answers to the questions about time conversion exercise. Added explanation for variable declaration, function calls, and expressions used in time conversion code.
1 parent bf8a890 commit 34c796a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 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;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ 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+
// Answer a: There are 6 variable declarations in this program: movieLength, remainingSeconds,totalMinutes,totalHours,remainingMinutes, and result.
28+
// Answer b: There is only one function call "console,log(result);".
29+
// Answer c: The expression movieLength % 60 uses the modules operator (%) which returns the remainder after dividing movieLength by 60.
30+
// This tells us how many remainder seconds are left after converting the total time into full minutes.
31+
// Answer d: This line calculates the total number of complete minutes in the movie after removing the leftover seconds. in first subtract the remaining seconds then divide the rest by 60 to convert seconds by minutes.
32+
// Answer e: result stores the formatted time in hours,minutes,seconds. A better name for this variable formattedTime,durationString,timeInHMS.
33+
// Answer f: yes, it works for all non negative integer values of movieLength

0 commit comments

Comments
 (0)