I'm having a problem with the Rock Paper Scissors JavaScript Project

I’m having issues getting the Rock Paper Scissors project to run correctly. I’m at the point where I have put in the user input and the computer input. After some issues, I watched the help video, and even put down the exact code in the video. In the video, the code executes so the computer returns either “rock”, “paper”, or “scissors”. Here is the code I used, but when I run it, it comes back as “undefined”. What am I doing wrong?

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if(userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error’);
}
}

const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random * 3);
switch(randomNumber) {
case 0:
return ‘rock’;
case 1:
return ‘paper’;
case 2:
return ‘scissors’;
}
}

console.log(getComputerChoice());

Hello, @course5306306327. Welcome to the forum!

To use Math.random(), you need to include the empty ()'s. The empty ()'s call the function.

Also, for future posts where you need to paste in your code, please refer to the following:

1 Like