Basic JavaScript: Multiple Identical Options in Switch Statements
See original GitHub issueDescribe your problem and how to reproduce it: The example shows
switch(val) {
case 1:
case 2:
case 3:
result = "1, 2, or 3";
break;
case 4:
result = "4 alone";
}
Should not have result
should show return
with the example this is in basic javascript, this could be confusing for the user new to javascript to think they should use result
and not return
for output.
Add a Link to the page with the problem:
Tell us about your browser and operating system:
- Browser Name: Firefox
- Browser Version: 81.0.2
- Operating System: OSX Catalina
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Multiple Identical Options in Switch Statements - GitHub
Multiple Identical Options in Switch Statements ... Cases for 1, 2, and 3 will all produce the same result. Instructions. Write a switch...
Read more >Multiple Identical Options in Switch Statements. help - JavaScript
You can't put that kind of logic inside of switch statements. Your cases evaluate to either true or false then you are comparing...
Read more >Multiple Identical Options in Switch Statements - Stack Overflow
It's the first time I'm using switch statements in Javascript and I've found a lot of difficulties while learning this through FreeCodeCamp.
Read more >FCC - Multiple Identical Options in Switch Statements - CodePen
1. <!-- If the break statement is omitted from a switch statement's case, the following case statement(s) are executed until a break is...
Read more >Multiple Identical Options in Switch Statements - Scrimba.com
Our courses and tutorials will teach you React, Vue, Angular, JavaScript, HTML, CSS, and more. Scrimba is the fun and easy way to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I took a quick peek at those forum posts - the first one seems to come from trying to condense the case statements (which the tests ask specifically for 9 distinct statements). The rest come from following the example too closely and missing the change in variable names.
I do agree that these suggestions would alleviate that - but at the same time, we have a number of examples that do not directly match what the tests look for. And I fully support that, as it discourages blindly following the example and encourages the camper to think about how the example works.
Hiền SôKiu
Vào 15:55, Th 2, ngày 09 tháng 11 năm 2020 rajapandi_vijayakumar < notifications@github.com> đã viết: