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

What motivated the United States to enter into a war with Spain?
what is the system of naming species using two words
Hayden is a manager at a landscaping company. He has 3 workers to landscape an entire park, Cody, Kaitlyn, and Joseph. Cody can complete the project in 8 h
768 is 60% of what number?
3 cans that store 9 tennis balls... Find the constant of proportionality & write a equation to represent the relationship PLEASE help
Sin(x-20)=1/root2 This question is confusing me.
In colonial Spanish America, which system was developed by the Spanish to support plantation agriculture? (1) barter (3) domestic (2) encomienda (4) guild
what is the system of naming species using two words
Marisol is painting on a piece of canvas that has an area of 180 square inches. The length of the Painting is 1 1/4 times the width. What are the dimensions of
does radius squared equal the diameter