Kiyana I.

asked • 03/15/19

need help with this javascript code

Create an array that stores the names of five dogs.

Using a loop, evaluate an array index for even numbers. If the value is even, then output "dog name is a good dog", and if it is an odd number, "dog name is a bad dog."

HINT: you can use the Modulus. 

For example:

var x = 2;

var z = x % 2;

z will equal 0 if x is an even number

z will equal 1 if x an odd number

Starter code:

var mydogs= ["Fifi","Fido","Felix","Floppy","Flipper"]; 


for (i=0;i < mydogs.length;i++)

   if ( _____  ){ console.log(mydogs[i] + " is a good dog");}


1 Expert Answer

By:

Brian E. answered • 03/29/19

Tutor
4.9 (14)

Senior Full Stack JavaScript Developer (Node & React)

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.