Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Grid, Flexbox, Javascript

Albert Rex 360

@rexalbert538

Desktop design screenshot for the Tip calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

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

@amalkarim

Posted

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 select text 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 helpful

0

Albert Rex 360

@rexalbert538

Posted

@amalkarim thank you so much

0

Please log in to post a comment

Log in with GitHub
Discord logo

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