6. I.D., Please Error on this task


I need to print out the three variables types but for somereason I keep receiving this error message.

"Oops, try again. Make sure to fill in the first console.log statement with typeof anObj"

I don't understand it cause my output is actually "object".

Could you please help me out ?


// complete these definitions so that they will have
// the appropriate types
var anObj = { job: "I'm an object!" };
var aNumber = 42;
var aString = "I'm a string!";

console.log(typeof(anObj)); // should print "object"
console.log(typeof(aNumber)); // should print "number"
console.log(typeof(aString)); // should print "string"


typeof doesn't require parentheses


console.log(typeofanObj); // should print "object"
console.log(typeofaNumber); // should print "number"
console.log(typeofaString); // should print "string"

I've tried it without it but that is runs on error as well.

I am quite sure the parentheses needed


You need a space between the typeof keyword and the variable you're checking.


look at the example, a space is required (ad mentioned by @toplearner)


Ahh thanks man indeed it does accepts it.

What I don't understand is why codeacademy accepts only this version.
When is Use this one
it also print out the object so the formula works properly only codeacademy does not accepted it for some reason ...

Or do you know any explanation ? Thanks man


well, you can read this stackoverflow answer, which goes a bit more in depth

although parentheses for typeof is not uncommon, its not the recommended way, which is why the exercise validated as such (i guess, the only person who can answer that question is whomever wrote the course)


ahh okay thanks friend


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.