202301142044 filter function

A filter function can be used to filter things out of a list.

Be careful of the return values

Be careful that in some languages, the filter function filters out elements, and on some other cases returns the list of valid values.

Example:
myList = [1,2,3,4,5,6]

Assume that function isEven returns true if a number is even.
const isEven = (num) => num % 2 == 0;

Now, Python List Filter Function will return [2,4,6] whereas the the JS List Filter Function will return [1,3,5]


Last update : 25 mai 2024
Created : 25 mai 2024