5/6 How would I make the user do all three to win?


Here's my game. It works, but I want the user to do all three tow win. How can I do that?

    var user = prompt("You wake up one morning and discover you have shrank while you slept.  Your mom has left you a list of chores to do: dishes, clean your room and walk the dog.  Which chore would you like to do first?").toUpperCase();

switch(user) {
    case 'DISHES':
        console.log("You chose to do the dishes! How do you think you're going to do that?");
        var strong = prompt("You head to the kitchen and see the a tall stack of drawers that you can use as a ladder.  If you're strong enough you can climb the drawers and use a sponge like a surf board to clean the dishes!","Are you strong?").toUpperCase();
        var surf = prompt("Can you surf?").toUpperCase();
        if (strong === 'YES' && surf === 'YES') {
            console.log("Nice job!  You did the dishes!");
            cosole.log("You were unable to do the dishes.  You lose!");
    case 'CLEAN ROOM':
        console.log("Alright!  We're going to need something to help us!");
        var magic = prompt("You left your toy airplane on the floor.  With a lot of luck or a bit of magic you can fly your plane to zoom around and quickly collect all of your toys!", "Do you believe in magic?").toUpperCase();
        var luck = prompt("Do you feel lucky?").toUpperCase();
        if (magic === "YES" || luck === 'YES') {
            console.log("Make sure to grab you're tiny helmet!  You fly around your room in the plane and quickly get all of your toys back in the bin. Watch out for the cat, he might think YOU are a toy!");
            console.log("No luck AND you don't believe in magic? Looks like your room isn't getting cleaned today.");
    case 'WALK DOG':
        console.log("This outta be good! Here boy!");
        var train = prompt("You're dog is big when you are big, but when you are small he seems like a giant.  Hopefully you remembered to train him!","Did you train your dog?").toUpperCase();
        var holdOn = prompt("You can climb on your dog's back, but can you hold on?").toUpperCase();
        if (train === 'YES' && holdOn === 'YES') {
            console.log("Your dog lays down do you can climb on his back.  You take hold of his fur in both hands.  Let's go!  Your dog runs around the neighborhood with a freedom he's never felt before, with you on his back feeling the wind in your hair.  After you've returned home, you're pooped!  You decide to take a nap.  When you wake up, you're big again.  Huh? Must have been a dream.");
            console.log("If you didn't train your dog, how do you expect to get on his back?  You're dog doesn't get walked, you lose.");
        console.log("You're too small to do that!");


Look closely. Also, I see this:

Or specifically, this:

But I don't think that's the problem. So first, change that console.log.


Good question. I'm a beginner in Javascript so maybe my way of doing is not the best but here are my thoughts:

  • First you could set 3 variables (dishesDone, cleanDone and walkDone) to FALSE.

  • Then, simplify your prompt message so you can make it dynamic : after a task is done, you don't want it to be displayed in your prompt (Ex : "... So what you can do is:"+(if(dishesDone == true){ "DISHES"} else {""}+(if(cleanDone == true){ etc..

  • Then after a victory, you could set the correct variable to TRUE (ex: var dishesDone = true;) and make a if() to check if all the tasks are done. If yes, console.log a "You did everything" message. If not, prompt again.

  • In your switch, check that the player didn't type something set to TRUE (ex: case 'WALK DOG': if(walkDone == TRUE){console.log("Already done");} and display the prompt again.

There are probably flaws in my syntax and there may be a more simple solution too (for exemple: use loops and arrays) but in theory, it should work.
Hope it helps.


@ragezapper haha, how embarrassing. OK, typos fixed :smile:

@shanowar - that makes sense to me, and was similar to what I was thinking of. Thanks for your help!