← Back to challenges

Filter out Strings from an Array

JavaScriptHardloopsarraysformatting

Instructions

Create a function that takes an array of non-negative integers and strings and return a new array without the strings.

Examples

filterArray([1, 2, "a", "b"]) ➞ [1, 2]

filterArray([1, "a", "b", 0, 15]) ➞ [1, 0, 15]

filterArray([1, 2, "aasf", "1", "123", 123]) ➞ [1, 2, 123]

Notes

  • Zero is a non-negative integer.
  • The given array only has integers and strings.
  • Numbers in the array should not repeat.
  • The original order must be maintained.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Error Messages