Answers for "adding a default option in switch statements"

0

adding a default option in switch statements

function switchOfStuff(val) {

  var answer = "";
  
  switch(val){
    case "a":
    answer = "apple";
    break;
    case "b":
    answer = "bird";
    break;
    case "c":
    answer = "cat";
    break;
    default:
    answer = "stuff";
    break;
  }

  return answer;
}

switchOfStuff(1);
Posted by: Guest on December-16-2020

Code answers related to "adding a default option in switch statements"

Code answers related to "Javascript"

Browse Popular Code Answers by Language