Object returning NaN when sum values

var jan = 0; //this should solve it

for (var i=0;i<data.length;i++){ 
    if(data[i].jan != null){    
        jan += parseFloat(data[i].jan);
        console.log(jan);
    }
}

Try this should solve it 🙂

Explanation as quoted by DON in comments below:

var jan; this will declare variable as undefined, so when you try to
add values with undefined you will get as NaN, so the answer here with
var jan = 0 will work – DON

Leave a Comment