Q:

Getting NaN when using parseFloat

I am using a this code to do that calculation:
$('#outfitters').submit(function(event) {
                var days = $('#days').val();
                var final_price = 0;

                var length = parseFloat($("#length").val());
                var material = parseFloat($("#material").val());
                var fibre = parseFloat($("#fibre").val());
                var kevlar = parseFloat($("#kevlar").val());
                final_price = parseFloat(days * (length + material + fibre + kevlar));

                console.log(length);
                alert("Final Price is: " + final_price);
                window.location.reload(true);
        });

All the values are getting retrieved from a JSON which is shown below,
{
   "company":"SS",
   "locations":[
        { "name":"Kincardine" },
        { "name":"Killarney"},
        { "name":"Bon Echo"}
    ],
    "twelve": 25.00,
    "fourteen": 30.00,
    "sixteen":35.00,
    "paddles": 10.00,
    "lifevest": 10.00,
    "fibreglass":0.00,
    "kevlar": 10.00
}

The problem is I am getting NaN while calculating final_price though I an retrieve all values perfectly. Anything I am missing here?

A:

Double check the value of your days element. Try parsing it as a float as well.
var days = parseFloat($('#days').val());

