Switch cases - slight error



Hey CC Squad, I've got another question. In the 'Yeah' case after I've entered 'yeah' twice, I never return the value of "Well play on playa!".

Any clues?
Cheers guys

var user = prompt("YEAH AHAA YEAH AHAA AHAA! Bad Bad Boy come with me?").toUpperCase();

    case 'YEAH':
       var yeahReply = prompt("Oh really?").toUpperCase(); {
           if (prompt === 'Yeah' && 'Yeah' ) {
               console.log("Well play on playa!");
               } else if (prompt === 'Maybe' || 'No') { 
                   console.log('Ahh ok, fair enough');
    case 'NO':
        console.log("Boo, spoil sport!");
    case 'WHAT?':
        console.log("It's a song, by these Swedish chicks from the, you know what, never mind");
        console.log("Its a song. Midi, Mmmmrrnnnnn....and Efti. Can't remember the second girl's name");


In the 'Yeah' case after I've entered 'yeah' twice, I never return the value of "Well play on playa!"

There's an error .. (Even overall code is passed by CC editor)

if (prompt === 'Yeah' && 'Yeah' )

prompt is not a variable.
It should be yeahReply that should be compared!

I hope it helps!


Hey, that makes sense @greentreemee i gave that a go, but still even if i reply yeah both times i only get the else if response. I have a feeling that I may need a third prompt to be able to respond 'Yeah' twice in order to get the 'Yeah' && 'Yeah' response of 'Well play...'.

I'll play around with it


Because you're making a compound condition using &&.
It simply means that to execute that block of code, two condition should be true.
It should be 'Yeah' and also'yeah'.
Even you use || operator, It will let you execute that block but then again your code will throw an error saying You did not used && operator.
To deal with that you can add a new storyline that'd take two essential conditions (You can combine them using &&)

I hope it makes your doubt more clear! :slight_smile:


Ahhh i changed one slight thing, which was the 'Yeah' 's in the IF prompt to 'YEAH'. I think because it had .toUpperCase it changing the inputs to capitalised when the defined Yeah's were lowercase. It works now! Thanks for sticking with me!


Keep up the good work! :thumbsup:


cheers, really appreciate the help!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.