Click to See Complete Forum and Search --> : syntax for an if statement


Help
05-16-2003, 02:13 AM
is this the correct syntax for an if statement?

if myVariable == 10{
alert("Your variable is equal to 10");}

vickers_bits
05-16-2003, 03:41 AM
parenthesis

if (myVariable == 10){
alert("Your variable is equal to 10");}

AdamGundry
05-16-2003, 03:52 AM
If you are only executing one statement, you don't need the curly braces:
if (myVariable == 10) alert("Your variable is equal to 10");

Adam

Charles
05-16-2003, 04:42 AM
And if the statement comes at the end of a line, then you do not need the semi-colon.

if (myVariable == 10) alert("Your variable is equal to 10")