i am creating a quiz app which has an array that includes five questions but i want the five questions to display randomly but all the 5 questions at the same time
const randomQuestion = (array) => {
let random = array[Math.floor(Math.random() * array.length)]
return random
}
const [current, setCurrent] = useState(() => randomQuestion(questions));
3
Answers
Here’s one using the
array.sort
method.