Cards never change


#1

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

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

I need help~
I can pass the exercise, but when I run the code, its log is always “Heart” also it came with those red error messages as below.
Can any one help me to take a look where I got wrong? Thanks!

// Output looks like this
Heart
/home/ccuser/workspace/javascript_101_Unit_4_v2/cards.js:7
randomNumber = Math.floor(Math.radom()*4);
^

TypeError: Math.radom is not a function
at Object. (/home/ccuser/workspace/javascript_101_Unit_4_v2/cards.js:7:34)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3



var cards = ["Diamond", "Spade", "Heart", "Club"];
var currentCard = "Heart";
 
while(currentCard !== "Spade"){
  console.log(currentCard);
  
  var randomNumber = Math.floor(Math.radom()*4);
  currentCard = cards[randomNumber];
}

console.log("Found a Spade!");

#2

Have close look at

radom


#3

Hello old chap - probably because you’ve misspelled random.


#4

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