Code your own Adventure. Ex.5 Breaking


Below, I'm trying to use the else statement to prompt the first question "As you're out walking...
So my question is, is there a way to break out of the case and start the game over again?

var user = prompt ("As you're out walking a man walks up. He asks you Where are you going'?").toLowerCase();

switch (user) {
        case 'north':
       var confident = prompt("You know it's cold up there. Do you feel up to the task?" ).toLowerCase();

       if( confident === 'yes') {
        console.log("Well then, god speed");    
        else {


You could place the whole thing in a while statement e.g. while (thisIsTrue) {};

More specifically, a do...while loop would probably be more appropriate.

This would repeat until the condition becomes false.


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