Rock paper scissors

Hi there, so this code here is working fine

const getUserChoice = userInput => { userInput = userInput.toLowerCase(); if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors' || userInput === 'bomb' ) { return userInput; } else { console.log('Error!'); } }; const getComputerChoice = () => { randomNumber = Math.floor(Math.random() * 3); switch (randomNumber) { case 0: return 'rock'; case 1: return 'paper'; default: return 'scissors'; } } //console.log(getUserChoice('Paper')); //console.log(getComputerChoice()); const determineWinner = (userChoice, computerChoice) => { if (userChoice = 'bomb') { return 'you won'; } if (userChoice === computerChoice) { return 'The game is a tie!'; } if (userChoice === 'rock') { if (computerChoice === 'paper') { return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'paper') { if (computerChoice === 'scissors') { return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'scissors') { if (computerChoice === 'rock') { return 'The computer won!'; } else { return 'You won!'; } } }; //console.log(determineWinner('paper', 'scissors')); // prints something like 'The computer won!' //console.log(determineWinner('paper', 'paper')); // prints something like 'The game is a tie!' //console.log(determineWinner('paper', 'rock')); // prints something like 'The user 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();

But I would like to be able to ask the user what is his choice actually instead of putting ‘scissors’ as a parameters

so I am trying to insert a prompt method(); inside of the getUserInput(); function like this:

const getUserChoice = userInput => { userInput = prompt ("rock, paper or Scissors, choosing Bomb is not permit...") userInput = userInput.toLowerCase(); if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors' || userInput === 'bomb' ) { return userInput; } else { console.log('Error!'); } }; const getComputerChoice = () => { randomNumber = Math.floor(Math.random() * 3); switch (randomNumber) { case 0: return 'rock'; case 1: return 'paper'; default: return 'scissors'; } } //console.log(getUserChoice('Paper')); //console.log(getComputerChoice()); const determineWinner = (userChoice, computerChoice) => { if (userChoice = 'bomb') { return 'you won'; } if (userChoice === computerChoice) { return 'The game is a tie!'; } if (userChoice === 'rock') { if (computerChoice === 'paper') { return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'paper') { if (computerChoice === 'scissors') { return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'scissors') { if (computerChoice === 'rock') { return 'The computer won!'; } else { return 'You won!'; } } }; //console.log(determineWinner('paper', 'scissors')); // prints something like 'The computer won!' //console.log(determineWinner('paper', 'paper')); // prints something like 'The game is a tie!' //console.log(determineWinner('paper', 'rock')); // prints something like 'The user won!' const playGame = () => { const userChoice = getUserChoice(); const computerChoice = getComputerChoice(); console.log('You threw: ' + userChoice); console.log('The computer threw:' + computerChoice); console.log(determineWinner(userChoice, computerChoice)); }; playGame();

but apparently prompt method is not defined at getUserChoice:

/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2
userInput = prompt (“rock, paper or Scissors, choosing Bomb is not permit…”)
^

ReferenceError: prompt is not defined
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:15)
at playGame (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:61:22)
at Object. (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:68:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)

what am I missing ?

thank you very much for your time in advance!!

I think Codecademy LE (learning environment) does not support prompt(), you could try on a website like jsfiddle or jsbin

oh god!!! Thank you very much for your answer , it actually does work on JSFiddle, thanks also for giving me this link!!!

I was getting crazy trying to find out why it would not work… I have not thought a minute that it could be Codecademy LE not supporting that method!!!