workshopper / scope-chains-closures

Javascript Scope Chains And Closures Workshop
ISC License
202 stars 142 forks source link

Issues with tests for scopes challenge #26

Open arku opened 8 years ago

arku commented 8 years ago

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 commented 8 years ago

The solution is below:

function foo() {
    var bar
}
LisaMieth commented 8 years ago

@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 commented 8 years ago

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

LisaMieth commented 8 years ago

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

domfarolino commented 7 years ago

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

NonPolynomial commented 7 years ago

@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 commented 7 years ago

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.