Computer Choice: Part 1 ... Help!


#1

This is my code:

var userChoice = prompt("Do you choose rock, paper, or scissors?")
var computorChoice = Math.random();
console.log(computorChoice);

I'm not only looking for the answer but for an explanation of how/why it's done. I've been struggling with this for a while now, so some helpful feedback would be greatly appreciated.

Thanks! :wink:


#2

Hey @ethansolamito,

I can help you with some things. I'll start by showing the problem, but which is really minor. :smile:

You wrote "computorChoice" in both of these instead of "computerChoice". :smiley:

I'll tell you what the code does now. Get ready, it might be long :wink:.

-----------------------------------------------------------------

Let's start with the prompt here:

This prompt asks the user the question: "Do you choose rock, paper, or scissors?". :smiley:
You'll use this later in the next levels. :smile: This would be the core of how the game rock, paper, and scissors will go.


Next part: MATH.RANDOM(); !!

What the Math.random(); does is that the computer chooses a random number from 0 to 1. That will choose the computer's choice from rock, paper, and scissors. You'll also get to that later. :smile:


Next part:

What this does is print the random number that the computer had randomly chosen from 0 to 1, used by the Math.random. :smile:

Helped? Say "Thanks!" (Actually, you don't have to. :smile:)

Not helped? Still confused? Ask more questions! :smiley:


#3

Hey, @ragezapper

Thanks a bunch! I appreciate you explaining everything to me. I think I finally got these terms down, so I'll come to you next time I have some other questions regarding JavaScript.

I always did have a hard time spelling "computer". Now I really feel special. :laughing:

Thanks again!