Skip to main content

--description--

You can use typeof to check the data structure, or type, of a variable. This is useful in debugging when working with multiple data types. If you think you're adding two numbers, but one is actually a string, the results can be unexpected. Type errors can lurk in calculations or function calls. Be careful especially when you're accessing and working with external data in the form of a JavaScript Object Notation (JSON) object.

Here are some examples using typeof:

console.log(typeof "");
console.log(typeof 0);
console.log(typeof []);
console.log(typeof {});

In order, the console will display the strings string, number, object, and object.

JavaScript recognizes seven primitive (immutable) data types: Boolean, Null, Undefined, Number, String, Symbol (new with ES6), and BigInt (new with ES2020), and one type for mutable items: Object. Note that in JavaScript, arrays are technically a type of object.

--instructions--

Add two console.log() statements to check the typeof each of the two variables seven and three in the code.

--hints--

Your code should use typeof in two console.log() statements to check the type of the variables.

assert(__helpers.removeJSComments(code).match(/console\.log\s*\(typeof[\( ].*\)?\)/g).length == 2);

Your code should use typeof to check the type of the variable seven.

assert(__helpers.removeJSComments(code).match(/typeof[\( ]seven\)?/g));

Your code should use typeof to check the type of the variable three.

assert(__helpers.removeJSComments(code).match(/typeof[\( ]three\)?/g));

--seed--

--seed-contents--

let seven = 7;
let three = "3";
console.log(seven + three);
// Only change code below this line

--solutions--

let seven = 7;let three = "3";console.log(typeof seven);
console.log(typeof three);