Skip to content

Commit e88bd15

Browse files
committed
recommitted all files in the mandatory-errors
1 parent 68e73cb commit e88bd15

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ console.log(`I was born in ${cityOfBirth}`);
66

77

88
// The error is ReferenceError: Cannot access 'cityOfBirth' before initialization
9-
// Answer: the correct variable is not called
10-
// I changed the console to print the actual variable value
9+
// Answer: I switched the order by declaring the const first before calling /printing

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ console.log(last4Digits)
1111
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1212

1313
//Prediction was the code would run successfully without error although with the wrong results due to absence of syntax errors in the file
14-
// Error returned: TypeError: cardNumber.slice is not a function
14+
// Error returned: TypeError: cardNumber.slice is not a function
15+
// Lesson learnt here; slice method is only available for strings or arrays not numbers
16+
// So converted the cardNumber into a string first

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
const 12HourClockTime = "8:53pm";
2-
const 24hourClockTime = "20:53";
1+
const twelveHourClockTime = "8:53pm";
2+
const twentyFourHourClockTime = "20:53";
3+
console.log(twelveHourClockTime);
4+
console.log(twentyFourHourClockTime);
5+
6+
// Error - SyntaxError: Invalid or unexpected token
7+
// lesson learnt - variables cannot start with a number

0 commit comments

Comments
 (0)