Ad
  • Custom User Avatar

    I agree! It's the one that actually does what's asked instead of filtering out everything that's not a number.

  • Custom User Avatar

    I agree mostly, but the instructions do say that the incoming data is lists of non-nengative integers and strings. So the arrays have two types of data. So either way accomplishes the goal. However I do prefer to filter our strings for the reason mentioned that in the future should more data types be added then this function still does it's task without changes. Since the task was to remove strings and not return numbers. The top rated one would require rework to function correctly if other data types were added in the future, so I fail to see why it's "best practice"

  • Custom User Avatar

    I definitely agree, since the instructions say "with the strings filtered out", not "with only the integers returned". The other solutions seem to just be passing the test cases, as opposed to fully following the instructions. Perhaps a random test with different data-types could be added?

  • Custom User Avatar

    I like this approach in part because it filters out strings rather than returning numbers.
    This code can be used on arrays that contain more data types than just Strings and Numbers,
    and will return the array less the Strings.