I am step 13 of the project. I am having trouble running the play game function. I have followed the walk through as well and still get the same error.
Can someone explain to me what I’m doing wrong.
I am step 13 of the project. I am having trouble running the play game function. I have followed the walk through as well and still get the same error.
Can someone explain to me what I’m doing wrong.
Difficult to say without seeing the code. Please copy paste your code to the forum
The exercise url is the same for everyone, it will load the logged in users code, if i click on it, it will take me to the lesson and load my code.
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if(userInput === 'rock' ||userInput === 'paper' || userInput === 'scissors') {
return userInput;
}
else{
console.log(`Choose rock, paper or scissors`);
}
};
const getComputerChoice = () => {
randomNum = Math.floor(Math.random() * 3)
switch (randomNum){
case 0:
return 'rock'
break;
case 1:
return 'paper'
break;
case 2:
return 'scissors'
break;
default:
console.log(`Choose rock, paper or scissors`)
break;
}
};
const determineWinner = (userChoice, computerChoice) => {
if(userChoice === computerChoice){
return 'Tied Game'
}
if(userChoice === 'rock'){
if(computerChoice === 'paper'){
return 'Computer Won!';
}
else{
return 'You Won!';
}
}
if(userChoice === 'paper'){
if(computerChoice === 'scissors'){
return 'Computer Won!';
}
else{
return 'You Won!';
}
}
if(userChoice === 'scissors'){
if(computerChoice === 'rock'){
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();
there is just a syntax error.
const playGame = () => {
const userChoice = getUserchoice(‘scissors’);
const computerChoice = getComputerchoice();
both the function are not correctly capitalized
for instance getUserchoice = getUserChoice and getComputerchoice = getComputerChoice