Else if not running properly


#1



My code is running, but my else if (food === "CANDY") in my first case is not working. Entering candy results in the same console.log as berries or nuts.


var user = prompt("You are walking around in a mystical forest when you come across an elf. At first you think he is friendly, but he quickly grows 3 times his origional 3' height. What do you do? FEED HIM, FIGHT HIM or RUN AWAY?").toUpperCase();

switch(user) {
    case 'FEED HIM':
         var food = prompt("Do you have BERRIES, NUTS or CANDY?").toUpperCase();
         if(food === "BERRIES" || "NUTS") {
            console.log ("Forest Elves love those! Good job you may pass!")
            }
         else if(food === "CANDY") {
             console.log("The elf is insulted that you assume he likes candy like North Pole elves and locks you away in his prison. And then he eats the candy")
         }
         else {
            console.log("Well if you don't have any of those you are out of luck! The elf knocks you unconsious and you wake up in his prison")
            };
        break;
    case 'FIGHT HIM':
          var weapon = prompt("Do you have a sword or a gun?").toUpperCase();
        if(weapon === sword) {
            console.log("Good, that is the only weapon that can kill this kind of elf. Congratulations you win!")
            }
        else {
            console.log("Unfortionanly you do not have a weaspon powerful enough to beat the elf, he sqashes you in one try") 
        };
        break;
    case 'RUN AWAY':
        var run = prompt("Can you run fast?").toUpperCase();
        var hide = prompt ("Think you can find somewhere to hide?").toUpperCase();
        if(run && hide === "YES") {
        console.log("You got away this time, better not go back")
        }
        else {
            console.log("He found you! he doesn't want to loose you again so he locks you in his prison")
        };
        break;
    default:
        console.log("You have to type your answer correctly to understand, try again");
        break;
        };


#2

@byteninja08248,

console.log(    
    "You are walking around in a mystical forest\n"+
    " when you come across an elf. \n"+
    "At first you think he is friendly, \n"+
    "but he quickly grows 3 times his origional 3' height."
    );
var user =prompt(
    " What do you do? FEED HIM, FIGHT HIM or RUN AWAY?").toUpperCase();

switch(user) {
  case 'FEED HIM':
    var food = prompt("Do you have BERRIES, NUTS or CANDY?").toUpperCase();
    if(food === "BERRIES" || food === "NUTS") {
      console.log ("Forest Elves love those! Good job you may pass!");
    }
    else if(food === "CANDY") {
      console.log(
          "The elf is insulted that you assume he likes candy\n"+
          " like North Pole elves and locks you away in his prison.\n"+
          " And then he eats the candy");
    }
    else {
      console.log(
          "Well if you don't have any of those you are out of luck!\n"+
          "The elf knocks you unconsious and you wake up in his prison");
    }      
    break;
  case 'FIGHT HIM':
    var weapon = prompt("Do you have a sword or a gun?").toUpperCase();
    //weapon is UPPERCASE !!!!
    //prompt will return a "string" like "sword" or "gun"
    if(weapon === sword) {
      console.log(
        "Good, that is the only weapon that can kill this kind of elf.\n"+
        "Congratulations you win!");
    }
    else {
      console.log(
        "Unfortionanly you do not have a weaspon powerful enough\n"+
        " to beat the elf, he sqashes you in one try"); 
    } //an IF ELSE statement does NOT need semi-colon's ;
    break;
  case 'RUN AWAY':
    var run = prompt("Can you run fast?").toUpperCase();
    var hide = prompt ("Think you can find somewhere to hide?").toUpperCase();
    if(run ==="YES "&& hide === "YES") {
      console.log("You got away this time, better not go back");
    }
    else {
      console.log(
        "He found you! \n"+
        "he doesn't want to loose you again \n"+
        "so he locks you in his prison");
    }
    break;
  default:
    console.log("You have to type your answer correctly to understand, try again");
    //break; a =default= does not need a =break=
  }