Heeeellp


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-NhsaT/2/5?curriculum_id=506324b3a7dffd00020bf661

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++){
console.log(colors[i]);
}
var userChoice = prompt("what is your favorite color?");{
console.log(userChoice);
}
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]);
}
else{
console.log("I don't have a favorite color");
};


#2

Does the prompt function require braces? :wink:

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

Try and rewrite your code.


#3

jacon anderson will you help me bit not with this problem


#4

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


#5

Create your own thread :slight_smile:


#6

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