Introduction to JavaScript
Which of the following statements is true about where JavaScript code can run?
- B. Only inside databases
- A. Only in document editors
- E. Only within spreadsheets
- C. Both in web browsers and on servers
- D. Only in desktop applications
Syntax u0026 Comments
How do you write a single-line comment in JavaScript code?
- D. ** this is a comment **
- A. u003C!-- this is a comment --u003E
- E. ;; this is a comment
- C. // this is a comment
- B. ## this is a comment
Variables - let
Which keyword should you use to declare a variable that can be reassigned, such as let x = 5?
- B. vlet
- A. varible
- C. let
- E. vart
- D. const
Variables - const
What happens if you try to reassign a variable declared with const in JavaScript?
- A. The value updates silently
- B. The statement is ignored without any warning
- C. A syntax error is thrown
- D. The program renames the variable automatically
- E. It changes type automatically
Variables - var
Which JavaScript keyword declares a variable with function scope and allows re-declaration?
- A. var
- D. val
- C. vart
- B. let
- E. kon
Data Types - String
Given the code let name = 'Sara';, which JavaScript type does variable name hold?
- A. string
- C. boolean
- E. null
- B. number
- D. array
Data Types - Number
What value will typeof 42 return in JavaScript?
- C. 'boolean'
- D. 'function'
- B. 'number'
- E. 'object'
- A. 'string'
Type Conversion
What will JavaScript return for Number('25')?
- C. 25
- E. NaN
- B. '25'
- D. null
- A. 0
Type Conversion - toString
Which method converts a number to a string in JavaScript, such as (22).toString()?
- E. stringy()
- A. str()
- D. numberToString()
- C. toString()
- B. toText()
Operators - Arithmetic
What is the result of the JavaScript expression 3 + 4 * 2?
- E. 8
- B. 10
- D. 7
- A. 14
- C. 11
Operators - Comparison
Which operator checks for both value and type equality, such as 5 === '5'?
- B. !=
- A. ==
- C. equals
- E. =u003E
- D. ===
Operators - Logical
Which symbol represents the logical AND operator in JavaScript?
- C. ^^
- E. !u0026
- A. u0026u0026
- D. u0026
- B. ||
Operators - Logical
What is the result of false || true in JavaScript?
- D. false
- E. null
- C. true
- A. undefined
- B. 0
Operators - Bitwise
Which bitwise operator performs a bitwise OR between two numbers in JavaScript?
- A. u0026
- C. |
- B. ^
- E. u0026u0026
- D. ~
Keywords and Identifiers
Which of these is NOT a valid variable name in JavaScript?
- D. $result
- C. 2total
- E. userName
- B. _score2
- A. totalAmount