2.1k views
2 votes
Consider the following JavaScript code fragment:var greeting = function ( name ) {console.log ( name )}The best answer for what is wrong with this code is:Group of answer choices

1 Answer

7 votes

Answer:

name is a reserved word in JS and cannot be used as an identifier

Step-by-step explanation:

From the group of answer choices provided the only one that may be a problem would be using the word name as a parameter. Although name is not a reserved word per say in JS it is in HTML, and since JS targets HTML it could cause some errors. This however does not prevent this code from running correctly. JS does not require semicolons anymore, and the opening and closing braces for a body of code does not need to be on their own lines. Also, variable names are not Strings and do not need to be inside quotes, even for console.log()

User Arne Decker
by
4.5k points