It just says my syntax is incorrect, but I cannot find my error.

Replace this line with your code.
var colors = ["blue", "green", "red"];

for(i = 3; i< colors.length; i++){
var userChoice = prompt("what is your favorite color?");{
if (userChoice === "blue");{
console.log("My favorite color is " + colors[0]);
else if (userChoice === "green");{
console.log("My favorite color is " + colors[1]);
else if (userChoice === "red");{
console.log("My favorite color is " + colors[2]);
console.log("I don't have a favorite color");


Does the prompt function require braces? :wink:

Also, does the if conditional require a semicolon (;) before the braces open?

Try and rewrite your code.


jacon anderson will you help me bit not with this problem


Thank you so much, I was going crazy trying to find what was wrong.


Create your own thread :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.