Control structures 01: All of the lights


const light = 'green';
let action = '';

if (light === 'green') {
  action = 'Go';
} else if (light === 'yellow') {
  action = 'Slow down';
} else if (light === 'red') {
  action = 'Stop';
} else if (light === 'blue') {
  action = 'Pull over';
} else {
  action = 'Look at the sky';
}

Rewrite the previous code by using a switch statement.







Join the waiting list to see the solution