我有一个这样的数组:
export const QuizArray = [
{
id: 1,
question: 'Which of these factors that contribute to stroke?',
answers: ['High blood cholesterol', 'Smoking', 'Old Age', 'All of the above'],
correct_answer: 'All of the above',
},
{
id: 2,
question: 'Ischaemic Stroke is when blood clots occur in the brain?',
answers: ['TRUE', 'FALSE'],
correct_answer: 'TRUE',
},
{
id: 3,
question: 'Which of the following are possible symptoms of stroke?',
answers: ['Weakness in facial muscles', 'Vision impairment', 'Slurring of speech', 'All of the above'],
correct_answer: 'All of the above',
},
]
如何在不重复的情况下随机化/洗牌 id?我正在使用 React Native、VS Code 和 Andriod studio。