Search⌘ K
AI Features

Result Component

Build a Result component for your React JavaScript quiz app that displays the user's score, provides a restart button, and conditionally adds confetti for scores above seven, using the react-confetti package and the ternary operator.

Add the result card component

After the user has completed all the questions, we display the points they earned and the Restart button, which allows them to restart the quiz. We also add confetti to the function, as seen in the preview of this app. We display the confetti if the user scores more than seven points.

We use an npm package called react-confetti to add confetti to our application. To install this, we run the following command in the terminal:

npm i react-confetti

Note: This step has already been done here.

After installing the package, ...