Skip to content

Commit 854e79e

Browse files
committed
Regular changes and adjustments done on sprint-1
1 parent e2cd279 commit 854e79e

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Sprint-1/2-mandatory-errors/1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ age = age + 1;
66
console.log (age);
77

88

9-
//I had to change the variable (conts) to (let) because a value assigned to (conts) can not be assign again, while with (let) it can be reassigned
9+
//I had to change the variable (const) to (let) because a value assigned to (const) can not be assign again, while with (let) it can be reassigned

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

Lines changed: 13 additions & 2 deletions
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;
@@ -11,12 +11,23 @@ console.log(`The percentage change is ${percentageChange}`);
1111

1212
// Read the code and then answer the questions below
1313

14-
// a) How many function calls are there in this file? Write down all the lines where a function call is made
14+
// a) How many function calls are there in this file? Write down all the lines where a function call is made:
15+
// 5 which are: 2 number(), 2 replaceAll() and 1 console.log()
1516

1617
// 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?
18+
// The error is on line 5, there is a missing comma that needs to seperate the arguments of replaceAll().Will fix it by putting the comma.
1719

1820
// c) Identify all the lines that are variable reassignment statements
21+
// Line 4 and 5
1922

2023
// d) Identify all the lines that are variable declarations
24+
// Line 1, 2, 7 and 8
2125

2226
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
27+
// The purpose is to:
28+
29+
// Remove formatting (commas) from a number string
30+
31+
// Convert the cleaned string into a real number
32+
33+
// Allow mathematical calculations to be performed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ console.log(result);
1212
// For the piece of code above, read the code and then answer the following questions
1313

1414
// a) How many variable declarations are there in this program?
15+
// 6 variable declaration. Which are movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result
1516

1617
// b) How many function calls are there?
18+
// 1 functions, which is Console.log
1719

1820
// c) Using documentation, explain what the expression movieLength % 60 represents
21+
// It represents the remainder expression. This means that the remainder operator returns the remainder left over when one operand is divided by a second operand.
22+
//
1923
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2024

2125
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
26+
// This command calculate the number of hours in the expression then extract the leftover minutes.
2227

2328
// e) What do you think the variable result represents? Can you think of a better name for this variable?
29+
// It creates a formated string. for example: 2:30:23. That is the movie duration formated in Hours:Minutes:Seconds.
30+
//Better names could be; FormatedDuration or MovieDuration or FormatedTime.
2431

2532
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
33+
// It would Works for positive integers only; not ideal for negatives, decimals, or proper formatting.

0 commit comments

Comments
 (0)