Cool D&D switch


#1

This is a cool switch code I made to help those who want to see how to do multiple switches.

var answer = prompt("Do you play D&D?");

switch(answer) {
    case 'yes':
        console.log("Good for you!");
        var answer2 =prompt("What class are you? (please use lower case.)");
switch(answer2) {
    case 'paladin':
        console.log("Be the tank of the party!");
        break;
    case 'cleric':
        console.log("You heal the party!");
        break;
    case 'druid':
        console.log("Be connected to nature.");
        break;
    case 'rogue':
        console.log("Silent, but deadly.");
        break;
    case 'ranger':
        console.log("Like Aragorn!");
        break;
    case 'bard':
        console.log("You scandalous performer!");
        break;
    case 'wizard':
        console.log("Knowledgeable in the arcane arts.");
        break;
    case 'sorcerer':
        console.log("Fireball!!!");
        break;
    case 'warlock':
        console.log("Harbinger of dark secrets.");
        break;
    case 'monk':
        console.log("Fair and balanced.");
        break;
    case 'barbarian':
        console.log("Big brute.");
        break;
    case 'fighter':
        console.log("Hone your skills.");
        break;
    default:
        console.log("What?");
break;
}
break;
case 'no':
    console.log("You should!");
    break;
}

Hope it helps and hope you enjoy!

`


#2

@boywonderkertson
Only 1 comment::
the =double= break is not needed !!!
the break-in-the-2nd-switch-default can be discarded......


#3

Hey, thanks! I only put the extra break to remind me where I wanted my case 'yes': to end.


#4

This is cool! You should include some of the races too.


#6

Haha, thanks. I'm glad you like it. The reason I didn't put race is because I was tired of making sure everything was right. I probably will add races at some point in time soon. What race/class do you play? Or do you DM?


#7

Drow/rogue. Awesomeness


#8

Agreed. What lvl?
I am a high elf Monk.


#9

I havent played in a while, but I was pretty new. Although I am really into the forgotten realms books.


#10

Hey guys, here is an updated version of this switch, and as requested, it includes the basic 5e races. No subraces. Hope you like!

var answer = prompt("Do you play D&D?");

switch(answer) {
    case 'yes':
        console.log("Good for you!");
        var answer2 =prompt("What class are you?").toLowerCase();

switch(answer2) {
    case 'paladin':
        console.log("Be the tank of the party!");
        break;
    case 'cleric':
        console.log("You heal the party!");
        break;
    case 'druid':
        console.log("Be connected to nature.");
        break;
    case 'rogue':
        console.log("Silent, but deadly.");
        break;
    case 'ranger':
        console.log("Like Aragorn!");
        break;
    case 'bard':
        console.log("You scandalous performer!");
        break;
    case 'wizard':
        console.log("Knowledgeable in the arcane arts.");
        break;
    case 'sorcerer':
        console.log("Fireball!!!");
        break;
    case 'warlock':
        console.log("Harbinger of dark secrets.");
        break;
    case 'monk':
        console.log("Fair and balanced, you are.");
        break;
    case 'barbarian':
        console.log("Big brute.");
        break;
    case 'fighter':
        console.log("Hone your skills.");
        break;
    default:
        console.log("What?");
break;
}

var answer3 =prompt("What race are you?").toLowerCase();

switch(answer3) {
    case 'human':
        console.log("Lots of versatility.");
        break;
    case 'elf':
        console.log("Tall, proud, and beautiful.");
        break;
    case 'dwarf':
        console.log("Sturdy and strong, like stone.");
        break;
    case 'dragonborn':
        console.log("Descendant of dragons.");
        break;
    case 'halfling':
        console.log("Hobbitses!");
        break;
    case 'tiefling':
        console.log("Descendant of demons.");
        break;
    case 'half elf':
        console.log("Part of two worlds.");
        break;
    case 'half orc':
        console.log("Hardy and belligerent.");
        break;
    case 'gnome':
        console.log("Happy-go-lucky folk.");
        break;
    case 'aarakocra':
        console.log("Flighty but fun!");
        break;
    case 'genasi':
        console.log("Elemental connections.");
        break;
    default:
        console.log("What?");
        break;
}
        
break;
case 'no':
    console.log("You should!");
    break;

}


New and improved D&D switch!
#11

That is awesome. That's python, right?


#12

Javascript, actually.


#13

Oh ok. It looks very similar to python.


#14

Here is the link to the new, updated thread: https://discuss.codecademy.com/t/new-and-improved-d-d-switch/36778