Somebody please help me get my code working


I need this simple code for a assignment and i can't get it to work.

the error massage is:
Oops, try again. Your code returned 'scissors wins!' instead of 'undefined' when the inputs are scissors and rock

I want it to print out the random number, ComputerChoice, userChoice and who wins/if it a tie (like below)

I really need this code working because it is for an assingment due to 15-05-2016


In the last section it should start with else if(userChoice==="scissors"){ not just if.


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


If you read your code, can you see how choices scissors and paper leads to rock winning? Where does it go wrong and what should it be instead?


I can't find the mistake


Read your code, execute it in your mind. What happens when those are the choices?

If you're not finding it, then you should probably be spending more time with it, figuring out how it works.


This is my first ever code and i still quit don't know how everything works i was just hoping someone could guide me a bit


Sure but you know what's supposed to happen in a rock-paper-sciossors game. You know what comparisons need to be made.

Writing code is very deliberate. You've got to be able to say that, for this function, when these are the arguments, this is what the function will do.

Grab your pet rock and explain to it how your function gets the correct result when the arguments are what the error message complains about. You won't be able to, because your function doesn't get the correct result, but while doing that explanation, you'll run into the part where it goes wrong.


basically whats happening in the code is..(you need to know the rock paper scissor game....)

At first you make a random number.. with Math.random(); ..(you will see later Math.floor() is a usefull tool for Math.random()), then you prompt the user if he wants to chose rock paper or scissor... Then later you just make a bunh of if/else statements checking if user typed in paper, then do that, if user typed in rock do that... Understanding of If/Elseif/Else statements would probably make you understand what you exactly typed...


check your capitalizations on lines 14 & 15 @madsnov


I think i understand it, but i am very new to it :slight_smile: I have now done the challege and got it correctly but it still won't show userChoice or computerChoice. Yeah i just found those biff75 :slight_smile:


Can you show your code @madsnov :wink: ?


It's working now :slight_smile: