Skip to content

Commit 20fb215

Browse files
Doing some error change that in section 2 of sprint 1
1 parent ae2a475 commit 20fb215

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
This is just an instruction for the first activity - but it is just for human consumption
2-
We don't want the computer to run these 2 lines - how can we solve this problem?
1+
/*This is just an instruction for the first activity - but it is just for human consumption
2+
We don't want the computer to run these 2 lines - how can we solve this problem?
3+
By comment both the line 1 and 2 out and the system should ignore these 2 line and see them as comment.
4+
*/

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
const age = 33;
4-
age = age + 1;
3+
let age = 33;
4+
age = ++age;
5+
6+
console.log(age);
7+
8+
/*By changing the variable from const to let since const variable value can't be change. I used prefix to increase the value and reassign it right away.*/

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33

44
console.log(`I was born in ${cityOfBirth}`);
55
const cityOfBirth = "Bolton";
6+
7+
/*the main the error here is that the console.log try to print the expression string template with the variable cityOfBirth. But since in the variable
8+
cityOfBirth declare after the console.log, so the console.log when try to involve the cityOfBirth will return error since the it doesn't exist.
9+
*/

Sprint-1/2-mandatory-errors/3.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const cardNumber = 4533787178994213;
2-
const last4Digits = cardNumber.slice(-4);
2+
const last4Digits = Number(cardNumber.toString().slice(-4));
3+
console.log(last4Digits);
4+
console.log(typeof last4Digits);
35

46
// The last4Digits variable should store the last 4 digits of cardNumber
57
// However, the code isn't working

Sprint-1/2-mandatory-errors/4.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
1+
const $12HourClockTime = "20:53";
2+
const $24HourClockTime = "08:53";
3+
console.log($12HourClockTime);
4+
console.log($24HourClockTime);
5+
6+
/*For this error I I fix by add $(money-sign)before the 12 and 24 variable name because in JS number can't be used to begin writing a variable name */

0 commit comments

Comments
 (0)