local scope illustration fix

this new structure illustrates the local scope to the block of d. the other structure was incorrect since c is still in scope
pull/41/head
Patrick Njuguna 6 years ago committed by GitHub
parent 93bbcb7f77
commit 35f9375648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -110,10 +110,10 @@ function letsLearnScope() {
let a = 'Python'
let b = 20
let d = 40
console.log(a, b, c) // Python 20 30
console.log(a, b, c, d) // Python 20 30 40
}
// we can not access c because c's scope is only the if block
console.log(a, b)
// we can not access d because d's scope is only the if block. c is still in scope
console.log(a, b, c) // JavaScript 10 30
}
letsLearnScope()
console.log(a, b) // JavaScript 10, accessible

Loading…
Cancel
Save