Как уже отмечалось, вам необходимо вернуть общее значение Math.round - но вам также необходимо проанализировать значения в числах), а затем вы также должны помнить, что налог с продаж является процентом - поэтому его нужно разделить на 100.
Я изменил вашу логику на
а) разобрать значения входов в числа с помощью parseInt ()
б) решить проблему math.round ()
в) получить значение налога с продаж, умножив стоимость товара на процент налога с продаж ... itemCost * (salesTax / 100)
d) добавить значение налога с продаж к стоимости товара ... стоимость товара + (itemCost * (salesTax / 100)) ...
//Function
function calculateTip() {
var itemCost = parseInt(document.getElementById("itemCost").value);
var salesTax = parseInt(document.getElementById("salesTax").value);
//enter values window
if (itemCost === "" || salesTax == "") {
window.alert("Please enter the values!");
return;
}
//calculation
var total = Math.round(itemCost + (itemCost * salesTax/100));
//display amount
document.getElementById("totalTip").style.display = "block";
document.getElementById("amount").innerHTML = total;
}
//Hide Tip Amount and call our function with a button
document.getElementById("totalTip").style.display = "none";
document.getElementById("submit").onclick = function() {
calculateTip();
};
</head>
<body id="color">
<div class="container" id="contain">
<div class="text-center">
<h1>Sales Tax Calculator</h1>
<p> Amount Before Tax?</p>
$ <input id="itemCost" type="text" placeholder="item cost">
<p>Sales Tax Percentage?</p>
<input id="salesTax" type="text" placeholder="sales tax percent"><br><br>
<button type="submit" id="submit">submit</button>
</div>
<div class="container" ID="totalTip">
<div class="text-center">
<p>Total Tip</p>
<sup>$</sup><span id="amount">0.00</span>
</div>
</div>
</div>
<script type="text/javascript" src="javascript.js"></script>
</body>