My 'if' statement inside switch doesn't work. Any advice for me?


Below is my game. When player answers 'Nih' a second prompt re: 'shrubbery' should happen. Instead I get default response at bottom every time. Does anyone know what is wrong here?

var answer = prompt("You walk across a bridge & a knight is there. What do you say to him?").toUpperCase();

    case 'Got a quarter?':
        if(answer == 'Got a quarter?' && answer.length ==4)         {
            console.log("Here you are");
        else {
           console.log("Stop bludging!");
    case 'Gimmee Shelter':
        console.log("Whooh whoooh");
    case 'Nih':
        if(answer == 'Nih'){
            prompt("Do you have a shrubbery?");
            console.log("We are the knights who say Nih!");
            console.log("Bugger off");
        console.log("I intend to jump");


Would be nice if you indent your code


It actually was indented when pasted in. When I go in to edit it the indents are still there so I can't change it. It's still readable enough for someone knowledgable to help me. As this is JavaScript and not Python, the results are not effected as white space isn't a problem. Thanks for the advice.


Ok, sorry did'nt mean it to be rude. Would have been easier to follow though without pasting it into a readable form


Remove the toUpperCase()
Why did you put that in anyway ??


I know you weren't being rude. :disappointed_relieved:
The to upper and to lower case options were in the instructions in the previous exercise. I think it was presented as an option rather than compulsory but that part got through okay previously so I think that wasn't the problem in this exercise. The code seemed to work okay to the end but for some reason skipped the if/else statements. I'll try removing it and see what happens and mess around with it on an editor.