I am a total newbie to coding. I am currently learning javascript in
codecademy.com. As such, I happened to run this code in Chrome console:
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!');
Chrome is giving me some numbers before the output "Heart" as shown in the figure attached. The number becomes bigger as the code runs. My questions.
1. What does this number mean since its not part of my code?
2. Anything wrong with the code? I suspect something is wrong with it. Once I run it, the Tab on which am running and every new tab I try to open becomes unresponsive until I have to kill Chrome from the Windows task manager.
3. Suppose this code is an infinite loop which I suspect it is, how do I stop infinite loops in Chrome or in the console.
Running Windows 10 x86; Chrome Version 65.0.3325.181 (Official Build) (32-bit).