Codeloft
0 0 XP

Project: tip calculator

25 min 60 XP + 10 for no hints

Build a tool people really use at restaurants: type the bill, pick a tip and see the total.

You'll combine an HTML form, a little CSS and JavaScript. Read numbers from inputs with Number(input.value), and round money with total.toFixed(2), which always shows two decimal places.

Test it yourself in the preview: change the bill, pick a tip and click Calculate.

Your tasks

0 of 5 done
  1. Listen for clicks on the Calculate button
  2. A 50 bill with a 20% tip shows a total of 60
  3. It works for other amounts (80 with 15% is 92)
  4. The total is rounded to 2 decimal places
  5. Add a CSS rule that styles the button
tip.htmlUpdates as you type