gpt4 book ai didi

javascript - 返回 NaN 值的方程

转载 作者:行者123 更新时间:2023-12-02 19:55:06 25 4
gpt4 key购买 nike

老实说,我不明白为什么这不起作用。还没有看到任何与我的项目足够接近的东西来帮助我。该功能:

    function sneakPast(){

sneakChance = Math.floor((Math.random()*11)+1)+sneak;
alert(sneakChance);
if (sneakChance >=(6*level))
{
sneakSuccess = true;
}
else {sneakChance = false;}
}

正在从此函数调用:

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'/>";}



}

当警报出现时,它只显示“NaN”。

非常感谢任何提示。

最佳答案

我认为,潜行没有定义,所以它是“未定义”的。

DEMO这里

分配一个整数来潜行,它应该可以工作。

改变

var sneak, sneakSuccess = false;

var sneak = 0, sneakSuccess = false; //assign a valid integer to sneak

关于javascript - 返回 NaN 值的方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8773532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com