-
Notifications
You must be signed in to change notification settings - Fork 1k
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 problem should be updated to ES2015 #296
Comments
I agree. However, including the block scope feels a bit difficult. |
Yeah, having taught this to others I think removing function scope is okay for what |
@ledsun here's a bit of code based on the scope problem to show let [a, b, c] = [1, 2, 3]
console.log(`a: ${a}, b: ${b}, c: ${c}`)
{
let [b, c] = [5, 6]
console.log(`a: ${a}, b: ${b}, c: ${c}`)
{
let b = 8
console.log(`a: ${a}, b: ${b}, c: ${c}`)
{
let [a, c] = [7, 9]
console.log(`a: ${a}, b: ${b}, c: ${c}`)
{
let [a, c] = [1, 8]
console.log(`a: ${a}, b: ${b}, c: ${c}`)
}
console.log(`a: ${a}, b: ${b}, c: ${c}`)
}
console.log(`a: ${a}, b: ${b}, c: ${c}`)
}
console.log(`a: ${a}, b: ${b}, c: ${c}`)
}
console.log(`a: ${a}, b: ${b}, c: ${c}`) Running
Putting this into problem form: let [a, b, c] = [1, 2, 3]
{
let [b, c] = [5, 6]
{
let b = 8
{
let [a, c] = [7, 9]
{
let [a, c] = [1, 8]
}
}
}
} Then solution form: let [a, b, c] = [1, 2, 3]
{
let [b, c] = [5, 6]
{
let b = 8
console.log(`a: ${a}, b: ${b}, c: ${c}`)
{
let [a, c] = [7, 9]
{
let [a, c] = [1, 8]
}
}
}
} Gives the proper solution.
Of course the preamble still needs to be reworked. |
The scope exercise defines scope in javascript before the ES2015 standard. Being 5 years later the ES2015 is probably the most used javascript now.
javascripting
global
andlocal
scopes are referencedInclude
block
scope. Renamelocal
scope tofunction
scope.Usage is defined at these two links from w3schools for let and const,
The text was updated successfully, but these errors were encountered: