6. I.D., Please

i don’t know what’s wrong with it?

In this lesson they want to make acquainted
with the typeof-operator
= https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operators/typeof
with which you can check
the Datatype of the associated Value of a variable

== assigning a string Value to the variable myVar ==
var myVar = “This is a string”;
and with the typeof-operator
you are able to acknowledge the Data-type
console.log( typeof myVar ); =>output==> string


I had to think about this for a while. First i tried this:

// 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”

And when that didn’t work, I ended up with this, which worked:

// 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"

Thanks @urtek n Sir @leonhard_wettengmx_n :slight_smile:

Big Mistake in my opinion. Paranthesis are important always

Here is the code that worked for me:

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

hope that helps.