I understand local and global scope variables but my question is why doesn’t it show “ReferenceError: oopsGlobal is not defined”?
Because the tests aren’t running in strict mode and thus it will allow you to declare a variable without using
const and that variable will automatically be a global variable.
I’m guessing that the tests are actually running in strict mode and the
oopsGlobal variable is being defined in the tests with
let (or possibly
var) before your code is executed. So the tests are really just simulating non-strict mode (sometimes called “sloppy” mode). I was technically wrong when I said they weren’t running in strict mode. But as far as you are concerned when doing this challenge, they are.
I see. Thanks for replying!