Selecting from Many Options with Switch Statements problem

function caseInSwitch(val) {
  var answer = val;
  // Only change code below this line
  
  switch ( val )
 {
   case 1:
      val = "alpha";
        break;
   case 2:
      val ="beta";
        break;
   case 3:
      val ="gamma";
        break;
   case 4:
      val = "delta";
        break;
  }
  
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);


// Change this value to test
caseInSwitch("alpha");

Not sure whats up with this?


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

Argh

You aren’t using switch correctly

function example(value) {
	var answer = '';

	switch (value) {
		case 1:
			answer = 'one';
			break;
		case 2:
			answer = 'two';
			break;
		default:
			answer = 'neither';
	}
	return answer;
}

console.log(example(2)); // two
1 Like