Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here's a description of the changes made to the provided code: 1. Timer Feature: - We added a timer feature to each question in the quiz. - `useState` and `useEffect` hooks are used to manage the timer. - `timer` state variable keeps track of the remaining time in seconds, initially set to 30 seconds. - `timerInterval` state variable is used to store the interval ID for the timer. - `startTimer` function initializes the timer and starts counting down from 30 seconds. - `stopTimer` function clears the timer interval when the question changes or when the quiz finishes. - In the `useEffect`, we start the timer when a new question is displayed and stop it when the quiz is finished. - The remaining time is displayed in the UI using `<p>Time Left: {timer} seconds</p>`. 2. Progress Bar Feature: - We added a progress bar to indicate the progress of the quiz visually. - CSS classes `progress-bar` and `progress` are used to style the progress bar. Make sure to add appropriate CSS styles for these classes. - The width of the progress bar is determined based on the current question's index (`next`) and the total number of questions (`len`). - The progress bar is a visual representation of how far the user has progressed in the quiz. These enhancements improve the user experience of the quiz by adding a time limit per question and a visual indicator of progress. Users can see how much time is remaining for each question and how far they have progressed in the quiz.
- Loading branch information