Skip to content

Commit 01932d2

Browse files
committed
sprint 1 section 2 - manadatory -error's all four tasks are done
1 parent 1771147 commit 01932d2

5 files changed

Lines changed: 20 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
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?

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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);

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

Lines changed: 3 additions & 0 deletions
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+
//The error was ReferenceError: cannot access `cityOfBirth` before initialization
5+
//by swapping the order of the two lines, the error will be fixed.
6+
47
console.log(`I was born in ${cityOfBirth}`);
58
const cityOfBirth = "Bolton";

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
const cardNumber = 4533787178994213;
1+
const cardNumber = "4533787178994213";
22
const last4Digits = cardNumber.slice(-4);
3-
3+
console.log(last4Digits);
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+
// i predict that the code doesn't work its because of two things, first i thought its case sensitive things
8+
// the second one is the type of variable, i thought the slice method is only for string type variable.
9+
710
// Then run the code and see what error it gives.
811
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
12+
/*
13+
I run the code and it gives me an error that says "TypeError: cardNumber.slice is not a function".
14+
so i checked the type of cardNumber using typeof operator and it returns number.
15+
*/
916
// Then try updating the expression last4Digits is assigned to, in order to get the correct value

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
const 12HourClockTime = "8:53pm";
22
const 24hourClockTime = "20:53";
3+
4+
// I believe this question is about what the error might be.
5+
// the error is syntaxError: and its because the variable name stats wit a number which is not allowed in Javascript.
6+
// removing the number or use the number next to the string/s.

0 commit comments

Comments
 (0)