Better typeof
JavaScript
20 pts
Better typeof
Write a function typeName(value) that fixes the two traps of typeof:
- for
nullit returns"null", - for an array it returns
"array", - for everything else it returns
typeof value.
Then print typeName of every item in things with forEach. Expected output:
string number null array object undefined function
Checklist
- For normal values, return
typeof value. - Return
"null"for null. - Return
"array"for arrays. - Print the result for every item with
forEach. - The output shows the seven type names.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
