<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Did you write a console.log outside the for loop on the last line of the program?
```
var cards = [‘Diamond’, ‘Spade’, ‘Heart’, ‘Club’];
var currentCard = ‘Heart’;
while (currentCard !== ‘Spade’) {
console.log(currentCard);
Let’s write a program that flips cards until we get a ‘Spade.’ Start by creating a variable named cards, and set it eqaul to this array:
['Diamond', 'Spade', 'Heart', 'Club']
Right under the array, create a variable named currentCard and set it equal to ‘Heart’.
This variable will hold the name of the card we just flipped. We are using ‘Heart’ as the first card.
Let’s utilize a while loop to do two things:
If the currentCard is not a ‘Spade’, then add a call to console.log to print the value of currentCard.
Then, create a random number between 0 and 3, and put it in a variable named randomNumber.
Then use the randomNumber to reassign currentCard to a new card from the cards array.
The while loop could like this:
while (currentCard !== 'Spade') {
console.log(currentCard);
var randomNumber = Math.floor(Math.random() * 4);
currentCard = cards[randomNumber];
}
Outside the while loop, on the last line of the program, use console.log to log that the program found a spade.
Run the code a few times to see the output changing. You can see the while loop guessing a card, then seeing if it is a Spade, over and over, until it finds one.
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Error message: Did you write a console.log outside the for loop on the last line of the program?
Written code will not be accepted, but it meets all the conditions and instructions for this task!
It seems that something is wrong with this task… I know that this course has not yet been released, but as I began to study it, I want to finish it!
Thanks for your help in advance!
```
var cards = [‘Diamond’, ‘Spade’, ‘Heart’, ‘Club’];
var currentCard = ‘Heart’;
while (currentCard !== ‘Spade’) {
console.log(currentCard);