0

我正在尝试构建一个小黑杰克助手,但错误消息没有抛出,如果有输入,它总是说打我!帮助请提前谢谢你。

<script>
function count(){
    var base=0;
    var input= document.getElementById("input").value;
    var total= base + input;
    try{
    if (isNaN(input)){
        throw "Input is not a number";
    }
    if(input=""){
        throw "Input is empty!";
    }
    if(total=""){
        throw "No value added!";
    }
    document.getElementById("total").innerHTML = total;
    if (total >= 14){
        document.getElementById("command").innerHTML= "Hold on";
    }else{
        document.getElementById("command").innerHTML= "Hit me!";
    }}
    catch(err){
    document.getElementById("error").innerHTML= err;
    }}

</script>
4

0 回答 0