Skip to content

Commit 599853f

Browse files
answered and updated the explanation
1 parent c234195 commit 599853f

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Predict and explain first...
22

3-
43
// Why will an error occur when this program runs?
54
// =============> write your prediction here
65

7-
//1- The function is trying to declare the decimalNumber twice in the perameter and later as a new variable
8-
//2-console.log() is printing a variable in the local scope where it can't be accessed as it is inside the function
6+
//1- The function is trying to declare the decimalNumber twice in the perameter and later as a new variable
7+
//2-console.log() is printing a variable in the local scope where it can't be accessed as it is inside the function
98

109
// Try playing computer with the example to work out what is going on
1110

@@ -16,20 +15,17 @@
1615
// return percentage;
1716
// }
1817

19-
20-
21-
2218
// =============> write your explanation here
2319
/* The variable decimal Number has already been declared in the parameter
24-
and already is a local variable which can't be declared again causing a ReferenceError
20+
and already is a local variable which can't be declared again causing a SyntaxError
2521
As the decimalNumber inside the function we can't print it using the console.log() as it has no power to the local scope
2622
instead we can delete the second declaration and just leave the parameter as an input for the user
2723
Finally, correct the code to fix the problem */
2824

2925
// =============> write your new code here
3026
function convertToPercentage(decimalNumber) {
3127
const percentage = `${decimalNumber * 100}%`;
32-
return percentage;
28+
return percentage;
3329
}
3430

3531
console.log(convertToPercentage(0.5));

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
// You will need to come up with an appropriate name for the function
1515
// Use the MDN string documentation to help you find a solution
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
17-
function toUpperSnakeFormat(string){
18-
return string.toUpperCase().replaceAll(" ","_")
19-
17+
function toUpperSnakeFormat(string) {
18+
return string.toUpperCase().replaceAll(" ", "_");
2019
}
21-
console.log(toUpperSnakeFormat("hello there"))
22-
console.log(toUpperSnakeFormat("lord of the rings"))
20+
console.log(toUpperSnakeFormat("hello there"));
21+
console.log(toUpperSnakeFormat("lord of the rings"));

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function formatTimeDisplay(seconds) {
1515
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1616
}
1717

18-
console.log(formatTimeDisplay(61))
18+
console.log(formatTimeDisplay(61));
1919
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
2020
// to help you answer these questions
2121

@@ -32,11 +32,10 @@ console.log(formatTimeDisplay(61))
3232
// c) What is the return value of pad is called for the first time?
3333
// =============> "00"
3434

35-
3635
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3736
// =============> "1"
3837
// the last time, pad() is called with the remaining seconds which is value "1"
3938

4039
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
4140
// =============> "01"
42-
// the return value is 1 put as we are using pad wouldbe adding leading "0"
41+
// the return value is 1 put as we are using pad would be adding leading "0"

0 commit comments

Comments
 (0)