JavaScript while Loops error


#1

var cards = [‘Diamond’,‘Spade’,‘Heart’, ‘Club’];
var currentCard = ‘Heart’;
while (currentCard !== ‘Spade’) {
console.log(currentCard);
var randomNumner = Math.floor(Math.random() * 4);
currentCard = cards[randomNumber];
}
console.log(‘Found a Spade!’);

Above is the code that I wrote. Now I am getting check marks as if it is right but I am getting an error message in the console, randomNumber is not defined. I know there is something wrong but I don’t know how to fix it.

Thank you for any help,
Gaby


#2

check your spelling, you made a typo in a variable name


#3

Thank you so much. I feel so silly now.


#4

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