Step 4: A progress bar component
Extract a small reusable component. ProgressBar receives value and max as props, draws a bar whose width is the fraction complete, and uses role="progressbar" with aria-valuenow so assistive technology can read it. The result screen reuses it to show the score. The answers are also wrapped in a role="group" with a label.
Components with clear props are the building block of React: ProgressBar knows nothing about quizzes, so it could be used for an upload or a course too.
Write percent(value, max) that returns the whole-number percentage (rounded), or 0 when max is 0. Print percent(1, 4), percent(2, 3) and percent(5, 0).
What are props?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.