mardi 11 avril 2023

Limit same Random number JavaScript

im selecting a statement from a json file, but the one i get is done by a randome number, but i want to avoid getting the same one consecutive times, is there a way to limit this?

Right now this is the code i have for that part, it gives me a random question beetween the amounth of questions i have

        const json = JSON.parse(fs.readFileSync('quiz.json'));
        const quizNum =  Math.floor(Math.random() * 22);

i was thinking something to avoid getting the same question if it was given in the last 2 or 3 times




Aucun commentaire:

Enregistrer un commentaire