Skip to content

Commit

Permalink
Cmabio en el sort de las preguntas
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287747 committed Mar 3, 2024
1 parent c01b2d0 commit 130f4a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webapp/src/components/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ const Question = ({ goTo }) => {
};

const shuffleOptions = (options) => {
return options.sort(() => Math.random() - 0.5);
const shuffledOptions = [...options];
for (let i = shuffledOptions.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[shuffledOptions[i], shuffledOptions[j]] = [shuffledOptions[j], shuffledOptions[i]];
}
return shuffledOptions;
};

const handleSubmit = (option, index) => {
Expand Down

0 comments on commit 130f4a9

Please sign in to comment.