Multiple choice

What is the correct way to write a JavaScript array?

  1. var colors = "red", "green", "blue"

  2. var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")

  3. var colors = (1:"red", 2:"green", 3:"blue")

  4. var colors = ["red", "green", "blue"]

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

JavaScript arrays are defined using square brackets [] to enclose a comma-separated list of values.