File tree Expand file tree Collapse file tree
Sprint-1/2-mandatory-errors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11This 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?
2+ We don 't want the computer to run these 2 lines - how can we solve this problem?
3+
4+ //The error message displayed by Node.js is:
5+ //Uncaught SyntaxError: Unexpected identifier 'is'
6+ //This is a syntax error. It occurs because JavaScript is trying to interpret an
7+ //English sentence as JavaScript code. After reading the word 'This', the JavaScript
8+ //parser expects a valid JavaScript operator. Instead, it encounters another variable
9+ //name, 'is', which is not valid in that position according to JavaScript's syntax rules.
10+ //As a result, the parser throws the error Unexpected identifier 'is'.
Original file line number Diff line number Diff line change 22
33const age = 33 ;
44age = age + 1 ;
5+
6+ //The error message displayed by Node.js is:
7+ //Uncaught TypeError: Assignment to constant variable
8+ //The error happens because const creates a variable whose value cannot be reassigned.
Original file line number Diff line number Diff line change 11// Currently trying to print the string "I was born in Bolton" but it isn't working...
2- // what's the error ?
2+ // what's the error?
33
44console . log ( `I was born in ${ cityOfBirth } ` ) ;
55const cityOfBirth = "Bolton" ;
6+
7+ //The error message displayed by Node.js is:
8+ //Uncaught ReferenceError: cityOfBirth is not defined
9+ //The error occurs because the variable 'cityofBirth' is used before it has been declared.
Original file line number Diff line number Diff line change 1- const cardNumber = 4533787178994213 ;
1+ const cardNumber = " 4533787178994213" ;
22const last4Digits = cardNumber . slice ( - 4 ) ;
33
4- // The last4Digits variable should store the last 4 digits of cardNumber
5- // However, the code isn't working
6- // Before running the code, make and explain a prediction about why the code won't work
4+ // The last4Digits variable should store the last 4 digits of cardNumber.
5+ // However, the code isn't working.
6+ // Before running the code, make and explain a prediction about why the code won't work.
77// Then run the code and see what error it gives.
88// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
9- // Then try updating the expression last4Digits is assigned to, in order to get the correct value
9+ // Then try updating the expression last4Digits is assigned to, in order to get the correct value.
10+
11+ //The error message displayed by Node.js is:
12+ //Uncaught TypeError: cardNumber.slice is not a function
13+ //The error occurs because slice() is a string method, but the variable 'cardNumber' is a number.
14+ //To get the last four digits, the number must be converted to a string.
Original file line number Diff line number Diff line change 11const 12 HourClockTime = "8:53pm" ;
22const 24 hourClockTime = "20:53" ;
3+
4+ //The error message displayed by Node.js is:
5+ //Uncaught SyntaxError: Invalid or unexpected token
6+ //This error happens because JavaScript does not allow variable names to start with a number.
You can’t perform that action at this time.
0 commit comments