Passed the lesson, but code doesn't work - Code your own adv 2


#1

I managed to pass the lesson, but the answers I give the prompt don't work properly, can anybody help me??
Here's my code:

var user = prompt ("Let's have a deal, dearie? :D").toLowerCase();
var power;
var strength;

switch(user) {
case "yes":
prompt("What kind of magic do you like, dearie?").toLowerCase();
if (prompt === "black magic") {
console.log ("Hhmhmhmhmhmhm :D");
}
else {
console.log ("I'll teach you something nice!");
}
break;
case "no":
console.log("You'll come to me sonner or later, dearie!");
break;
case "dunno":
prompt("Do you want power or strength??");
if (power && strength) {
console.log("We will have a deal, dearie");
}
else if (power || strength) {
console.log("Why not both?");
}
else {
console.log("Go away then.");
}
break;
default:
console.log("Every magic comes with a price, dearie!");
};


#2

Hi this part if (power && strength)
You didn't put the prompt answer its should be Something Iike that

if (prompt === "Power" or "strenght")

#3

Hi,
are you sure? Power and strength are variables, so they shouldn't go between quotes, right? And I want to use the logical operator "and", which should be written as &&.


#4

Ok you right but if you want to have the choice for power and strength you need to add a prompt like that

var p = prompt("Do you want power or strength??");

var s = prompt("Do you want power or strength??");

 if (p === "power" && s === "strength") {
console.log("We will have a deal, dearie");
}