Yet another Rock Paper Scissors Problem


#1

Once again, another person is having a rough time with rock paper scissors (sigh). Not sure how badly I botched this. Please help steer me right. Also, anybody have any other methods for remembering/learning Javascript? (link:https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors)

Thanks. My bad code is below. All help is much appreciated.

const getUserChoice = userInput => {
userInput = userInput.toLowerCase if (userInput === 'rock' || userInput === 'paper' === userInput === 'scissors');}
{return userInput;}
else {console.log('Error!');
     }
function getComputerChoice Math.floor(Math.random() Math.floor *3);
switch (randomNumber) {
  case 0:
    return 'rock';
  case 1:
    return 'paper';
  case 2:
    return 'scissors';
}
console.log(getComputerChoice());
function determineWinner userChoice(computerChoice())if (userChoice === computerChoice);
{return 'Tie!'};
if (userChoice === 'rock' || computerChoice === 'paper');
{return 'User won!';}
if (userChoice === 'paper' || computerChoice === 'scissors');
{return 'User won!';}
if (userChoice === 'scissors' || computerChoice === 'paper');
{return 'User won!';}
if (userChoice === 'bomb')
{return 'User won!';}
function playGame = () => {const userChoice = getUserChoice('rock');
                           const computerChoice = getComputerChoice();
                           console.log('You threw: ' + userChoice);
                           console.log('The computer threw: ' + computerChoice);};
playGame();

#2

There are a lot of syntax errors in your code.
Two main problems that I see are as follows:

The proper way to create a function:

// This function takes 2 input parameters
function functionName(parameter1, parameter2) {
    // Code to be executed
}

OR

// This function has no input parameters
function functionName() {
    // Code to be executed
}

The other one is if-else:

if (valuesToCheck) {
    // If true execute this
} else if (otherValuesToCheck) {
    // If true execute this
} else {
    // Code to execute when all "if" and "else if" statements are false
}

My code is just written so that it is easier to read, if you want to do it the way you have

it should be written as follows:

if (userChoice === 'rock' || computerChoice === 'paper')
{return 'User won!';}

Note that there is no semicolon ( ; ) at the end of the “if” line.

Once you have fixed those, you might want to check the logic of the if statements.

The one above says:
If the user choice is rock OR the computer choice is paper then the user wins.