Code your own adventure problem


#1

I know I probably got a lot of things wrong so feel free to point them out (this is a rough draft)
Error: there was a problem with your syntax

var Health = 15;
var DarkHealth = 20;
var damage = 0;
var user = prompt("What attak should I do(magic,sword,potion").toUpperCase()
switch (user){
    case 'SWORD' :
    if (Math.floor(Math.random()*2 === false)){
    return DarkHealth - 8;
    confirm("Critical Hit! Dark Health is damaged");
    return Health - 5;
}else{ 
    return DarkHealth - 6;
    confirm("DarkHealth is damaged");
    return Health - 5;
}
break;
case 'MAGIC' :
    return Dark Health - 4;
    confirm("You reduced Dark Health damage for one turn, Dark Health is damaged");
    return Health - 3;
    break;
    case 'POTION' :
        return Health + 10;
        confirm("You healed yourself");
        return Health - 5;
        break;
        default :
        return Health - 8
        confirm("DarkHealth charged at you and you were unprepared");
};

I plan on adding a 'for loop' to give you 3 or 4 rounds also some variable names will be changed ,operators will be added, if/else statement to tell when Health/DarkHealth is 0,and Damage points will be fixed


#2

there is a problem at this line:

if (Math.floor(Math.random()*2 === false)

the number of opening parentheses (() doesn't match the number of closing parentheses ())


#3

fixed it The error now says illegal return statement what should I do


#4

I changed return to console.log now it says missing ) after argument


#5

please post an updated version of your code


#6

Oh sorry I gave up because I couldn't figure it out so I gave up and started over


#7

Nobody responded to help me but only one and his revisions didn't solve the whole problem


#8

Here is the code I am working on right now (if you want to help)

var Choice2 = prompt("do you feel confident");
var Choice = prompt("do you think you are  smart","yes or no");
confirm("You are starting a test be ready (think logically)");


var user = prompt("Little Johnny's mother had 3 children. There name's were April,May,and blank A)  Johnny, B)  June, C)  None of them"," Be logical").toUpperCase();
switch(user) {
    case  'A':
    console.log("1)Correct");
    if (Choice === "YES"|| Choice2 === "NO"){
        
    confirm("Yay you are smart but don't doubt yourself")}
    
    else if (Choice === "YES" && Choice2 ==="YES"){
        
    confirm("Good job you gotta feel good about yourself")}
    
    else if (Choice === "NO"|| Choice2 === "YES")}
    
    confirm("Feel confident but not smart that should change")
    
    }else{
        
    confirm ("You should feel good about yourself")
    
    };
     break;
 case 'B' :
     console.log("Wrong");
     break;  
 case 'C' :
     console.log("Wrong");
     break;
   default :
   console.log("Answer next time Wrong");
};
confirm("That was A warm up")
var user2 = ('A 62 two year old woman walked with a 16 year old teen , all the sudden a man walked by and the both said " Hello father" how is this possible " A) The women are sisters and the man is there father B) Incest C) Man is a priest','BE LOGICAL').toUpperCase();


switch(user2) {
   
    case  'A':
    console.log("Wrong");
     break;
 case 'B' :
     console.log("Wrong");
     break;  
 case 'C' :
     console.log("2)Correct");
     
     break;
   default :
   console.log("Answer next time Wrong");
};

thanks in advanced
I will probably ask post this question


Help urgent
#9

this line:

else if (Choice === "NO"|| Choice2 === "YES")}

you have a } instead of a {, if you need more help, post the exercise url and an updated version of your code


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.