# JavaScriptAdding the negative number return as Nan

#### Jailani24589

##### New Coder
Getting the values from the locator like below, if the locator have the negative values Total return NaN

JavaScript:
``````for (let i = 0; i < count-2; i++)
{
let estimateMiniCartAmount = (await _estimateTotalAmount.nth(i).innerText).replace('\$','').replace('/mo', '').replace('.00','')
console.log(" Line Amount-->"+ estimateMiniCartAmount)
Total = parseFloat(Total) + parseFloat(Number(estimateMiniCartAmount))
console.log(" Line Amount-->"+ Total)
}``````

Output

Line Amount-->90
Line Amount-->90
Line Amount-->−25
Line Amount-->NaN

Getting the values from the locator like below, if the locator have the negative values Total return NaN

JavaScript:
``````for (let i = 0; i < count-2; i++)
{
let estimateMiniCartAmount = (await _estimateTotalAmount.nth(i).innerText).replace('\$','').replace('/mo', '').replace('.00','')
console.log(" Line Amount-->"+ estimateMiniCartAmount)
Total = parseFloat(Total) + parseFloat(Number(estimateMiniCartAmount))
console.log(" Line Amount-->"+ Total)
}``````

Output

Line Amount-->90
Line Amount-->90
Line Amount-->−25
Line Amount-->NaN
Hi there,
You might want to check if Total is a number first of all

I am not sure why this returns NaN instead of the expected 65. However this simplified code

JavaScript:
``````var total = 0;

{
total += parseFloat(Number(amount));
console.log("amount = " + amount + "  total = " + total);
}

```amount = 90 total = 90 amount = -25 total = 65 ```
1) Any reason for using the `await` ?
2) Any reason for using the `Number()` function ? It works just as well without it.