Why does
switch ("string") {
case "string":
const text = "Hello World!"
break
}
console.log(text)
return error: Uncaught ReferenceError: text is not defined ?
I don't understand why the variable text returns undefinded.
Why does
switch ("string") {
case "string":
const text = "Hello World!"
break
}
console.log(text)
return error: Uncaught ReferenceError: text is not defined ?
I don't understand why the variable text returns undefinded.
Copyright © 2021 Jogjafile Inc.
Because it is not in the same scope. Something like this should work: