"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'){
  var randomNumber = Math.floor(Math.random()*4);
  currentCard = cards[randomNumber]; }

console.log('You found a ' + currentCard);


It seems like you should write console.log('You found a Spade!'); instead of use currentCard variable.


That seems silly. What if I wanted to change the program to be a different card....


Well I agree, but in this exercise you need to write that you found a spade card. I tried modifying that in your code and it worked, so maybe it was the problem.


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