The commented code is considered for code validatation rather than just comment!
See original GitHub issue[Using Objects for lookup]
link for the challenge: https://www.freecodecamp.com/challenges/using-objects-for-lookups
Issue Description
In this challenge, I had to produce object version of switch statements. As I had to remember each ‘case’ member of switch to produce an object version, I had commented out the whole switch part and retyped the correct object version.
Though, I haven’t able to pass the test.
This is due to test check of
You should not use case, switch, or if statements
During commenting out the switch, it should not validate the usage of switch and consider it just as a comment.
Browser Information
- Browser Name, Version: Google Chrome
- Operating System: Windows 10
- Mobile, Desktop, or Tablet: Desktop
Your Code
// Setup
function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};
result = lookup[val];
/*
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
*/
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
Screenshot
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (10 by maintainers)
Top Results From Across the Web
Best practices for writing code comments - Stack Overflow Blog
Another misuse of comments is to provide information that should have been in the code. A simple example is when someone names a...
Read more >Commenting Source Code: Is It Worth It For Small ...
During programming, a developer may wonder whether the actual code is worth – more precisely, is large enough – to be commented. Thus,...
Read more >Code Tells You How, Comments Tell You Why - Coding Horror
Sometimes fewer comments makes for more readable code. Especially if it forces you to use meaningful symbol names instead.
Read more >Is commented out code really always bad? [duplicate]
Practically every text on code quality I've read agrees that commented out code is a bad thing. The usual example is that someone...
Read more >Classifying code comments in Java software systems
Several researchers investigated the usefulness of these comments, showing that thoroughly commented code is more readable and maintainable.
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
@Saif-Shines Yes, we are aware of this as an existing issue on the main website, and we do lack the infrastructure to have a strict parser if you may.
The only way currently would be to move forth by deleting the comments.
@SuperGeniusZeb Can you please open a new issue at https://github.com/freeCodeCamp/learn/issues ? Thanks a lot.