130k views
0 votes
Write the function appendEvens() which, given two arrays, adds all of the even elements from the first to the second. You may assume the second has enough space.

1 Answer

3 votes

Answer:

function appendEvens( arr1, arr2) {

for (let i in arr1){

if (i%2 == 0){

arr2.push(i);

}

}

}

Step-by-step explanation:

The defined javascript function "appendEvens" is a function that returns undefined. It accepts two arrays and pushes the even numbers from the first array to the second.

User Annish
by
6.2k points