Switch case - mmedrano9438/peripheral-brain GitHub Wiki
A switch statement evaluates an expression, checks its value against different cases, and executes statements based on the first matching case. If no case matches, it falls back to the default case.
const expr = 'Papayas';
switch (expr) {
case 'Oranges':
console.log('Oranges are $0.59 a pound.');
break;
case 'Mangoes':
case 'Papayas':
console.log('Mangoes and papayas are $2.79 a pound.');
// Expected output: "Mangoes and papayas are $2.79 a pound."
break;
default:
console.log(Sorry, we are out of ${expr}.
);
}