Skip to content

Commit 647ad66

Browse files
committed
2-mandatory-errors are done.
1 parent 987c2ce commit 647ad66

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
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 adding // at the beginning of each line, we can turn them into comments.

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

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

3-
const age = 33;
3+
let age = 33;
44
age = age + 1;
5+
console.log(age);
6+
// let can allow us to reassign the value of a variable.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
33

4-
console.log(`I was born in ${cityOfBirth}`);
54
const cityOfBirth = "Bolton";
5+
console.log(`I was born in ${cityOfBirth}`);
6+
//The error is the order. JavaScript always reads the code from top to bottom.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
const cardNumber = 4533787178994213;
1+
const cardNumber = "4533787178994213";
22
const last4Digits = cardNumber.slice(-4);
33

44
// The last4Digits variable should store the last 4 digits of cardNumber
55
// However, the code isn't working
66
// Before running the code, make and explain a prediction about why the code won't work
7+
// First the code doesn't have console.log()to print the value of last four digits. Second, the slice can't be negative.
78
// Then run the code and see what error it gives.
89
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
10+
// The error is that slice is not a function. This is because cardNumber is a number and slice is a string method. To fix this, we need to convert cardNumber to a string before using slice.
911
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
12+
console.log(last4Digits);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
const 12HourClockTime = "8:53pm";
2-
const 24hourClockTime = "20:53";
1+
const twelveHourClockTime = "8:53pm";
2+
const twentyFourHourClockTime = "20:53";
3+
//variables can't start with a number. To fix this, we need to change the variable name to something that starts with a letter or an underscore.

0 commit comments

Comments
 (0)