Selecting from Many Options with Switch Statements problem

Selecting from Many Options with Switch Statements problem
0

#1
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?


#2

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

Argh


#3

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

#4

You need to read the instructions again (below) carefully. It tells you to set answer. You will notice answer is what gets returned at the end of the function, so why would you assign something to val?

Write a switch statement which tests val and sets answer for the following conditions: