o

Javascript If / Then branching statements

// if statement
if (condition) write code here;

// typical if statement
if (condition){
    write code here;
    write more code here;
}

// if else statement
if (condition){
    write code here;
    write more code here;
} else {
    write code;
    write code here;
    write code here;
    write code here;
}

// else if statements
if (condition){
     write code here;
     write more code here;
} else if (another condition) {
     write code;
     write code here;
     write code here;
     write code here;
} else if (another condition) {
    write code;
    write code here;
    write code here;
    write code here;
} else {
    write more code;
}

//switch-case statement
switch(choice){
    case 'choice1':
    write code here;
    write code here;
    break;
case 'choice2':
    write code here;
    write code here;
    break;
case 'choice3':
    write code here;
    write code here;
    break;
default:
    write code here;
    write code here;
}