On Code.org I'm trying to make a quiz that picks an answer based on what the user has placed in the array. However, regardless of what is in the array it always comes out false.
I've tried changing the statement to have more than one equal sign, I've tried doing it backwards and making the if statement "if list !== [list]" and I've tried removing the quotations. Nothing has worked. I've also tried defining the correctlist variable inside the if statement, but that still produces false.
var mylist = ["a". "b", "c"];
var correctlist;
if (mylist == ["a", "b", "c"]) {
correctlist = true;
} else {
correctlist = false;
}
console.log(correctlist);
It always comes out as false.
I expected the console log to state true but it always says false.
Aucun commentaire:
Enregistrer un commentaire