8.
What is the correct syntax for an if statement in JavaScript?
if (condition) { // code to be executed }
if {condition}; // code to be executed
if condition: // code to be executed
if (condition) // code to be executed
Correct: A
The correct syntax for an if statement in JavaScript is "if (condition) { // code to be executed }". The condition inside the parentheses should evaluate to either true or false. If the condition is true, the code inside the curly braces will be executed.