I can't get while loop about card suits to work


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript/lessons/loops/exercises/while?action=lesson_resume&link_content_target=interstitial_undefined

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
The console shows everything BUT a spade, and always starts with “Hearts”. I know hearts is the current card but I thought that my code line – currentCard = cards[randomNumber]; – was supposed to change that and I’m quite confused. I keep hitting run and I’ll get anything from “heart” to a list of hearts, diamonds, and clubs, but never a spade. Please help!! Thanks!

```

var cards = [‘Diamond’, ‘Spade’, ‘Heart’, ‘Club’];
var currentCard= ‘Heart’;
while (currentCard !== ‘Spade’) {
console.log(currentCard);

var randomNumber = Math.floor(Math.random() * 4);

currentCard = cards[randomNumber];
}

<do not remove the three backticks above>

#2

Wait nvm it’s supposed to do that… lol my bad


#3

So, issue resolved? No more questions about this exercise?


#4

yes I realized I had done it correctly …thanks. Sorry!


#5

No problem, just ensuring you understanding it now :slight_smile:


#6

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