Let's test your knowledge. Click the correct answer from the options.
As the name suggests, Array filter filters array elements into a new array based on the condition specified in the callback function. Check out the code and try to understand what does the filter function does.
JAVASCRIPT
1const arr = [1,2,3,4,5,6,7,8,9,10];
2
3const filtered_arr = arr.filter((e)=>e%2 == 0);
4
5console.log(filtered_arr);
Click the option that best answers the question.
- Filters out even values only
- Filters out odd values only
- Filters out the multiples of two only