Skip to content

Commit a6a5c70

Browse files
authored
Answering mandatory interprater file
1 parent 27662d6 commit a6a5c70

File tree

3 files changed

+59
-40
lines changed

3 files changed

+59
-40
lines changed

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

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,46 @@ console.log(`The percentage change is ${percentageChange}`);
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515

16-
// There are five functions calls.
17-
//carPrice.replaceAll(",", "")
18-
//Number(carPrice.replaceAll(",", ""))
19-
//priceAfterOneYear.replaceAll("," "")
20-
//Number(priceAfterOneYear.replaceAll("," ""))
21-
//console.log(`The percentage change is ${percentageChange}`)
16+
//Answer
17+
/* There are five functions calls.
18+
carPrice.replaceAll(",", "")
19+
Number(carPrice.replaceAll(",", ""))
20+
priceAfterOneYear.replaceAll("," "")
21+
Number(priceAfterOneYear.replaceAll("," ""))
22+
console.log(`The percentage change is ${percentageChange}`)*/
23+
2224

2325
// 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?
2426

25-
// When I run the code the error is "syntaxError: missing ) after argument list.
26-
// The error comes from line 5
27-
// The error occurs due to the missing coma between the two strings in the replaceAll() call.
28-
// Add coma between the two strings "priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));"
27+
//Answer
28+
/* When I run the code the error is "syntaxError: missing ) after argument list.
29+
the error comes from line 5
30+
The error occurs due to the missing coma between the two strings in the replaceAll() call.
31+
Add coma between the two strings "priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));" */
32+
2933

3034
// c) Identify all the lines that are variable reassignment statements
3135

32-
// there are to lines that state variable reassignment
33-
// carPrice = Number(carPrice.replaceAll(",", ""));
34-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
36+
//Answer
37+
/* there are to lines that state variable reassignment
38+
carPrice = Number(carPrice.replaceAll(",", ""));
39+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); */
40+
3541

3642
// d) Identify all the lines that are variable declarations
3743

38-
// There are fore variable declarations (line 1, line 2, line 7, line 8)
39-
// let carPrice = "10,000";
40-
// let priceAfterOneYear = "8,543";
41-
// const priceDifference = carPrice - priceAfterOneYear;
42-
// const percentageChange = (priceDifference / carPrice) * 100;
44+
//Answer
45+
46+
/*There are fore variable declarations (line 1, line 2, line 7, line 8)
47+
let carPrice = "10,000";
48+
let priceAfterOneYear = "8,543";
49+
const priceDifference = carPrice - priceAfterOneYear;
50+
const percentageChange = (priceDifference / carPrice) * 100;*/
4351

4452

4553
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
54+
//Answer
4655

47-
// carprice at line 1 is a string in order to calculate for the next line of codes you have to change the string ti number.
48-
// carPrice.replaceAll(",","")). delete the coma in between the number (e.g from "10,000" to "10000")
49-
// number() change the string to number ("10000" to 10000)
56+
/*carprice at line 1 is a string in order to calculate for the next line of codes you have to change the string ti number.
57+
carPrice.replaceAll(",","")). delete the coma in between the number (e.g from "10,000" to "10000")
58+
number() change the string to number ("10000" to 10000)*?

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,30 @@ 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-
// There are 6 variable declaration. "line1, line3, line4, line6, line7, line9"
15+
16+
/*There are 6 variable declaration. "line1, line3, line4, line6, line7, line9"*/
1617

1718
// b) How many function calls are there?
18-
// There is only one function call in this program "console.log(result);"
19+
20+
/* There is only one function call in this program "console.log(result);" */
21+
1922

2023
// c) Using documentation, explain what the expression movieLength % 60 represents
2124
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
22-
// % is called remainder. There fore movieLength % 60 represents the remainder of the movie length after dividing by 60.
25+
26+
/* % is called remainder. There fore movieLength % 60 represents the remainder of the movie length after dividing by 60. */
2327

2428
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25-
// totalMinutes are calculated by subtracting the remaining seconds from movie length and divided by 60 to get full minutes. this helps to get a number which divided by 60 with out reminder.
29+
30+
/* totalMinutes are calculated by subtracting the remaining seconds from movie length and divided by 60 to get full minutes.
31+
this helps to get a number which divided by 60 with out reminder.*/
2632

2733
// e) What do you think the variable result represents? Can you think of a better name for this variable?
28-
// result represents the total length of the movie in the form of Hour: minute: second
29-
// moveDurationFormatted can be a better name to replace result.
34+
35+
/*result represents the total length of the movie in the form of Hour: minute: second
36+
moveDurationFormatted can be a better name to replace result. */
3037

3138
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
32-
// Yes it works for all value. the only thing that is concerning is the validation of movieLength as the negative integer also gives value which is unrealistic.
39+
40+
/* Yes it works for all value. the only thing that is concerning is the validation of movieLength as the negative integer also gives value which is unrealistic. */
41+

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
onst penceString = "399p";
21

2+
onst penceString = "399p";
33
const penceStringWithoutTrailingP = penceString.substring(
44
0,
55
penceString.length - 1
@@ -24,14 +24,15 @@ 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"
28-
// 2. const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1);
29-
// This remove the p and left the string with only 399
30-
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
31-
// this code make sure that the string has 3 character. since one pound is equal 100 pence.
32-
// 4. const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2);
33-
// This code takes the number leaving the last 2 digits "in this case it takes 3 and leave 99"
34-
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2) .padEnd(2, "0");
35-
// This code takes the last digit from the string and also make sure that it has only two digits this gives a "99" value.
36-
// 6. console.log(`£${pounds}.${pence}`);
37-
// his gives a result with £ sign and separated by . " in this case it gives £3.99 "
27+
28+
/*1. const penceString = "399p": initialises a string variable with the value "399p"
29+
2. const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1);
30+
This remove the p and left the string with only 399
31+
3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
32+
this code make sure that the string has 3 character. since one pound is equal 100 pence.
33+
4. const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2);
34+
This code takes the number leaving the last 2 digits "in this case it takes 3 and leave 99"
35+
5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2) .padEnd(2, "0");
36+
This code takes the last digit from the string and also make sure that it has only two digits this gives a "99" value.
37+
6. console.log(`£${pounds}.${pence}`);
38+
his gives a result with £ sign and separated by . " in this case it gives £3.99 " */

0 commit comments

Comments
 (0)