Hi, i’m currently using the following code to calculate the total cost of selected services. That works fine. However, when the total price is calculated, some calculations decide to show as £99.9999999 … Is there a code I can use to prevent this from happening and get it to show £99.99??
This is my current code:
export function iphone4g_click(event) {
$w(“#strip2”).hide();
$w(“#4gstrip”).show();
$w(“#strip1”).show();
$w(“#getquote”).show();
}
function ttlPrice() {
let charge = 0.00;
if ($w(“#switch1”).checked) {
charge += Number($w(“#switch1”).value)
}
if ($w(“#switch2”).checked) {
charge += Number($w(“#switch2”).value)
}
if ($w(“#switch3”).checked) {
charge += Number($w(“#switch3”).value)
}
if ($w(“#switch4”).checked) {
charge += Number($w(“#switch4”).value)
}
if ($w(“#switch5”).checked) {
charge += Number($w(“#switch5”).value)
}
if ($w(“#switch6”).checked) {
charge += Number($w(“#switch6”).value)
}
if ($w(“#switch7”).checked) {
charge += Number($w(“#switch7”).value)
}
if ($w(“#switch8”).checked) {
charge += Number($w(“#switch8”).value)
}
return String(charge);
}
export function getquote_click(event, $w) {
$w(“#price”).text = ttlPrice();
$w(“#input1”).show();
$w(“#input2”).show();
$w(“#input3”).show();
$w(“#submit”).show();
$w(“#yourquote”).show();
}