Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scope Chains]: Non-accepted solution to exercise 4 (Closures) #1721

Closed
dawesome opened this issue May 1, 2016 · 2 comments
Closed

[Scope Chains]: Non-accepted solution to exercise 4 (Closures) #1721

dawesome opened this issue May 1, 2016 · 2 comments

Comments

@dawesome
Copy link

dawesome commented May 1, 2016

I think I have a correct solution to exercise #4 in the scope-chain-closures tutorial, but I'm also pretty new at node, so maybe I'm missing something?

  • node version: v4.4.3
  • npm version: 3.8.8

Error output

not ok 2 The structure is correct
  ---
    operator: equal
    expected:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
    actual:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
  ...

My Code

function foo() {
    var bar
    quux = 2
    return function zip() {
        var quux
        bar = 3
    }
}
@riyadhalnur
Copy link
Member

@dawesome Your solution is correct but the parser for this exercise expects the code to be structured a certain way (weird, I know). So, instead of returning the zip function immediately, return it after you declare it -

function foo() {
    var bar
    quux = 2
    function zip() {
        var quux
        bar = 3
    }
    return zip
}

You can check the discussion we had here about this problem #1569

@dawesome
Copy link
Author

dawesome commented May 2, 2016

Ah, okay! I went to look to see how to fix it, but it looks like there's already an open PR for it. Thanks!

workshopper/scope-chains-closures#23

@dawesome dawesome closed this as completed May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants