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

One of the first steps of poetry analysis is to read a poem out loud. a. True b. False
What is the setting of "The Raven"? A. A dark December night in a museum with the speaker B. At night by the ocean with the speaker C. In a public library at mi
The formula to calculate population density is _______. a. land area number of populations b. number of populations land area c. number of organisms in a region
16 is 4% of what number?
State or federal codes that specifically apply to 4es are called: A. franchise law B. patent law C. 4 law D. tax law
5. Which of the following sets of conditions would result in the highest velocity for a sound wave traveling through air? A. A warm and humid day with a wind m
What is the meaning of incongruous
A novel that includes elements of mystery,horror, and strange occurrences is known as ? Sentimental burlesque gothic picaresque
One method of displaying the entire contents of a window is to ____ it.
What is the GCF of 8,18