makayladroste9079 makayladroste9079
  • 12-11-2020
  • Computers and Technology
contestada

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.

Respuesta :

IfeanyiEze8899 IfeanyiEze8899
  • 14-11-2020

Answer:

function appendEvens( arr1, arr2) {

   for (let i in arr1){

       if (i%2 == 0){

           arr2.push(i);

       }

   }

}

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.

Answer Link

Otras preguntas

What is an extraneous solution to a radical equation
A main difference between gravitational and electric forces is that electrical forcesA. attract. B. repel or attract. C. obey the inverse-square law. D. act ov
Can anyone help me?!?!?!?!
which statement best summarizes the writers claim?
Which of the following would not help you become more health literate
which of the following has a slope of -3 and a y-intercept of -4 ? (A) y = -3x + 4 (B) y = 3x + 4 (C) y = 3x - 4 (D) y = -3x - 4
Describe the relationship between the area and the perimeter of two squares with a length of 2.5 and 5.
Need help with a math question
Nagrom the Dwarf Queen desires a tunnel through the mountain to connect her two wealthiest cities, Yram and Haras, which lie on either side. In an effort to det
5. Which equation is of a circle that has a center at (3,-2) and a radius of 9? A (x + 3)2 + (y - 2)2 = 9 B (x + 3)2 + (y - 2)2 = 81 C (x - 3)2 + (y + 2)2 = 9 D