Where is the mistake?


There is a mistake with random.number, but i can not find it.

function getUserChoise() {
var userInput = prompt('Rock,Paper,Scissors?');
userInput = userInput.toLowerCase();
if (userInput || 'rock' || 'paper' || 'scissors');
return (userInput);

function getComputerChoise() {
Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return 'rock';
case 1:
return 'paper';
case 2:
return 'scissors';

function determineWinner(userChoise, computerChoise) {
if (userChoise === computerChoise);
return 'tie';
if (userChoise === 'rock') {
if (computerChoise === 'paper');
return 'The computer won!';
} else {
return 'You won!';
if (userChoise === 'paper') {
if (computerChoise === 'scissors');
return 'The computer won!';
} else {
return 'You won!';
if (userChoise === 'scissors') {
if (computerChoise === 'rock')
return 'The computer won!';
} else {
return 'You won!';

function playGame() {
var userChoise = getUserChoise();
var computerChoise = getComputerChoise();
console.log('You Threw: ' + userChoise);
console.log('The copmputer threw: ' + computerChoise);
console.log(determineWinner(userChoise, computerChoise));



What does "mistake" mean, what is it doing that should be different?

Running your code results in:

11: Uncaught ReferenceError: randomNumber is not defined

Is that not explanation enough what you need to change? Or did you not encounter a message like that?

I don't know what's got you stuck, what is stopping you from moving on.
You have to explain what's going on.


The program must show me hwo won in the game. It should take random number from computer and compare to my answer. And than it show who is the winner. But instead of this it show me that ranomNumber is not defined, what i need to do to run this program as it should be?


Problem: it uses something that doesn't exist
Solution 1: create it
Solution 2: stop using it

This seems like something you can come up with yourself, so I'm still confused about what you want.

If you're saying that there's some problem ten steps into trying to fix the issue, then ask about that

Figure out what's stopping you from fixing it, figure out what you're missing, figure out what information allows you to continue. Then ask about that. If you just say "help" then .. well, there's no way to tell what you want.


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