diff --git a/src/components/QuizGame.js b/src/components/QuizGame.js index 1705708..e0aae96 100644 --- a/src/components/QuizGame.js +++ b/src/components/QuizGame.js @@ -2,10 +2,21 @@ import React, { Fragment } from 'react'; import Grid from '@material-ui/core/Grid'; import Quiz from 'react-quiz-component'; +function shuffleArray(array) { + var j, x, i; + for (i = array.length - 1; i > 0; i--) { + j = Math.floor(Math.random() * (i + 1)); + x = array[i]; + array[i] = array[j]; + array[j] = x; + } + return array; +} + class QuizGame extends React.Component { quiz = { "quizTitle": "Trail Cam Quiz", - "questions": [ + "questions": shuffleArray([ { "question": What animal is this?
, "questionType": "text", @@ -56,7 +67,7 @@ class QuizGame extends React.Component { ], "correctAnswer": "2" }, - ] + ]) }; render() { diff --git a/src/pages/QuizPage.js b/src/pages/QuizPage.js index ef6cb3f..97f7904 100644 --- a/src/pages/QuizPage.js +++ b/src/pages/QuizPage.js @@ -7,7 +7,7 @@ class QuizPage extends Component { render() { return ( - + ); }