Open main menu

Wikibooks β

JavaScript/Reserved words/if

< JavaScript‎ | Reserved words

The if keywordEdit

The if keyword stars a loop that executes until the condition is met.

ExamplesEdit

  The code
  var result = 1;

  if (result%2 == 0) {
    console.log(result + " is an odd number");
  } else {
    console.log("result + " is an even number");
  }
returns the following:
1 is an even number


See alsoEdit