I honestly don’t understand why this doesn’t work. Haven’t seen anything close enough to my project to help me.
This function:
function sneakPast(){
sneakChance = Math.floor((Math.random()*11)+1)+sneak;
alert(sneakChance);
if (sneakChance >=(6*level))
{
sneakSuccess = true;
}
else {sneakChance = false;}
}
is being called from this function:
function sceneFourC(){
sneakPast();
if (sneakSuccess == true){document.getElementById("Content").innerHTML = "You are able to sneak past the mob into town. <br/><input type='button' value='Continue.' onClick='sceneFive();' />";}
else {document.getElementById("Content").innerHTML = "You fail to sneak past the mob.<br/><input type='button'/>";}
}
When the alert comes up it just displays “NaN.”
Any tips are much appreciated.
I think, The sneak is not defined and so it is ‘undefined’.
DEMO here
Assign an integer to sneak and it should work.
Change
to