Question:

Which of the following is an invalid function name in JavaScript?

Show Hint

An easy mnemonic for variable and function naming: LUD\$} --- \textbf{L}etter, \textbf{U}nderscore (\texttt{\_}), or \textbf{D}ollar sign (\texttt{\$) must be the first character. Numbers are allowed anywhere except the first character.
Updated On: Jun 29, 2026
  • toCelsius()
  • sumNum()
  • 123Sum()
  • addNumbers()
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation



Step 1: Reviewing Identifier Naming Rules in JavaScript:

Function names in JavaScript are categorized as identifiers. Identifiers must follow these fundamental lexical rules:
• They can contain letters (A-Z, a-z), digits (0-9), underscores (_), and dollar signs ($).
Crucial Rule: They cannot begin with a digit (0-9).
• They are case-sensitive (myFunc and myfunc are different).
• They cannot be reserved keywords (such as var, function, class, return).

Step 2: Evaluating the Options:


(A) toCelsius(): Valid. Starts with a lowercase letter.
(B) sumNum(): Valid. Starts with a lowercase letter.
(C) 123Sum(): Invalid. It begins with numerical characters (123), which violates standard compilation lexical guidelines. This will trigger a syntax parsing error: Uncaught SyntaxError: Invalid or unexpected token.
(D) addNumbers(): Valid. Starts with a letter.
Was this answer helpful?
0
0