← Back to challenges

What's the Data Type?

JavaScriptHardvalidationlanguage_fundamentals

Instructions

Create a function that returns the data type of a given variable. These are the eight data types this challenge will be testing for:

  • Array
  • Object
  • String
  • Number
  • Boolean
  • Null
  • Undefined
  • Date

Examples

dataType([1, 2, 3, 4]) ➞ "array"

dataType({key: "value"}) ➞ "object"

dataType("This is an example string.") ➞ "string"

dataType(new Date()) ➞ "date"

Notes

Return the name of the data type as a lowercase string.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Max Adjacent Product