Skip to content

Commit 7fdf45b

Browse files
committed
tidy up the format.
1 parent 52b508e commit 7fdf45b

6 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
//A: when user input the string. First index will be capitalised.
3+
// when user input the string. First index will be capitalised.
44

55
// call the function capitalise with a string input
66
// interpret the error message and figure out why an error is occurring
7-
//A: SyntaxError: Identifier 'str' has already been declared
87

98
//function capitalise(str) {
109
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
1110
// return str;
1211
//}
1312

1413
// =============> write your explanation here
15-
//"str" has been declared in function. In the local scope of original code, str declared again.
14+
// SyntaxError: Identifier 'str' has already been declared. "str" has been declared in function. In the local scope of original code, str declared again.
1615
//It caused the problem of redeclaration. Delete the "let" in local scope
1716
// =============> write your new code here
1817
function capitalise(str) {

‎Sprint-3/1-key-errors/1.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Why will an error occur when this program runs?
44
// =============> write your prediction here
5-
// A: There have the problem of redeclaration of the statement of decimalNumber. Local Scope should return to decimalNumber instead.
5+
// There have the problem of redeclaration of the statement of decimalNumber. Local Scope should return to decimalNumber instead.
66
// To print the code, the code should be console.log(decimalNumber)
77

88
// Try playing computer with the example to work out what is going on
@@ -16,7 +16,7 @@
1616
//console.log(decimalNumber);
1717

1818
// =============> write your explanation here
19-
//A: In the local scope, remove "const decimalNumber = 0.5". for the second line of local scope, 'const percentage' should be change to
19+
// In the local scope, remove "const decimalNumber = 0.5". for the second line of local scope, 'const percentage' should be change to
2020
//'decimalNumber' to avoid redeclaration and refer the correct variable. and return the function to 'decimalNumber'
2121
//finally console.log(convertToPercentage(0.5)) should be used to print the function.
2222

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//}
1111

1212
// =============> write the error message here
13-
//SyntaxError: Unexpected number
13+
// SyntaxError: Unexpected number
1414

1515
// =============> explain this error message here
16-
// the error caused by the wrong input for the variable "square(3)".
16+
// =============> the error caused by the wrong input for the variable "square(3)".
1717

1818
// Finally, correct the code to fix the problem
1919

‎Sprint-3/2-mandatory-debug/0.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1111

1212
// =============> write your explanation here
13-
// A: The calculation of the a * b should apply the the statement (`The result of multiplying 10 and 32 is ${multiply(10, 32)}`).
13+
// The calculation of the a * b should apply the the statement (`The result of multiplying 10 and 32 is ${multiply(10, 32)}`).
1414
// because code on local scope did not return to global. The global cannot apply the result of local.
1515

1616
// Finally, correct the code to fix the problem

‎Sprint-3/2-mandatory-debug/1.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
// A: The result of the function supposed to print 'The sum of 10 and 32 is 42' local scope should be return to sum.
3+
// The result of the function supposed to print 'The sum of 10 and 32 is 42' local scope should be return to sum.
44

55
//function sum(a, b) {
66
// return;
@@ -10,7 +10,7 @@
1010
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1111

1212
// =============> write your explanation here
13-
// A: the answer is undefined because of local scope code did not return to global (sum). semicolon of return need to be removed.
13+
// the answer is undefined because of local scope code did not return to global (sum). semicolon of return need to be removed.
1414
// Finally, correct the code to fix the problem
1515
// =============> write your new code here
1616
function sum(a, b) {

‎Sprint-3/2-mandatory-debug/2.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Predict the output of the following code:
44
// =============> Write your prediction here
5-
// A: The function supposed to print the last digit of 42, 105 and 806 which is 2, 5, 6. But the function could not run smooth
5+
// The function supposed to print the last digit of 42, 105 and 806 which is 2, 5, 6. But the function could not run smooth
66
// because of the variable "num" has been declared.
77

88
//const num = 103;
@@ -20,13 +20,13 @@
2020

2121
// Now run the code and compare the output to your prediction
2222
// =============> write the output here
23-
//A: The last digit of 42 is 3
23+
//The last digit of 42 is 3
2424
//The last digit of 105 is 3
2525
//The last digit of 806 is 3
2626

2727
// Explain why the output is the way it is
2828
// =============> write your explanation here
29-
// A: because num has been declared for 103 so the function could only get the last digit of 42, 105 and 806.
29+
// because num has been declared for 103 so the function could only get the last digit of 42, 105 and 806.
3030

3131
// Finally, correct the code to fix the problem
3232
// =============> write your new code here

0 commit comments

Comments
 (0)