Should this code work? I get a JS error
What's the JS error? Usually that should never happen so should always be filed as a bug.
Develop games in your browser. Powerful, performant & highly capable.
No, all is well. My fault. But what about this?
In the second example, after a 'Wait' the function has ended so the local variable no longer exists. So it has no value.