AP Lab Switch not working?

Hi Anthony,

Sorry, I noticed this post this morning and brought it up with our engineers. Switch statements should work, but, guess what? You exposed a bug, but it wasn’t our fault! Our engineer discovered something in our code interpreter - a 3rd party had implemented some logic incorrectly. Our engineer fixed it, and it should go out with tomorrow’s deploy.

Also, I don’t think switch statements were ever in our code toolbox. You can use them because they are part of javascript. And they should work - and they actually do now in most cases, except for what our engineer found. If you’re interested here was the code he used to reveal the problem:

function doSwitch(x) {
  switch(x) {
    case 1:
      console.log('case 1');
      break;
    case 2:
      console.log('case 2');
      break;
    case 3:
      console.log('case 3');
      break;
    case 4:
      console.log('case 4');
      break;
    default:
      console.log('case 5');
  }
}

// This works
// Expected&Actual: case 3
doSwitch(3); 

// Either loop or switch is broken
// Expected: case 1 case 2 case 3 case 4 case 5
// Actual  : case 1 case 1 case 1 case 1 case 1
for (var i = 1; i <= 5; i++) {
  doSwitch(i);
}

Anyway, thanks for the find. But switch statements should work.