Keep the evens
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Keep the evens
Filter a list: keep some items and leave the rest out.
Start with an empty list, loop over nums, and .append() each number that passes the test n % 2 == 0. Return the new list after the loop has finished.
Write evens(nums) that returns a new list holding only the even numbers from nums, in the same order.
Click Run to see the output here.