← Back to challenges

Return Only the Integer

JavaScriptHardarrayssortingloopslanguage_fundamentals

Instructions

Write a function that takes an array of elements and returns only the integers.

Examples

returnOnlyInteger([9, 2, "space", "car", "lion", 16]) ➞ [9, 2, 16]

returnOnlyInteger(["hello", 81, "basketball", 123, "fox"]) ➞ [81, 123]

returnOnlyInteger([10, "121", 56, 20, "car", 3, "lion"]) ➞ [10, 56, 20, 3]

returnOnlyInteger(["String",  true,  3.3,  1]) ➞ [1]

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Calculate Determinant of a 2x2 Matrix