Skip to content

Commit 0da6056

Browse files
author
Payman IB
committed
reverted to original state
1 parent 4ea61d3 commit 0da6056

File tree

4 files changed

+23
-45
lines changed

4 files changed

+23
-45
lines changed

Project-CLI-Treasure-Hunt

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
// I gives us a syntax error as str declared before.
3+
44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

7-
// function capitalise(str) {
8-
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
// return str;
10-
// }
11-
12-
// =============> write your explanation here :
13-
// as the variable in side the function has the same name as the function variable.
14-
// =============> write your new code here
157
function capitalise(str) {
16-
return `${str[0].toUpperCase()}${str.slice(1)}`;
8+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
1710
}
18-
console.log(capitalise("abcd"));
11+
12+
// =============> write your explanation here
13+
// =============> write your new code here;

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

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
// Predict and explain first...
2-
// error on line 11
3-
// error on line 17
4-
// Why will an error occur when this program runs? yes
2+
3+
// Why will an error occur when this program runs?
54
// =============> write your prediction here
6-
// decimalNumber is declared before and can not be declared again.
7-
// console.log(decimalNumber) should be console.log(convertToPercentage)
8-
// Try playing computer with the example to work ot what is going on
95

10-
// function convertToPercentage(decimalNumber) {
11-
// const decimalNumber = 0.5;
12-
// const percentage = `${decimalNumber * 100}%`;
6+
// Try playing computer with the example to work out what is going on
7+
8+
function convertToPercentage(decimalNumber) {
9+
const decimalNumber = 0.5;
10+
const percentage = `${decimalNumber * 100}%`;
1311

14-
// return percentage;
15-
// }
12+
return percentage;
13+
}
1614

17-
//console.log(percentage);
15+
console.log(decimalNumber);
1816

1917
// =============> write your explanation here
20-
// decimalNumber is declared before and can not be declared again.
21-
// console.log(decimalNumber) should be console.log(convertToPercentage)
2218

2319
// Finally, correct the code to fix the problem
24-
// =============> write your new code here
25-
function convertToPercentage(decimalNumber) {
26-
return `${decimalNumber * 100}%`;
27-
28-
}
29-
30-
console.log(convertToPercentage(0.5));
20+
// =============> write your new code here

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@
44
// this function should square any number but instead we're going to get an error
55

66
// =============> write your prediction of the error here
7-
// line 9 num is not defined.
87

9-
// function square(3) {
10-
// return num * num;
11-
//}
8+
function square(3) {
9+
return num * num;
10+
}
1211

1312
// =============> write the error message here
14-
// SyntaxError: Unexpected number
13+
1514
// =============> explain this error message here
16-
// 3 is not a variable for the function to use. It should be a variable name like num or n.
17-
// Finally, correct the code to fix the problem
1815

19-
// =============> write your new code here
16+
// Finally, correct the code to fix the problem
2017

21-
function square(num) {
22-
return num * num;
23-
}
24-
console.log(square(3));
18+
// =============> write your new code here

0 commit comments

Comments
 (0)