Javascript user input help

Hello!!!

I just finished the javascript exercise of the rock paper scissors game. At the beginning, it tells you to create a function for user input and to change it to all lower case no matter what the user puts in. but the exercise never has you actually put in a user input, its just randomly generated for the user when you run the script.

How do i find out where and what to use to ACTUALLY get user input? I want the user to be able to put in their choice as they choose and not let the computer do it for them. I found on google that window.prompt is what i’m supposed to use but doesn’t tell me much else and I just get errors.
This is my current code:

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

switch (Math.floor(Math.random() * 3)){
case 0:
return ‘rock’;
case 1:
return ‘paper’;
case 2:
return ‘scissors’;
}
};
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return ‘The game is a tie!’;
} // closing if tie clause!!!
else if (userChoice === ‘rock’) {
if (computerChoice === ‘paper’) {
return ‘Computer Won!’;
} else {
return ‘You won!’;
}
}
else if (userChoice === ‘scissors’) {
if (computerChoice === ‘rock’) {
return ‘Computer won!’;
} else {
return ‘You won!’;
}
}
else if (userChoice === ‘paper’) {
if (computerChoice === ‘scissors’) {
return ‘Computer won!’;
} else {
return ‘You won!’;
}
}
}
const playGame = () => {
const userChoice = getUserChoice(‘scissors’);
const computerChoice = getComputerChoice();
console.log('You threw: ’ + userChoice);
console.log('The computer threw ’ + computerChoice);
console.log(determineWinner(userChoice, computerChoice));
};

playGame();

I can’t exactly remember, but I think for this exercise the text implies that you will have user input, but expect you (for learning purposes at this point) to simply replace that would-be user input with a variable. That’s why it’s never explained how to actually get the input

1 Like

Hi, I have exactly the same issue. I know that the computer will generate a random value but I want to try and let the user input a value.
I think prompt is used with windows, and that its maybe a console method but I can’t find which one…