Complete the code to check the type of variable value.
console.log(typeof [1]);The typeof operator returns the type of the variable. You need to pass the variable name value to it.
Complete the code to check if input is a string.
if (typeof input === [1]) { console.log("It's a string!"); }
The typeof operator returns a string describing the type, so you must compare it to the string "string" (all lowercase).
Fix the error in the code to correctly check if num is a number.
if (typeof num === [1]) { console.log("It's a number!"); }
= instead of ===.Use the strict equality operator === to compare the result of typeof with the string "number". The original code used a single equals sign =, which is an assignment, not a comparison.
Fill both blanks to create an object with keys as variable names and values as their types.
const types = {
name: [1],
age: [2]
};To get the type of variables name and age, use typeof name and typeof age respectively.
Fill all three blanks to create a function that returns true if val is a boolean.
function isBoolean(val) {
return typeof [1] [2] [3];
}= instead of comparison ===.boolean without quotes.The function checks if the type of val is exactly the string "boolean" using typeof val === "boolean".