hillqryc
hillqryc hillqryc
  • 06-07-2020
  • Computers and Technology
contestada

print out the last even number from an array of integers, if there is no even number, then print out a sentence indicating so.

Respuesta :

4143689097
4143689097 4143689097
  • 06-07-2020

Answer:

See the sample algorithm below.

Explanation:

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 22];

function last_even(arr) {

    for( i = arr.length-1; i >= 0; i--) {

         if (arr[i] % 2 == 0) {

              console.log(arr[i]);

              break;

         }

         else {

              console.log("There is no even number!");

         }

    }

}

last_even(array);

Ver imagen 4143689097
Answer Link

Otras preguntas

Describe the steps to graph y-80x=65 on the coordinate axes. Mention the labels on the axes and the intervals.
What is the value of x when 3x + 12 = x + 6 ?
EMERGENCY!!!!! No work needs to be shown, answers only!! Thank you!! 19 points!
Your town gets between 8 and 12 inches of snow each month from December to February. Estimate how much snow your town should get over the entire 3 months from D
In photosynthesis, electrons that travel through the electron transport chain in the thylakoid membrane come from BLANK . In cellular respiration, molecules of
5/12 times 4 simplified
how do particles move in a solid
which is a characteristic of an informational text A. characters B. dialogue C. facts D. conflict
Read the excerpt from a story. "Shhhh! Quiet down,” Micah whispered to his friends as they crouched behind his sofa in anticipation. "She’ll be here any minute
Is the temperature profile in the thermosphere more like that of the troposphere or the stratosphere?