DEV Community

battle15
battle15

Posted on

Possible Nested Structures App Use

  • Quizzes to move on to the next pages.

    • Creates an array using checkboxes (at first)
      • Loops through the array and checks for the matching correct answers, if the answers do not match up, show the amount of answers correct and incorrect and do not allow the user to move on to the next page until they answer the correct number or questions needed for that page.
      • Correct number of answers needed for each page will vary
  • Answers will be hints on previous pages.

Code Example

<form>
  <label>Red</label>
  <input type= "checkbox" name="quiz 1[]" value="red">

  <label>Blue</label>
  <input type= "checkbox" name="quiz 1[]" value= "blue">

  <button>Submit</button>
</form>
Enter fullscreen mode Exit fullscreen mode

Output

Image description

Console (When both options are clicked)

Image description

Thought: Nested hash, keys could be different quizzes or items in a list, quiz, challenge, etc...

Source: Helper Methods, Pt 2 (Video Timestamp: 34:45)

Top comments (0)