Untitled
unknown
plain_text
a year ago
1.1 kB
3
Indexable
<script> function calculatePrice() { // Get the values of the inputs const currentSellingPrice = document.querySelector("input[placeholder='Current selling price in the market']").value; const boughtFromUs = document.querySelector("#boughtFromUs").checked; const age = document.querySelector("select[name='Age of the PC']").value; const condition = document.querySelector("select[name='condition']").value; // Calculate the trade-in price let tradeInPrice = currentSellingPrice; if (boughtFromUs) { tradeInPrice -= currentSellingPrice * 0.1; } else { tradeInPrice -= currentSellingPrice * 0.2; } if (condition === "top") { tradeInPrice -= currentSellingPrice * 0.3; } if (condition === "neverused") { tradeInPrice -= currentSellingPrice * 0.7; } if (condition === "good") { tradeInPrice -= currentSellingPrice * 0.4; } // Display the trade-in price document.querySelector(".trade-in-price").innerHTML = "Trade-in price: AED " + tradeInPrice; } document.querySelector("button").addEventListener("click", calculatePrice); </script>