Help on 5


#1

This is my code:

var user = prompt("Do you bump into a strange dragon while playing near an old castle with your friend. The evil Dragon demands a sacrifice or money. What do you give him a sacrifice, give him money, run away, or fight", "Please use one word answers").toUpperCase()
switch(user){
case "sacrifice":
console.log("You have to sacrifice your friend to the dragon but you live")
break;
case "money":
var amount = prompt("Do you have a lot of money on you","yes or no");
var choice = prompt("Do you give the dragon more than $100","yes or no");
if(choice === 'yes' && amount = 'yes'){
console.log ("The dragon sets you free");
}
else{
console.log("The Dragon kills you");
}
break;
case "fight":
console.log("The dragon kills you instantly with his breath of FIRE!!!!!!");
break;
case "run":
console.log("Thanks to your speed, you and your friend successfully make it back to your home the village. However the dragon follows you in and kills the whole village in a fit of rage");
break;
default:
console.log("That wasn't very smart. The Dragon killed you easily");
break;
}

The Error Message i receive:
ReferenceError: Invalid left-hand side in assignment

Please Help

I think my mistake is in case two about money??


#2

Hi there! I found 3 mistakes which you may want to fix.

1. Just after the ".toUpperCase()", considering writing a semicolon ';'.
2. You should end all the console.log() lines with a semicolon ';' too. The one in case "sacrifice" doesn't have one.
3. The condition in case "money" is wrong. You are asigning amount to 'yes', not comparing it.

I hope this helps you :smile:


#3

If anybody needs help, here is something you can refer to:
console.log("You are a theif and you are wanted by the kingdom of Esgaroth.You have to escape the kingdom Esgaroth and return back to your homeland Dale. However, to do that,you would have to pass through the gate of Mirkwood.You will have to make a decision on what you are going to do to go through the gate of Mirkwood!")
var user = prompt("What do you do?").toUpperCase();

switch(user) {
case 'Convince':
var smart = prompt("Are you smart?").toUpperCase();
var persuasive = prompt("Are you persuasive?").toUpperCase();
if(persuasive === 'YES'|| smart === 'YES') {
console.log("You only need one of the two! You convinced the gatekeeper --nice work!");
}
else {
console.log("You're neither persuasive or smart? Well, if you were smarter, you probably wouldn't have tried to convince the guard. You are on the run!");
}
case 'Bash your way through':
var strength = prompt("Are you strong?").toUpperCase();
var speed = prompt('Are you fast?').toUpperCase();
if( strength === 'YES' && speed === 'YES'){
console.log('You slaughtered everyone there and managed to escape the area before the reinforcement guards managed to arrive');
}
else{
console.log("You were killed");
}
case 'Slip through their defence':
var armour = prompt('Do you have a lot of armour?').toUpperCase();
if(!armour === 'NO'){
console.log("You were caught and thrown in jail!");
}
else{
console.log("You slipped through their defence!");
}

}
//I got inspiration from Hobbit and Skyrim.