← Back to challenges

Return Types

JavaScriptHardhigher_order_functionssortingarraysalgorithmsloops

Instructions

Create a function that takes an array and returns the types of values (data types) in a new array.

Examples

arrayValuesTypes([1, 2, "null", []])
➞ ["number", "number", "string", "object"]

arrayValuesTypes(["214", true, false, 2, 2.15, [], null])
➞ ["string", "boolean", "boolean", "number", "number", "object", "object"]

arrayValuesTypes([21.1, "float", "array", ["I am array"], null, true, 214])
➞ ["number", "string", "string", "object", "object", "boolean", "number"]

Notes

  • Remember Arrays & Null in JS are treated as object, hence the examples
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Luke, I Am Your ...