dimanche 28 février 2021

Random shuffling of tags in react

I am building a quiz program in react and pulling my questions from a mysql db into an array and then displaying the different parts in html rows. Right now I'm always pulling the correct answer into button 1 and three incorrect answers into buttons 2-4. Is there a way for me to shuffle the rows randomly so that I don't have to create a separate array and then shuffle?

<div className='answers'>
    <Row><button onClick={correctAnswer}>}</button></Row>
    <Row><button onClick={incorrectAnswer1}></button></Row>
    <Row><button onClick={incorrectAnswer2}></button></Row>
    <Row><button onClick={incorrectAnswer3}></button></Row>
</div>



Aucun commentaire:

Enregistrer un commentaire