const getUserInput = (userInput)=>{ userInput=userInput.toLowerCase(); if(userInput===‘rock’||userInput===‘paper’||userInput===‘scissor’){ return userInput; }else { console.log(“your choice o f input is invalid”) }; }; console.log(getUserInput(‘ROCK’)) const getComputerChoice=() =>{ const number = Math.floor(Math.random()*3); switch(number){ case 0 : return ‘rock’; break; case 1 : return ‘paper’; break; case 2: return ‘scissor’ } } console.log(getComputerChoice()) const determineWinner = (userChoice,computerChoice)=>{ if (userChoice===computerChoice){ return ‘the game was a tie’; } if (userChoice===‘paper’){ if (computerchoice===‘rock’){ return ‘the user is the winner’ }else if(computerChoice===‘scissor’){ return ‘the computer is the winner’ } } if (userChoice===‘rock’){ if (computerChoice===‘paper’){ return ‘the computer is the winner’; }else if(computerChoice===‘scissor’){ return ‘the user is the winner’; } } if (userChoice===‘scissor’){ if (computerChoice===‘paper’){ return ‘the user is the winner’; }else if(computerChoice===‘rock’){ return ‘the computer is the winner’; } } } console.log(determineWinner(‘rock’,‘paper’)); const playGame= ()=>{ }
GUYS WHY CANT WE USE THE GETUSERINPPUT AND GET COMPUTER INPUT AS PARAMETERS FOR THE DETERMINE WINNER FUNCTION
I think this may be where the user got stuck. I am also stuck, I have even watch the walk-through video and cannot figure out where I went wrong. When I type in:
You need to delete the line I’ve commented on in your code. That return statement is executed as soon as your function starts to run, and terminates the function with the output you are seeing. I’ve made several additional comments regarding syntax errors. Please review, and let me know how it goes.