-
-
Notifications
You must be signed in to change notification settings - Fork 335
Expand file tree
/
Copy path4.js
More file actions
13 lines (10 loc) · 872 Bytes
/
4.js
File metadata and controls
13 lines (10 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
const 12HourClockTime = "20:53";
// This line of code attempts to declare a constant variable named 12HourClockTime, but it results in a syntax error
const 24hourClockTime = "08:53";
// While testing the code, the following error appeared in console:
// SyntaxError: Invalid or unexpected token
// Why did this error occur? according to the MDN Web Docs: https://developer.mozilla.org/en-US/docs , a "SyntaxError: Invalid or unexpected token" occurs when JavaScript encounters code that doesn't follow proper syntax rules
// In this case, the error happens because JavaScript does not allow variable names to start with numbers. Variable names (also called identifiers) must begin with a letter, underscore (_), or dollar sign ($)
// How to fix the error:
const hour12ClockTime = "20:53";
// These version follow JavaScript naming rules and will execute without errors