Hello! I am working on my first beginner project with JS and am doing a rock, paper, scissors problem.
I am stuck on something so basic that it is frustrating (so apologies for that).
I am trying to figure out how I can print what has been 'user input' within my code (just to confirm), but can't seem to figure out this basic thing. Does it have to do with scope?
The console.log at the bottom throws me an error that userInput is not defined.
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'rock'){
console.log('Time to smash');
return userInput;
} else if (userInput === 'paper'){
console.log('You are gonna fold');
return userInput;
} else if (userInput === 'scissors'){
console.log('You better not run...');
return userInput;
} else {
console.log('You need to pick a valid choice yall!');
};
};
getUserChoice('scissors');
console.log(userInput);