Skip to content

Commit 0aceeed

Browse files
committed
interpreting 0.js syntaxerror
1 parent 97ad770 commit 0aceeed

File tree

1 file changed

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

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// This is just an instruction for the first activity - but it is just for human consumption
22
// We don't want the computer to run these 2 lines - how can we solve this problem?
3-
/* comment out any code you do not want the machine to run by add two forward slash to a single line comment
4-
a single slash and a multiplication sign to both ends of a double line comment like this.
3+
4+
//The error found when running the code-> SyntaxError: Unexpected identifier 'is'.
5+
// syntax errors means the grammar rules of the language has not been applied. The instruction is written in plain english in a js file. It is not written in js syntax so js cannot parse it.
6+
7+
// An identifier just means:
8+
//A variable name
9+
//A function name
10+
// Or any word that isn’t a keyword
11+
// So "is" is being treated like a variable name — and the parser wasn’t expecting one at that position.
12+
13+
// //Solution:
14+
/*In this case, comment out the code by adding two forward slashes to a single line comment or
15+
a single slash and a multiplication sign to both ends of a double line comment like the one used for this comment.
16+
Other solutions could be checking:
17+
Missing quotes
18+
Missing operator
19+
Missing comma
20+
Or misplaced word
521
*/

0 commit comments

Comments
 (0)