Skip to content

Commit cf582c5

Browse files
authored
Update 4.js
Fix invalid variable names by renaming to start with letters instead of numbers.
1 parent 7f4d5bf commit cf582c5

File tree

1 file changed

+14
-2
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
1+
// Original variable names are invalid because variable names cannot start with a number
2+
// const 12HourClockTime = "20:53"; // This will cause a syntax error
3+
// const 24hourClockTime = "08:53"; // Also invalid for the same reason
4+
5+
// Fix:
6+
// Variable names must start with a letter, underscore (_), or dollar sign ($).
7+
// So we rename the variables to valid names below:
8+
9+
const hour12ClockTime = "20:53"; // Valid variable name for 12-hour clock time
10+
const hour24ClockTime = "08:53"; // Valid variable name for 24-hour clock time
11+
12+
// Explanation:
13+
// Variable names cannot begin with a number in JavaScript,
14+
// so prefixing them with a letter or underscore solves the problem.

0 commit comments

Comments
 (0)