Skip to content

Adding a comment causes a valid answer to be wrong #43578

Closed

Description

@jsgm

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)

Activity

  1. added
    scope: curriculum
    status: waiting triage
    on Sep 26, 2021
  2. ojeytonwilliams commented on Sep 27, 2021

    @ojeytonwilliams
    Contributor

    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));
  3. added
    first timers only
    and removed
    status: waiting triage
    on Sep 27, 2021
  4. elfransat commented on Sep 27, 2021

    @elfransat

    Hi,

    Would I be able to have a go at this?

    Thanks

  5. gikf commented on Sep 27, 2021

    @gikf
    Member

    Hey @elfransat

    Issues are typically not assigned to anyone other than long-time contributors. You can read more about this at https://contribute.freecodecamp.org/#/FAQ?id=how-can-i-get-an-issue-assigned-to-me.

    Issues labelled with help wanted or first timers only are open for contributions.

    Please make sure you read our guidelines for contributing. Join us in our chat room or the forum if you need help contributing, our moderators will guide you through this.

  6. elfransat commented on Sep 27, 2021

    @elfransat

    hi @gikf

    This issue does appear to have the label first timers only as far as I can tell.

  7. gikf commented on Sep 27, 2021

    @gikf
    Member

    @elfransat, to use different words - you are free to contribute, if you are first-time contributor, and you don't need to ask 🙂

  8. added a commit that references this issue on Sep 28, 2021
    53fa130
  9. prashantaghoshal commented on Sep 28, 2021

    @prashantaghoshal
    Contributor

    Hi @gikf

    Am an absolute newbie and this is my first first-step in Open Source World. Have submitted a PR to fix this issue. many thanks for providing this for a beginner to take up. While submitting the PR, i just realized that i have not taken care of the localization versions - Chinese, Spanish etc. Will the update be pushed to these versions automatically? Else should i update those files too and put in another PR. I did not want to break anything with the localization.
    Thanks

  10. gikf commented on Sep 28, 2021

    @gikf
    Member

    Hey @prashantaghoshal

    files in other languages don't need (nor should they) to be changed manually. They will be updated using the translation workflow.

  11. prashantaghoshal commented on Sep 28, 2021

    @prashantaghoshal
    Contributor

    Hi @gikf

    Many Thanks for your review and guidance. have updated accordingly.

  12. added a commit that references this issue on Sep 29, 2021
    e4e74aa
  13. added a commit that references this issue on Oct 2, 2021
    75a5a7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    first timers onlyscope: curriculum

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions