d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Basic Javascript Question > Rock, Paper Scissors
Add Reply New Topic New Poll
Member
Posts: 16,404
Joined: Mar 28 2009
Gold: 7.69
Jul 6 2015 04:15pm
Instructions:

1. Under your old code, use the same structure as the past two exercises and finish off your function.
2. We need to use the variables userChoice and computerChoice. Uncomment the first lines of the code by deleting /* on line 1 and */ on line 9, the variables are now active and can be called.
3. Call your function and pass in userChoice and computerChoice as your two arguments.
4. Press Save & Submit Code and your game should work! Congratulations!



I have been doing fine up until this last exercise. The error I keep getting when I try to run it:

Oops, try again. Your code returned 'paper wins' instead of 'undefined' when the inputs are scissors and paper

^ that error code comes up regardless if I choose rock, paper or scissors when I am prompted to choose


I've tried researching this issue as I assume I'm not the only person whose had this problem but I can't find any info.

This post was edited by Shakti on Jul 6 2015 04:27pm
Member
Posts: 16,404
Joined: Mar 28 2009
Gold: 7.69
Jul 6 2015 04:41pm
omfg lolol so lines 15-20 was the same as lines 32-37

ive spent the last 4 hours trying to figure that out. :wallbash: :wallbash:

maybe this will help someone. But i doubt it

This post was edited by Shakti on Jul 6 2015 04:42pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 6 2015 05:28pm
for starters, what are the results of these?

compare("paper", "paper");
compare("paper", "rock");
compare("paper", "scissors");
compare("rock", "paper");
compare("rock", "rock");
compare("rock", "scissors");
compare("scissors", "paper");
compare("scissors", "rock");
compare("scissors", "scissors");

second, on line 37 does it make any sense to you? choice1 is sisssors, so how can paper ever win?

This post was edited by carteblanche on Jul 6 2015 05:30pm
Member
Posts: 16,404
Joined: Mar 28 2009
Gold: 7.69
Jul 6 2015 05:30pm
Quote (carteblanche @ Jul 6 2015 06:28pm)
for starters, what are the results of these?

compare("paper", "paper");
compare("paper", "rock");
compare("paper", "sissors");
compare("rock", "paper");
compare("rock", "rock");
compare("rock", "sissors");
compare("sissors", "paper");
compare("sissors", "rock");
compare("sissors", "sissors");


i dont understand what youre asking. I'm literally only on my 3rd day of coding since highschool 7 years ago

This post was edited by Shakti on Jul 6 2015 05:32pm
Member
Posts: 16,404
Joined: Mar 28 2009
Gold: 7.69
Jul 6 2015 06:07pm
Quote (carteblanche @ Jul 6 2015 06:28pm)
for starters, what are the results of these?

compare("paper", "paper");
compare("paper", "rock");
compare("paper", "scissors");
compare("rock", "paper");
compare("rock", "rock");
compare("rock", "scissors");
compare("scissors", "paper");
compare("scissors", "rock");
compare("scissors", "scissors");

second, on line 37 does it make any sense to you? choice1 is sisssors, so how can paper ever win?


Yeah, that was the mistake i made because lines 15-20 and 32-37 were identical and thats what was causing my error.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 6 2015 06:47pm
Quote (Shakti @ Jul 6 2015 08:07pm)
Yeah, that was the mistake i made because lines 15-20 and 32-37 were identical and thats what was causing my error.


are you good then?
Member
Posts: 16,404
Joined: Mar 28 2009
Gold: 7.69
Jul 6 2015 06:51pm
Quote (carteblanche @ Jul 6 2015 07:47pm)
are you good then?


ya thanks
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll