How can I code the Magic 8 Ball exercise using the If/ else statements

*

Hi!
I am trying to figure out why the code will not populate a random number.
When I assign the eightBall a value, that particular conditional statement assigned to that number will populate but not randomly using the empty string ’ '.

You got your randomNumber perfectly (console.log this a couple of times to verify). The only problem is you’re comparing eightBall to numbers (and you made eightBall an empty string).

Hey! Thanks for replying. So the exercise instructed me to make eightBall an empty string so a random number could be selected.

When I actually do assign the eightBall a value, it does populate.

Ah, there’s either a typo in the instructions or you may be overlooking a detail in some step! If you want, share the link and somebody can verify.

1 Like

Oh sure!! Thank you, Here is the link! Codecademy export · GitHub

I actually figured it out and it worked! I completed the following syntax: let eightBall = Math.floor(Math.random() * 8;

A random number was consoled this way.

Thank you for your help.

1 Like

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