switch - JavaScript | MDN

PHOTO EMBED

Tue Nov 02 2021 00:02:27 GMT+0000 (Coordinated Universal Time)

Saved by @bronxrock

/*
function functionName(condition) {
  switch(condition) {
  	case value1 :
      Statement1
  	case value2 :
      Statement2
 	default :
 	  Statement3   
  }
}  
*/

function isRose(cat) {
  switch(cat) {
    case 'rose' :
      return 'Hi, Rose!'
    case 'ted' :
      return 'Hi, Ted!'
    default :
      return `Hi, ${cat}!`
  }    
} 
content_copyCOPY

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch