Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript question here, how do I create a Tip Calculator form with HTML and CSS where the form has a text input so that users

JavaScript question here, how do I create a Tip Calculator form with HTML and CSS where the form has a text input so that users can enter their bill amount and submit it (via a submit button). The JavaScript should calculate the tip amount based on the bill amount. Important, the tip should be displayed as a percentage of the bill amount (I don't know how to do that. help please). Edit the JavaScript to work with your updated HTML design.

Here is the JavaScript code:

const button = document.querySelector("button"); const output = document.querySelector(".output"); console.log(button); button.addEventListener("click", function() { const cost = document.querySelector("input"); console.log(cost.value * 0.15); let tip = (cost.value * 0.15).toFixed(2); let temp = `

You should tip $${tip} on $${cost.value}

`; output.innerHTML = temp; })

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions