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.

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

freecodecamp

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
raisedadeadcommented, May 31, 2017

@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.

1reaction
raisedadeadcommented, Jun 8, 2018

@SuperGeniusZeb Can you please open a new issue at https://github.com/freeCodeCamp/learn/issues ? Thanks a lot.

Read more comments on GitHub >

github_iconTop 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 >

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