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

write 2.786 as a fraction in common form
What are the Applications of electronic polarization?
Which statement describes Chinese imperial policy toward foreign trade during the Ming Dynasty? Europeans were not allowed to enter China. Europeans were allo
How did women's rights influence the West? O Women had difficulty getting a divorce in the West, so there were more married people there. o Women had more right
PLSS HELP!! FIRST ANSWER GETS BRAINLIEST!!!! At a baseball game, the Rebelos orrdered 2 hot dogs and 3 cheese burgers and paid $20.00. The Caines ordered 2 hot
can y’all help me answer question 4 pleas e
Solve for h. h - 45 = -35A.h = -10B.h = 10C.h = -80D.h = 80 PLS HELP HURRY
have been and has been when to use each one of them ?​
If the pitcher throws four balls the batter _________. walks gets three more chances strikes out bunts
An example of an important physical site characteristic is a:.