Remove Nil from an Array

Published by Helen Yu in

Create a function to remove all nil values from an array.

Examples

remove_nil(["a", nil, "b", nil]) ➞ ["a", "b"]

remove_nil([nil, nil, nil, nil, nil]) ➞ []

remove_nil([7, 8, nil, 9]) ➞ [7, 8, 9]

Notes

N/A

Watch a quick demo on how Edabit works.