javascript if statements, ternary operator and switch statements