4/6 Can't debug my code. Can someone assist?


#1

var user = prompt("are you ready for an epic adventure?").toLowerCase();

switch(user) {
case 'yes' :
console.log("Alright lets go");
break;

case 'no':
    console.log("Go home");
    default;

case 'maybe':
    console.log ("you have to be sure");
    break;

default:
    console.log("i dont understand ");
    break;

}

//what am i doing wrong here?


#2

these lines

case 'no':
    console.log("Go home");
    default;

should be

case 'no':
    console.log("Go home");
    break;

#3

oh gosh, probably went brain dead everytime I read that line. Thanks for pointing that out!


#4

var answer = prompt("you are wailking through a jungle when a tiger leaps out at you do you want to run, fight, or feed it kitty krackers").toUpperCase();
switch(answer) {
case 'run':
var P = prompt("are you fast?").toUpperCase();
var o = prompt("did you get a headstart?").toUpperCase();
var r = prompt("do you have alot of stamina?").toUpperCase();
if (p === 'yes' || o === 'yes' || r === 'yes'){
console.log("you sprint away leaving dirt behind you and never ever visit the jungle again");
}
else
{
console.log("the tiger gives a mighty leap and swallows you whole! YOU LOSE!");
}
break;
case 'fight':
var y = prompt("are you strong?").toUpperCase();
var q = prompt("Do you have any fighting gear with you?").toUpperCase();
if (y === 'yes' && q === 'yes'){
console.log("You easily kill the tiger! Great job! You win!");
}
else if (y === 'yes' || 'q === yes'){
console.log("you barely win I can't belive it YOU WON!");
}
else
{
console.log("say goodbye to your beloved life you lose!");
}
break;
case 'feed it kitty krackers':
var m = prompt("do you have kitty krackers with you?").toUpperCase();
var n = prompt("has the tiger stopped eating you").toUpperCase();
if (m === 'yes' && n === 'yes'){
console.log("you throw the kitty krackers far far away and always rembember if you go out into the jungle bring kitty krackers!");
}
else if (m === 'yes')
{
console.log("Oh no the tiger eats you and the kitty krackers and YOU LOSE!");
}
else
{
console.log("your attempt to feed it kitty krackers fails! YOU LOSE!");
}
break;
default:
console.log("please try again this time answering in run, fight, or feed it kitty krackers");
}

I tried to do it but it wouldn't work when i did feed it kitty krackers


#5

@doggy11 can you repost your code formatted
if you want to format your code when you paste it here you have three options

  1. select the code (after you paste it here) and press ctrl + k or
  2. select the code(after you paste it here) and press </> in the tools pane
  3. put this character ` three times at the begining and end of code

#6

I found out what was wrong with my brothers help but thanks rydan