question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selecting with Switch Statements missing code tags in tests

See original GitHub issue

Challenge Selecting from many options with Switch Statements has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


function caseInSwitch(val) {
  var answer = " ";
  // Only change code below this line
   switch(answer) {

      case 1:
      console.log("alpha");
      break;

      case 2:
      console.log("beta");
      break;

      case 3:
      console.log("gamma");
      break;

      case 4:
      console.log("delta");
      break;

    default:
   } 

  // Only change code above this line  
  return answer;  
}

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


```What to value to assign to var answer=" ";


Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

13reactions
StenNickcommented, Aug 8, 2016

function caseInSwitch(val) { var answer = val; //here need set answer = val and your code work!) // Only change code below this line switch (answer) { case 1: answer = “alpha”; break; case 2: answer = “beta”; break; case 3: answer = “gamma”; break; case 4: answer = “delta”; break;

}

// Only change code above this line
return answer;
}

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

1reaction
iameuanmackaycommented, Oct 14, 2016

Gah! I’m stuck, and not too sure what I’m missing on this… Any pointers, would be much appreciated…

`function caseInSwitch(val) { var answer = “”; // Only change code below this line

switch (val){ case “1”: answer = (“alpha”); break; case “2”: answer = “beta”; break; case “3”: answer = “gamma”; break; case “4”: answer = “delta”; break; }

// Only change code above this line
return answer;
}

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selecting from Many Options with Switch Statements can't ...
Your code so far function caseInSwitch(val) { var answer = "" ... Selecting from Many Options with Switch Statements can't pass the test....
Read more >
Switch Statement in C/C++ - GeeksforGeeks
The switch statement is a multiway branch statement. It provides an easy way to dispatch execution to different parts of code based on...
Read more >
Test for multiple cases in a switch, like an OR (||)
When the switch executes, it finds the first matching case statement and then executes each line of code after the switch until it...
Read more >
The "switch" statement - The Modern JavaScript Tutorial
A switch statement can replace multiple if checks. It gives a more descriptive way to compare a value with multiple variants.
Read more >
switch - JavaScript - MDN Web Docs - Mozilla
If no matching case clause is found, the program looks for the optional default clause, and if found, transfers control to that clause, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found