-1

I'm trying to check to see if an input is NaN, basically I want to alert 0 if nums doesn't have anything in it, or if that something is a 0. Any ideas on how to go about this?

var sumofnums = 0,
nums = document.getElementById("nums").value.split(",");

function add(){
    for (i = 0; i < nums.length; i++) {
        sumofnums += parseInt(nums[i]);
    };
    document.getElementById("sum").innerHTML = sumofnums;
};
if (nums === ''){
    alert('0');
} 
Bkes
  • 137
  • 8

1 Answers1

-1

isNaN();

Google can help as well.

Deadweight
  • 137
  • 8