DEV Community

Discussion on: Need help with project

Collapse
 
jeremyf profile image
Jeremy Friesen

On line 21 of script.js it looks like it's doing something unintended.

What's happening is you are looping through the array of buttons but on line 21 are always asking does the 0th element of buttonArray exist? (Which it always does). To visualize this, you could add a debug/breakpoint in your code.

I don't do much front-end coding, but here's how I'd approach this is:

  1. When I click on one of the numbers, I need to update an element with that value.
  2. When I click submit, I want to get the value of the element I updated.

Perhaps whenever you click a rating button set a data attribute on the submit button. Then when you click submit, read that data attribute. See the Mozilla Developer docs on Data

Collapse
 
taepal467 profile image
Chantae P.

Thank you so much. I will look into this and hope that it works 🤞🏾