no matter what i try i can't get rid of "NaN" when the data isn't present
Here is function
function decimalFormat(thisNum, places) {
if (places === -1) places = precision;
if (parseFloat(thisNum) === "NaN") thisNum = 0;
if (thisNum === -0.0001) {
thisNum = "-.---";
} else {
thisNum = parseInt(thisNum * Math.pow(10, places)) / (Math.pow(10, places));
if (thisNum === parseInt(thisNum)) {
if (places > 0) thisNum += ".";
}
for (var x = 0; x < places; x++) {
if ((parseFloat(thisNum) * (Math.pow(10, x))) === parseInt(thisNum * (Math.pow(10, x)))) thisNum += "0";
// I get "Nan" in this loop
// I placed efforts below here
}
}
return thisNum;
}
I have marked where I'm getting "NaN" in the function. I have tried all the following and still gets "Nan" , any advice ? I placed them inside the loop where i have it marked in function
if (thisNum === 'undefined') thisNum = 0;
if (parseFloat(thisNum) === 'undefined') thisNum = 0;
if (parseFloat(thisNum) === "NaN") thisNum = 0;
if (thisNum === "NaN") thisNum = 0;