Skip to content

Commit 3802e7d

Browse files
committed
done with mandetory errors
1 parent bf6881c commit 3802e7d

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

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

Lines changed: 5 additions & 1 deletion
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;
3+
let age = 33;
44
age = age + 1;
5+
age = 1;
6+
7+
8+
// Will remove the constant varible and use the let keyword

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
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+
7+
8+
// The variable was at the bottom so we could not access it, so it has to be hoisted at the top

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
const cardNumber = 4533787178994213;
2-
const last4Digits = cardNumber.slice(-4);
2+
// const last4Digits = cardNumber.slice(-4);
3+
const last4Digits = String(cardNumber).slice(-4);
4+
console.log(last4Digits);
35

46
// The last4Digits variable should store the last 4 digits of cardNumber
57
// However, the code isn't working
68
// Before running the code, make and explain a prediction about why the code won't work
9+
// Answer: Missing console.log
710
// Then run the code and see what error it gives.
11+
// Error:we had TypeError: cardNumber.slice is not a function
812
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
13+
// "cardNumber.slice" must declared as a function, this is not what i thought, the difference is that the code is incomplete and so will add a function
914
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
15+
16+
17+
// After some research i found out that ".slice()" only works on strings so we have to convert the numbers into a string first
18+
// Also learned abour method chaining

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
1+
const HourClockTime12 = "20:53";
2+
const hourClockTime24 = "08:53";
3+
4+
// You cannot name a variable starting witha number

0 commit comments

Comments
 (0)