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

Interactive rating component html css and js

Ian Rioba 450

@Rioba-Ian

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


When a user submits the without selecting a rating, the button still submits but I don't want it to submit when there is nothing selected. How can I modify these changes in my js?

Community feedback

Kyriakos 20

@kyriakossdr

Posted

Hello my friend,

What you could is to modify your js to seem like this on line 36:

submitBtn.addEventListener('click', () => {
  if (answerValue !== '') { // same as answerValue != 0
    scoreCard.style.display = 'none';
    thankyou.style.display = 'flex';
    storeAnswer(answerValue);
  }
  // console.log("it works");
});

What this does is to check if answerValue has changed from its initial value. If that is true means that the user selected an option, if not (the answerValue === '' //its initial value) means that the user selected nothing

Marked as helpful

1

Ian Rioba 450

@Rioba-Ian

Posted

@K1riakos Just made the change and it worked. Thank you man!

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