0

When I use the Alert it's working. But When I use Console.log it doesn't print anything.

I tried switching the alert with the console.log

var myColor = ["Red", "Green", "White", "Black"];

for (i = 0; i < myColor.length; i++) {
    console.log(myColor);
}
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Dani
  • 1
  • 3

1 Answers1

0

You need to change the syntax a bit var myColor = ["Red", "Green", "White", "Black"];

for (i = 0; i < myColor.length; i++) {
    console.log(myColor[i]);
}

Alternately you can also use for...of loop to print colors

var myColor = ["Red", "Green", "White", "Black"];
    for(const color of myColor){
    console.log(color);
    }
BLACKMAMBA
  • 675
  • 2
  • 11
  • 28