switch (Color) { case 'green': console.log('Color Green') break//if the condition is met, we stop the operator case 'yellow': console.log('Color yellow') break case 'red': console.log('Color red') break default://Default value console.log('undefined color') }
If necessary, you can process several conditions at once:
switch (Color) { case 'green': case 'yellow': console.log('Color green and yellow') break case 'red': console.log('Color red') break default://Default value console.log('undefined coloe') }