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

Issues with tests for scopes challenge #26

Open
arku opened this issue Jun 22, 2016 · 7 comments
Open

Issues with tests for scopes challenge #26

arku opened this issue Jun 22, 2016 · 7 comments

Comments

@arku
Copy link

arku commented Jun 22, 2016

The challenge asks us to create a function foo and lexically scope a variable bar.
My solution was

var foo = function(){
  var bar;
}

However one of the tests fail. I think the above solution is also right and should be accepted.
Correct me if I am wrong.

@lenguyenthanh
Copy link

lenguyenthanh commented Sep 22, 2016

The solution is below:

function foo() {
    var bar
}

@LisaMieth
Copy link

@lenguyenthanh
I've been running into the same problem. I tried your solution but I get a syntax error. Same if I try
function foo(){
var bar;
}
Anybody any ideas what I'm doing wrong?

@lenguyenthanh
Copy link

@LisaKhadijah what is your syntax error? It looks correct.

@LisaMieth
Copy link

@lenguyenthanh
I don't get any specific error. If i run scope-chains-closures verify <myfile.js> all I get is the console message "syntaxerror".

@domfarolino
Copy link

@lenguyenthanh shouldn't @arun1595 solution be valid too though?

@NonPolynomial
Copy link

@lenguyenthanh the solution of @arun1595 is a valid kind to define a function.
this workshop shouldn't make a difference between function declaration and function expression.

@martinheidegger
Copy link
Collaborator

Assigning a function to a variable did not give it a name in Node versions prior to 6:

var foo = function () {}
console.log(foo.name)
console.log((function bar() {}).name)

So that, and I think that the validation is harder were the reasons why this doesn't work. A PR that fixes this would be good imo.

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

6 participants