reading-notes

Making Decisions in your Code - Conditionals

Reading

if…else

if (condition) {
  /* code to run if condition is true */
} else {
  /* run some other code instead */
}

else if

if (condition) {
  /* code to run if condition is true */
} else if (another condition) {
  /* code to run if condition is true */
} //exit if statement and run code below

Switch Statements

switch (expression) {
  case choice1:
    run this code
    break;

  case choice2:
    run this code instead
    break;

  // include as many cases as you like

  default:
    actually, just run this code
}