Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button id="btn"> Play the Dinner Game </button>
- <p id="para"></p>
- document.getElementById("btn").addEventListener("click", dinnerThing);
- function dinnerThing () {
- var cost = prompt("how much did it cost?");
- if(cost == "") {
- document.getElementById("para").innerHTML = "sorry please enter an integer";
- }
- var taxRate = prompt("What was the tax rate?");
- if(taxRate == "") {
- document.getElementById("para").innerHTML = "sorry please enter an integer";
- }
- var taxPaid = cost * taxRate;
- document.getElementById("para").innerHTML = "You paid " + taxPaid + " dollars in tax for your dinner";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement