CODE YOUR OWN ADVENTURE 2! : Syntax Error


#1

Hi!
I need help debugging my code. I get a SyntaxError: Unexpected token case. Is it because I need to add like wrap text or something?

Thank you.

var user = prompt("whats the best Diablo class").toUpperCase();
switch (user)
{
case 'BARBARIAN':
console.log ("Great fighting class!");
var courage = prompt("Are you strong, YES or NO?").toUpperCase();
var attack = prompt("Are you ready to attack, YES or NO?").toUpperCase();
if (courage && attack)
{
console.log("you will be a great barbarian!");
}
else
{
console.log("since you arent strong and ready to attack, then you aren't a good barbarian!");
break;
case 'DEMON HUNTER':
console.log("One of my favorites, you have good taste!");
var weapon = prompt("do you have a weapon to attack? YES or NO?").toUpperCase();
var chant = prompt("Can you use any spells?").toUpperCase();
if (weapon || chant)
{
console.log("Great either Spells or Weapons can defeat the monster!");
}
else
{
console.log("boo you need either or to defeat the monster,sorry you lose!");
}
break;
case 'WITCH DOCTOR':
console.log("I've heard its tough good luck!");
break;
default:
console.log("dont know what you talking about bro!");
}


#2

The ELSE branch above case "DEMON HUNTER" is missing a closing curly brace "}".

var user = prompt("whats the best Diablo class").toUpperCase();
switch (user) {
    case 'BARBARIAN':
        console.log("Great fighting class!");
        var courage = prompt("Are you strong, YES or NO?").toUpperCase();
        var attack = prompt("Are you ready to attack, YES or NO?").toUpperCase();
        if (courage && attack) {
            console.log("you will be a great barbarian!");
        } else {
            console.log("since you arent strong and ready to attack, then you aren't a good barbarian!");
        } // added closing curly brace for ELSE
        break;
    case 'DEMON HUNTER':
        console.log("One of my favorites, you have good taste!");
        var weapon = prompt("do you have a weapon to attack? YES or NO?").toUpperCase();
        var chant = prompt("Can you use any spells?").toUpperCase();
        if (weapon || chant) {
            console.log("Great either Spells or Weapons can defeat the monster!");
        } else {
            console.log("boo you need either or to defeat the monster,sorry you lose!");
        }
        break;
    case 'WITCH DOCTOR':
        console.log("I've heard its tough good luck!");
        break;
    default:
        console.log("dont know what you talking about bro!");
}