Skip to content

Commit

Permalink
sonarcloud problem solved at menu
Browse files Browse the repository at this point in the history
  • Loading branch information
uo288574 committed Mar 13, 2024
1 parent 951564a commit ff89910
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion webapp/src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ const DatosContext = React.createContext();

var questions = []

function secureRandomNumber(max) {
const randomBytes = new Uint32Array(1);
window.crypto.getRandomValues(randomBytes);
return randomBytes[0] % max;
}

function shuffleArray(array) {
// Crea una copia del array original
const shuffledArray = [...array];

// Recorre el array desde el último elemento hasta el primero
for (let i = shuffledArray.length - 1; i > 0; i--) {
// Genera un índice aleatorio entre 0 y el índice actual
const randomIndex = Math.floor(Math.random() * (i + 1));
//const randomIndex = Math.floor(Math.random() * (i + 1));
const randomIndex = secureRandomNumber(i + 1);

// Intercambia el elemento actual con el elemento del índice aleatorio
const temp = shuffledArray[i];
Expand Down

0 comments on commit ff89910

Please sign in to comment.