JSFiddle - React, Tailwind, and code Playground
by Sean Cannon
JavaScript
var user = prompt("Welcome to Hogwarts! The sorting hat is on your head; are you brave, smart, nice, or cunning?").toLowerCase();
switch (user) {
case 'brave':
console.log("You were sorted into Gryffindor!");
var gryffindor = prompt("Would you like to go to the common room, dormitory or the lake?").toLowerCase();
if (gryffindor === 'common room' || gryffindor === 'dormitory') {
console.log("After being given the password by a prefect, you tell it to the Fat Lady. Inside the Gryffindor Tower, you meet lots of new people!");
} else {
console.log("You go down to the lake, when you meet a Ravenclaw you met on the train. He's trying to show off.");
var brave = prompt("Do you want to show off or ignore him?").toLowerCase();
switch (brave) {
case 'show off':
var win = Math.random();
if (win > 0.5) {
console.log("You try doing the spell he's doing, but you don't do very well. Oh well, maybe being foolhardy isn't the best.");
} else {
console.log("You do another, more complicated spell that he can't do! Take that, pompous people!");
}
break;
case 'ignore him':
console.log("You walk away and find some new friends to talk with.");
break;
default:
console.log("Hm, I didn't recognize what you said.");
}
}
break;
case 'smart':
console.log("You were sorted into Ravenclaw!");
var ravenclaw = prompt("Would you like to go to the common room or down to the lake?").toLowerCase();
if (ravenclaw === 'common room') {
console.log("You use the eagle knocker to knock on the door, and it gives you a riddle. You eagerly answer the riddle;...