The code doesn't work why?

It’s worth referring to MDN when you get stuck like this. A simple search online for ‘MDN typeof’

typeof is not a property or method of ‘g’

I see that netninja has tutorials specifically on objects

And a detailed 11 video course