Design comparison
SolutionDesign
Solution retrospective
-
How could I have improved my CSS using BEM naming conventions?
-
How can I get JS to show the extra zero for total amounts? (12.50 instead of 12.5)
Community feedback
- @ChamuMutezvaPosted over 3 years ago
- the validation is working but it has to be tightened again. The error message is showing when a
0
or less is entered in the bill or number of people inputs field but the calculations are still going ahead. - non numbers can be entered but no error message or warning
- this
<label class="calc__billTotalLabel" for="billTotal">Bill:</label>
label is not pointing to the input elements available. I cannot locate an element with the idbillTotal
- which is the same as this input
<label class="calc__billTotalLabel" for="billTotal">Bill:</label>
. I think you intention was to label this input element<input class="btn-container__input" type="number" id="people" value="1" />
. Change the value of thefor
attribute in thelabel
to be the value of theid
in the input element. - now to your question, create the following function:
const dollarsUS = Intl.NumberFormat("en-US", { style: "currency", currency: "USD", })
to change the following statement from your js
tipAmount.innerHTML = tipNumber;
- use it as follows
tipAmount.innerHTML = dollarUS.format(tipNumber);
Marked as helpful0 - the validation is working but it has to be tightened again. The error message is showing when a
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord