Tip Calculator Using Js

Solution retrospective
Javascript logic is not doing well, any suggestions and improvements are most welcome.
-
I am not sure if my js is doing the right calculation, i reviewed some of the solutions on frontendmentors but most of the solutions differ in results.
-
how can i calculate every time any of the value changes i.e my program calculate for once, to do another calculation, the program is needed to be reset.
-
would be very thankful for your suggestions and reviews.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @MarziaJalili
The web's on fire! 🔥
🌟 DOM manipulation? Super simple!
✅ We have three simple steps:
-
Get the input element using JavaScript.
-
Listen for changes on that input using the input event listener.
-
Update the UI whenever the value changes using textContent or innerText.
✅ Here's you go with the example:
/* First step */ const input = document.getElementById('num-of-ppl'); const result = document.getElementById('result'); /* Second */ input.addEventListener('input', function() { /* Third */ result.textContent = input.value; // Update UI with current input value });
Hope it clarifies the process! 😎
-
Join 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