Answer:
function countEvens(list) {
// IMPLEMENT THIS FUNCTION!
var even = [];
for(var i = 0; i < list.length; i++){
if (list[i] % 2 == 0){
even.push(list[i]);
}
}
return console.log(even)
}
var list = [ 17, 8, 9, 5, 20 ];
var count = countEvens(list);
Step-by-step explanation:
The programming language used is JavaScript.
An even variable is initialized, to hold the even variables within list.
A FOR loop loop iterates through all the elements in the list, an IF statement is used to check using the modulo division to check if the elements in the list are even.
The even elements are appended to the even list using .push() method.
Finally, the function returns the even list and outputs the list to the log using console.log(even) .
A list is created and the function is called.