Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (zyi6):

JavaScript Help!!! Can someone help me out with if/else statements?

OpenStudy (zyi6):

@dan815 @iambatman @Nnesha

OpenStudy (zyi6):

I am trying to create a simple game of rock paper scissors. Can someone help?

jaynator495 (jaynator495):

Yes, yes we can

OpenStudy (tester97):

No Offense, But this is so easy to do. 5 Year old could read a book and do this. Why are you taking a java course if you can't make a simple Rock, paper, and scissor game?

OpenStudy (zyi6):

@Tester97, I am not taking a course. This is more of a hobby. I don't care if a 5 year old could do it, the point is that I'M the one that needs help. Now please, Help, or leave. @Jaynator495 , Will you help?

OpenStudy (tester97):

Zyi6, First off, if this was a hobby. You wouldn't be on a site that is poorly ran, and 80% of these people know nothing about programming. You are best off going to a real forum, and getting help.

jaynator495 (jaynator495):

Would you like this done through the js console, through a text box, or through a prompt and yes it is very easy -_-

OpenStudy (zyi6):

js console

OpenStudy (zyi6):

As of right now, I know that I need to start by declaring a function with 3 parameters, for rock, paper, and scissors, correct?

OpenStudy (tester97):

var options = ["paper", "rock", "scissors"], result = [" ties ", " beats ", " loses to "], i = Math.floor(Math.random() * 3), randomChoice = options[i]

jaynator495 (jaynator495):

^you forgot some things there, like what loses/wins/ties... and also the input XD

OpenStudy (zyi6):

var options = function (rock, paper, scissors) {} Does that look like the correct starting point?

OpenStudy (zyi6):

Hello?

OpenStudy (tester97):

Jay, I wasn't finish.

jaynator495 (jaynator495):

oh ._.

OpenStudy (tester97):

I just wanted to know if she could build off of that.

jaynator495 (jaynator495):

ohxD

OpenStudy (zyi6):

I am a he, thank you very much.

jaynator495 (jaynator495):

._. #Awkward

OpenStudy (tester97):

https://jsfiddle.net/DarkRiddles/3ym7erzg/

jaynator495 (jaynator495):

^O-o i didn't know about that website... *instantly bookmarks website*

OpenStudy (woodrow73):

There are many ways to go about the same project - I find first making the algorithm then diving into the code works quite well. I'm not well versed in JS, but for rocks paper scissors (rps) I'd say ``` 1. user inputs their choice of r, p, or s 2. computer randomly picks it's choice 3. a function is called that takes the user's and computer's picks, and it figures out if user wins, loses, or it's a draw 4. result is displayed to the user ```

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!