Here is the snippet from a function:
const discountPrice = parseFloat(+(discount[1].trim())).toFixed(2).toString(); //--> 550.47
console.log(`discountPrice: ${discountPrice}`, discount[1], discountPrice); //--> discountPrice: 550.47 550.47 550.47
h += `
<tr class="discountRow discountrowx">
<td nowrap>
<span class="discountDesc" discountId="${discountObj.iddiscount}">${discountType}</span>
</td>
<td class="discountPriceDisplay">${discountPrice.toString()}</td>
<input type="hidden" class="discountPrice" discountid="${discountObj.iddiscount}" name="DiscountPrice${k}" value="${discountPrice.toString()}">
</tr>`;
console.log(`now it's:`, discountPrice);
This is what the string looks like after the function. It's perfect:
<tr class="discountRow discountrowx">
<td nowrap>
<span class="discountDesc" discountId="6180">Extra 30% off All Sale (FALLFORKICKEE)</span>
</td>
<td class="discountPriceDisplay">550.47</td>
<input type="hidden" class="discountPrice" discountid="6180" name="DiscountPrice0" value="550.47">
</tr>
Then I append it to the dom:
$(`#tblDiscounts`).append(h);
and get this:
<tr class="discountRow discountrowx">
<td nowrap="">
<span class="discountDesc" discountid="6180">Extra 30% off All Sale (FALLFORKICKEE)</span>
</td>
<td class="discountPriceDisplay">550.4699999999997</td>
<input type="hidden" class="discountPrice" discountid="6180" name="DiscountPrice0" value="550.4699999999997">
</tr>
The dollar value is rounding down somehow.I've tried with and without toString(). I've tried parseFloat-ing it again..nothing works.