0
const speakEnglish = Boolean(prompt("Does this country speak English?"));
const fiftyMill = Boolean(prompt("Is the country below 50 million population?"));
const island = Boolean(prompt("Is the country an island?"));

if (speakEnglish && fiftyMill && island) {
  console.log("Sarah can live in this country.");
} else {
  console.log("Sarah will look for another country.");
}

I'm trying to get the else-statement to fire, but even after entering false into the prompt, the if-statement fires.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
  • 1
    a non empty string is always [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). – Nina Scholz Feb 20 '23 at 13:04
  • 1
    _"even after entering false in prompt"_ if you meant you are trying to input `false` typing that word as is, it will anyway be a string and will convert to `true` – Diego D Feb 20 '23 at 13:06

0 Answers0