Home > front end >  Why does the typeof return undefined not string
Why does the typeof return undefined not string

Time:03-10

Why does the typeof return undefined not string

myFunction();
function myFunction(){
var address = '12345, Abuja,Nigeria'
}
console.log('the address is'   typeof  address)

CodePudding user response:

The variable address is not defined within the scope of where you are trying to use it. The variable only exists inside the "myFunction" function. If you move the console.log into the function block it should work as you expect.

  • Related