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 are the main four elements of socialization?​
Camila mixes 1/2 cup of yellow paint for every 1/4 cup of blue paint to make green paint. How many cups of yellow paint are needed for 1 cup of blue paint? cup
which artist created the first little debbie portrait in 1960?
I will give you brainliest . Help
what type of communication style is usually appropriate for evaluation or counseling interviews with employees?
what does the 5 layer model of the earth show?A. Compositional layers (What they are made of)B. Mechanical layers (physical properties)C. We know nothing about
please help I am having trouble with geometry
What does it mean that sponges are sessile?Question 1 options:They move along the bottom of ocean using flagellum.Sponges are lazy.They are anchored to one spot
Which inequality represents that 18 less than twice a number more than 35?
Simplify: 2/3 + 3/5 I will give brainliest if I can!