Did you set the variable currentCard equal to 'Heart"?


#1


6) While Loops

Every time I click run, I get the following message:

Did you set the variable currentCard equal to 'Heart'?

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];
}

console.log('Found a Spade!');

:disappointed_relieved:
PLEASE HELP!!!


#2

Did you try refreshing the page and resubmitting? Or trying to submit on a different browser?


#3

Yes I refreshed, resubmitted, and submitted on a different browser. It still gives me the same error message.:disappointed:


#4

I'm pretty sure it's a bug on codecademy's end. ::crying_cat_face:


#5

I tried reporting the bug and they sent me an email saying someone will be with me shortly, but that was about a month ago. In addition, I can't progress to the next exercise. I'll try again, but thanks a lot for your help. :pray:


#6

I am sure you have tried this but its worth a shot if you want to go to another computer and try submitting it. I have heard it works sometimes but yeah this seems to be somewhat of a consistent problem in some lessons if not caused by infinite loops and such.


#7

Is it checkpoint 2 that you are trying to get past?


#8

Yes I did try this, on multiple computers even, but thanks for the tip.:relaxed:


#9

I don't really know what you mean by this, but I'm on the "Learn JavaScript" course (preview version) and I am on section 4, "Arrays and Loops". I'm on the "Loops" part of this section, exercise 6, "while loops", to be exact. Since I am getting an error message saying something is wrong (even though it isn't) I am not allowed to progress to the next exercise or section.:confounded:


#10

This is checkpoint 2 for the link that you originally posted:

Is this the one you are stuck at, is yours green or red?


#11

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];
}

console.log('Found a Spade!');

That is the code that I keep trying to run, but every time I get the same error message:

"Did you set the variable currentCard equal to ‘Heart'?"

I know I did that, but I tried so many times that I was asked if I wanted the correct code. I agreed and got the same code that I typed in. Also, I got the same error message each time I ran the code.


#12

It's red, I don't know why.:thinking::sob:


#14

It's red because your code doesn't do what that checkpoint is asking for.

Delete everything AFTER this line:

var currentCard = 'Heart';

#15

Thanks so much for your help. :grinning::blush::stuck_out_tongue_closed_eyes:


#16

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