Code your own adventure.2 (ReferenceError: math is not defined)


#1

var userClass = prompt("Might or Magic? 1. Might 2. Magic.", "Enter number")
var goodLuck = math.random();
var goodLuck1 = math.random();
var goodLuck2 = math.random();

var user = prompt("You are lost in the middle of the forest. What you will do? 1. Go straight in one direction until the end of the forest. 2. Do as much noise as you can so that somebody can find you. 3. Climb on a highest tree nearby.", "Enter number").toLowerCase();
switch (user) {
case "1" :
if (goodLuck < 0.5 && userClass === 1) {
console.log("You are so lucky! The forest is small and you see a village nearby.");
} else {
console.log("So bad! It seems you are walking round and round. You are very exhausted now.");
}
break;
case "2" :
if(goodLuck1 < 0.5 && userClass === 1) {
console.log("You are so lucky! You see two hunters and they want you to go with them to their village");
} else {
console.log("So bad! It seems you waked the wolf and it tears you apart.");
}
break;
case "3" :
if(goodLuck2 < 0.5 || userClass === 2) {
console.log("You are so lucky! You see a village two miles away");
} else {
console.log("So bad! It seems you fell from that tree.");
}
break;
default:
console.log("No answer");
break;
}


#2

Hi try to put you math.random() with a uppercase M like that Math.random()


#3

Oh! Thanks a lot. It worked.