Skip to content

Commit d7d36b1

Browse files
committed
Part3-Interpretation tasks. All were interpreted and answered.
1 parent 7e5508b commit d7d36b1

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

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

Lines changed: 6 additions & 5 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;
@@ -12,11 +12,12 @@ console.log(`The percentage change is ${percentageChange}`);
1212
// Read the code and then answer the questions below
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15-
15+
// 4, 4, 5, 5, 10 total 5 function calls.
1616
// 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?
17-
17+
// line 5 the replaceAll function requires two parameters, which must be separated by coma.
1818
// c) Identify all the lines that are variable reassignment statements
19-
19+
// There are variable reassignments statements on the lines: 4 and 5
2020
// d) Identify all the lines that are variable declarations
21-
21+
// There are variable declarations in the lines: 1, 2, 7 and 8
2222
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
23+
// The carPrice include the character , to made it a number, the comma is replaced by "" (nothing) and use the function Number()

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ 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-
15+
// Lines: 1, 3, 4, 9. Total 4
1616
// b) How many function calls are there?
17-
17+
// One, in the line 10
1818
// c) Using documentation, explain what the expression movieLength % 60 represents
1919
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
20-
20+
// Obtain as a result the reminder of the division of movieLength between 60
2121
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22-
22+
// The expression
23+
// find difference of the movieLength minus the remainingSeconds to obtain the amount of seconds exactly divisible by 60
24+
// do the division to obtain the total in minutes, which is the value assigned to totalMinutes
2325
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24-
26+
// The variable result represents the duration of the film, expressed with the format: HH:MM:SS
27+
// A better name could be movieDuration.
2528
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
29+
// It works for all values of movieLength. With long names, the number of hours can be hundreds.

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,22 @@ console.log(`£${pounds}.${pence}`);
2424
// Try and describe the purpose / rationale behind each step
2525

2626
// To begin, we can start with
27-
// 1. const penceString = "399p": initialises a string variable with the value "399p"
27+
// 1. Const penceString = "399p": initializes a string variable with the value "399p"
28+
// 2. Empty
29+
// 3. Const penceStringWithoutTrailingP initializes and assigned the value of function penceString.substring()
30+
// 4. First position of string
31+
// 5. End position of string taken with the length of the string minus the last character p using -1
32+
// 6. Close function penceString.substring
33+
// 7. Empty
34+
// 8. Const paddedPenceNumberString initializes and assigned the value of function penceStringWithoutTrailingP.padStart(
35+
// padding the string with "0" until it reaches the length 3
36+
// 9. Const pounds initializes and assigned the value of function paddedPenceNumberString.substring(
37+
//10. the number is extracted from the first character
38+
//11. to the length of the string except the last two characters.
39+
//12. End of function
40+
//13. Empty
41+
//14. Const pence initializes and assigned the value of function paddedPenceNumberString.substring()
42+
//15. using the length of the paddedPenceNumberString minus 2 for decimal (pens) values.
43+
//16. Padding with 00 until two characters
44+
//17. Empty
45+
//18. Print on console the value using the characters £ representing pounds and dot separating pens.

0 commit comments

Comments
 (0)