I'm making a Quiz app in react native and I want to shuffle the order of questions each time someone picks the quiz. I was thinking about using shuffle from lodash but I'm not totally sure how to do for nested array.
const getTest = async () => {
try {
const response = await fetch('https://tgryl.pl/quiz/test/'.concat(route.params.testId));
const json = await response.json();
setData(json);
}
catch (error) {
console.error(error);
}
}
I was thinking about something like setData(_.shuffle(data.tasks)) ?? I have no idea
The JSON looks like this
