Currently, I am facing a roadblock while attempting to conquer the Rock-Paper-Scissors challenge proposed by The Odin Project. Some confusion arises as my function playRound seems to be returning undefined when executed. Any insights or assistance in resolving this matter would be greatly appreciated.
const computerPlay = () => { //Randomly returns 'Rock', 'Paper', or 'Scissors'
let choices = ['rock', 'paper', 'scissors'];
let computerChoice = choices[Math.floor(Math.random() * choices.length)];
return computerChoice;
}
const playRound = (playerSelection, computerSelection) => {
playerSelection = playerSelection.toLowerCase;
if (playerSelection === computerSelection) {
return "It's a tie";
} else {
switch (playerSelection.toLowerCase) {
case 'rock':
switch (computerSelection) {
case 'paper':
return "You Lose! Paper beats Rock";
case 'scissors':
return "You Win! Rock beats Scissors";
}
case 'paper':
switch (computerSelection) {
case 'rock':
return "You Win! Paper beats Rock";
case 'scissors':
return "You Lose. Scissors beats Paper"
}
case 'scissors':
switch(computerSelection) {
case 'rock':
return "You Lose. Rock beats scissors";
case 'paper':
return "You Win. Scissors beats Paper"
}
}
}
}
const playerSelection = "rock";
const computerSelection = computerPlay();
console.log(playRound(playerSelection, computerSelection));