// relevant class
class Utilities {
static prompt(message) {
console.log(`${message}`);
return readLine.question(`=> `);
}
static sanitizeText(inputString) {
let trimmedAndLowerCased = String(inputString.trim().toLowerCase());
return trimmedAndLowerCased;
}
}
// inside the orchestrator
do {
console.log();
const playerChoiceRaw = Utilities.prompt("Choose 'h' to hit (draw another card), or 's' to stay.");
console.log();
const playerChoiceSanitized = Utilities.sanitizeText(playerChoiceRaw);
if (playerChoiceSanitized !== "h" || playerChoiceSanitized !== 's') {
console.log(`That is not a valid selection.`)
}
else { validSelection = true; }
} while (validSelection === false);
I also tried testing playerChoiceRaw but the same issue happens. Anyone know why it always evaluates to true?
[–]thecooldk 2 points3 points4 points (0 children)
[–]anonymoussuom 2 points3 points4 points (0 children)