One Pager Cheat Sheet
- Create a generic, parameter-accepting method that returns a string of the
data typeof the given input. - We can parse a given data's type by calling
Object.prototype.toString()and slicing/splitting the result.
This is our final solution.
To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.
xxxxxxxxxxfunction detectType(data) { return Object.prototype.toString .call(data) .slice(1, -1) .split(" ")[1] .toLowerCase();}OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment
You're doing a wonderful job. Keep going!
If you had any problems with this tutorial, check out the main forum thread here.


