Skip to content

Commit

Permalink
Otro commit más...
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287747 committed Mar 3, 2024
1 parent 130f4a9 commit 15562bc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions webapp/src/components/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ const Question = ({ goTo }) => {
};

const shuffleOptions = (options) => {
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]];
let currentIndex = options.length, temporaryValue, randomIndex;

while (currentIndex !== 0) {

randomIndex = currentIndex - 1;

temporaryValue = options[currentIndex - 1];
options[currentIndex - 1] = options[randomIndex];
options[randomIndex] = temporaryValue;

currentIndex--;
}
return shuffledOptions;
return options;
};

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

0 comments on commit 15562bc

Please sign in to comment.