It's a rock paper scissors game. The code in question is supposed to check user input and keep circling back while the input doesn't contain "rock", "paper", "scissors", OR if the length of input exceeds 8 characters.
Am I entering the operators correctly? I couldn't find any examples that look remotely like my code which makes me think that there's something I'm missing entirely.
I've tried moving the not operator around and it either ignores it or breaks and doesn't run.
function playerSelection () {
let playerInput = prompt("Type Rock, Paper, or Scissors: ")
let trimmedInput = playerInput.trim();
let lowerCaseInput = trimmedInput.toLowerCase();
let capitalizedInput = lowerCaseInput.charAt(0).toUpperCase() + lowerCaseInput.slice(1);
// check user input
while (!((capitalizedInput.includes("Rock") || capitalizedInput.includes("Paper") || capitalizedInput.includes("Scissors")) || (capitalizedInput.length <= 8))) {
playerInput = prompt("You may only enter 8 characters. Please choose Rock, Paper, or Scissors: ");
trimmedInput = playerInput.trim();
capitalizedInput = trimmedInput.charAt(0).toUpperCase() + trimmedInput.slice(1);
}
return capitalizedInput;
}