No output in While loops exercise


#1

I have completed the exercise, but there is no output showing every time I run the code - just a blank black screen. Hard to fully understand this exercise without seeing the code output from the while loop.

https://www.codecademy.com/courses/learn-javascript/lessons/loops/exercises/while?action=lesson_resume&link_content_target=interstitial_lesson


var cards = ['Diamond', 'Spade', 'Heart', 'Club'];
var currentCard = 'Heart';

while (currentCard !== 'Spade') {
  console.log(currentCard);
  
  var randomNumber = math.Random() * 4;
  
  currentCard = cards[randomNumber];
}

console.log('The result is: Spade');


#2

The random() method is written in lowercase. The special class Math is written with a capital M.

Math.random()

To generate an integer index number, in the range 0 to 3, we pass the above into the Math.floor() method and multiply by 4. Be sure the 4 is inside the parentheses.

Math.floor(Math.random() * 4)

#3

Excellent...

Thanks a lot!


#4

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