Final answer:
An IF statement in JavaScript is written using the syntax 'if (i == 5)'. It uses double equals '==' for comparison to check if the variable 'i' has a value equal to 5.
Step-by-step explanation:
To write an IF statement in JavaScript, the correct syntax is:
if (i == 5)
This is a conditional statement that checks whether the variable i is equal to the number 5. The double equals sign '==' is used for comparison. Here's an example of the full usage in a script:
if (i == 5) {
console.log('i is 5');
} else {
console.log('i is not 5');
}
In this code block, a message will log to the console stating whether i is 5 or not based on the condition. It is important to use the double equals '==' or triple equals '===' for comparison, not the single equals '=', which is used for assignment.