JavaScript program that accepts an array as a parameter and returns an array of only even numbers extracted from the list
Posted by SceDev
Last Updated: February 17, 2024

Write a javascript program that accepts an array as a parameter and returns an array of only even numbers extracted from the list.

 function getEvenNums(arr) {
    return arr.filter(x => x % 2 === 0);
  }
  
  console.log(getEvenNums([3, 4, 5, 6, 7, 8, 9, 10]));