0

I am trying to build a little black jack assistant but the error messages are not throwing and if there is an input it always says hit me! Help please thank you in advance.

<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>
  • `input=""` and `total=""` assigns an empty String to `input` and `total`. Use `==` or `===` to [compare](http://www.w3schools.com/js/js_comparisons.asp). You also deal with `total` before `document.getElementById("total").innerHTML = total;` – marlan Jul 03 '16 at 14:58
  • Can I create the variables all at once at the top to avoid them being assigned an empty value? I need them empty for user input. – Georgie Santiago Sep 14 '16 at 15:29

0 Answers0