Skip to content

Commit 0707b11

Browse files
Fix 4.js: rename variables to not start with a digit, add explanation
1 parent 5c39a47 commit 0707b11

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
const 12HourClockTime = "8:53pm";
2-
const 24hourClockTime = "20:53";
1+
const twelveHourClockTime = "8:53pm";
2+
const twentyFourHourClockTime = "20:53";
3+
4+
// Error: SyntaxError: Invalid or unexpected token
5+
// Cause: I originally named the variables 12HourClockTime and 24hourClockTime,
6+
// but JavaScript doesn't allow variable names to start with a number.
7+
// They have to start with a letter, an underscore, or a dollar sign.
8+
// The parser was reading 12 as a number and then got stuck on the "H".
9+
// Fix: Renamed them to twelveHourClockTime and twentyFourHourClockTime so they
10+
// start with letters instead of digits.

0 commit comments

Comments
 (0)