Price Tag
JavaScript
10 pts
Price Tag
Use the starter values. A customer buys qty items at price each and pays with the text input.
- Create
total=price * qtyand print"Total:"withtotal.toFixed(2). - Create
paidas a number read frominput(useparseIntorparseFloat) and print"Paid:"andpaid. - Create
change=paid - totaland print"Change:"with two decimals.
Expected output:
Total: 22.50 Paid: 30 Change: 7.50
Checklist
- Create
totalas a number. - Read
paidfrom the text. - Create
changeand format the money withtoFixed(2). - The three lines match.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
