JavaScript If...Else Statements

This tutorial provides a demonstration on If...Else Statements.

It should be noted that the comparison operator uses alphabetical order. This alphabetical order is based on the Unicode character encoding used by JavaScript.


  1. strA="Hello";
  2. strB="Goodbye";
  3. strC="After";
  4. if (strA < strB) {
  5. document.write(strA + ", " + strB);
  6. } else {
  7. document.write(strB + ", " + strA);
  8. }