Math and Arithmetic script throwing out NaN


Looking for assistance here. leveldrop and result level throwing out NaN. Is there a syntax or operators error somewhere?

function calculateLeveldrop() {

var spl = Number($('#txtleveldrop_spl').val());
var dist = Number($('#txtleveldrop_dist').val());
var leveldrop;
var resultlevel;

if (spl == "") {

if (dist == "") {

leveldrop = 20 * (Math.LOG10) + dist;
leveldrop = (leveldrop).toFixed(2);
resultlevel = spl - leveldrop;
resultlevel = (resultlevel).toFixed(2);




This is most likely due to the answer being invalid. I am working on a quadratic equation calculator and whenever x equals imaginary numbers, it shows “nan.” Try an input combination that you know should result in a real number.


Narrowed the error down to this:

resultlevel = 20 * (Math.LOG10(dist));
resultlevel = spl - resultlevel;
resultlevel = (resultlevel).toFixed(2);

Its the first line thats not happy. Replacing with test inputs the rest of the variables follow as expected. Its now not outputting NaN but actually nothing at all now.