No output in While loops exercise

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

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.

<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_lesson

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

```

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’);

<do not remove the three backticks above>

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)

Excellent…

Thanks a lot!

1 Like

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