Design comparison
SolutionDesign
Solution retrospective
creating the logic for the calculation was difficult for me, I wasn't able to add the error message
Community feedback
- @amalkarimPosted almost 2 years ago
Hi Albert. Maybe this can help.
There's an error in this line:
const text = document.querySelector('text');
It doesn't select class
text
, but selecttext
element which is nowhere to find. Let's repair this first.const text = document.querySelector('.text');
Then we need to change
function setPeopleValue()
. Check out the code below:function setPeopleValue() { peopleValue = parseFloat(inputPeople.value); if (isNaN(peopleValue)) peopleValue = 0; if (peopleValue < 1) { text.classList.remove('hidden'); } else { text.classList.add('hidden'); calculateTip(); } }
Let me know if there's still error. Happy coding!
Marked as helpful0
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