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.

Adding a comment causes a valid answer to be wrong

See original GitHub issue

Affected page

Adding a comment causes the result that should be correct to be returned as invalid in the following page:

JavaScript Algorithms and Data Structures > ES6 > Compare Scopes of the var and let Keywords

Your code

Code used:

function checkScope() {
  let i = 'function scope';
  if (true) {
    /* Block scope */
    let i = 'block scope';
    console.log('Block scope i is: ', i);
  }
  console.log('Function scope i is: ', i);
  return i;
}

Console result after running tests:

// running tests
The variable i declared in the if statement should equal the string block scope.
// tests completed
// console output
Block scope i is:  block scope
Function scope i is:  function scope

Expected behavior

The answer above should be taken as correct ✅

Screenshots

image image image

System

  • Device: Desktop
  • OS: Windows 10
  • Browser: Brave
  • Version: 1.29.81 Chromium: 93.0.4577.82 (Build oficial) (64 bits)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
elfransatcommented, Sep 27, 2021

Hi,

Would I be able to have a go at this?

Thanks

1reaction
ojeytonwilliamscommented, Sep 27, 2021

Thanks for the report @jsgm. The problem is that comments are not removed from (getUserInput('index')), only from the code variable.

A simple fix would be to re-write the test to use code. For example:

  assert(code.match(/(i\s*=\s*).*\s*.*\s*.*\1('|")block\s*scope\2/g));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it in bad form to answer a question with another user's ...
Yes, I think it would be. You would be receiving any rep for it at that point instead of the person who made...
Read more >
Questioning Strategies
Handling student responses to questions · Redirect: When a student responds to a question, the instructor can ask another student to comment on...
Read more >
Student: Answering Questions - Top Hat Support
Your professor may have chosen to not set a correct answer for some or all of the questions they have created. If this...
Read more >
Post & interact with comments - Computer - YouTube Help
YouTube Comments: Replying, filtering, & moderating If a video's owner has turned on comments, you can post comments and like, dislike, or rep....
Read more >
Avoid Bad Survey Questions: Loaded Question, Leading ...
Learn more about bad survey questions, loaded questions, leading questions, and mistakes to avoid if you want to write good surveys.
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