Multiple choice technology web technology

How do you write a conditional statement for executing some code if "i" is NOT equal to 5?

  1. if =! 5 then

  2. if (i != 5)

  3. if (i <> 5)

  4. if <> 5

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In JavaScript and C-style languages, the not-equal operator is !=. The correct syntax requires the variable, the operator, and the value to be in parentheses: if (i != 5). Option A reverses the operator (=! is invalid), option C uses Pascal-style <> which isn't valid in JavaScript, and option D omits both the variable and parentheses.