I ma having an issue converting my numbers into decimal places. I am trying to return each balance value which is an actual money value. Here is an example html:
<div class="balance-amount">£25.00</div>
<div class="balance-amount">£15.00</div>
<div class="balance-amount">£43,022.00</div>
<div class="balance-amount">£0.00</div>
<div class="balance-amount">£32,232.00</div>
So I write a method which iterates through each selector and I output the values in a console log. I noticed that the large figures don't return the number but NaN.
balanceAmount 25.00
balanceAmount 15.00
balanceAmount NaN
balanceAmount 0.00
balanceAmount NaN
Method:
this.balanceAmount = Selector('.balance-amount');
...
async getBalance() {
for (let i = 0; i < (await this.balanceAmount.count); i++) {
let balance = Number(
(await this.balanceAmount.nth(i).textContent).replace('£', '')
);
console.log('balanceAmount', balance.toFixed(2));
}
}
How can I get the numbers displayed correctly and avoid this NaN issue?