This script defines an array of numbers and filters out the even numbers.
It then squares the filtered even numbers and stores them in a new array.
Finally, it outputs the squared even numbers to the console.
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let newArr = arr.filter(function(num) {
return num % 2 == 0
}).map(function(num) {
return num * num
})
console.log(newArr)
Top comments (0)