What I Want to Happen
I have a function called playRound() that returns a string and then increments a number. What should happen is that both of these are logged.
What is Happening Instead
When I console.log the function, only a number is logged. It seems to be one of the numbers that is being incremented. I have a separate function to find out what the numbers are after they're incremented so this isn't specifically what I'm looking for.
What I have Tried so Far
I tried creating a second function to log just the strings, but I couldn't get it to work without having to change some code on playRound().
I thought maybe there was a way to only log strings. Tried looking around the internet but I didn't find anything related to my question.
My Code
function playRound(playerSelection, computerSelection) {
if (playerSelection === "rock" && computerSelection === "rock") {
return "Draw!" && ties++;
} else if (playerSelection === "rock" && computerSelection === "paper") {
return "You lose!" && compScore++;
} else if (playerSelection === "rock" && computerSelection === "scissors") {
return "You win!" && myScore++;
} else if (playerSelection === "paper" && computerSelection === "paper") {
return "Draw!" && ties++;
} else if (playerSelection === "scissors" && computerSelection === "scissors") {
return "Draw!" && ties++;
} else if (playerSelection === "scissors" && computerSelection === "paper") {
return "You win!" && myScore++;
} else if (playerSelection === "scissors" && computerSelection === "rock") {
return "You lose!" && compScore++;
} else if (playerSelection === "paper" && computerSelection === "scissors") {
return "You lose!" && compScore++;
} else if (playerSelection === "paper" && computerSelection === "rock") {
return "You win!" && myScore++;
} else {
return "Invalid input! Try again!" && invalidScore++;
}
}
console.log("Here's the breakdown! Your Score, Computer Score, Ties, and the Invalid Score. ") + console.log(myScore, compScore, ties, invalidScore);
}
Please help me understand what I'm doing wrong, thank you.