mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
chore(js): clean while loop
This commit is contained in:
+11
-19
@@ -14,29 +14,21 @@ var nbQuestionToAnswer = 10; // don't forget to change the progress bar max valu
|
||||
var nbAnswerNeeded = 1; // out of nbQuestionToAnswer
|
||||
var nbPossibleQuestions = 10; //number of questions in database questions.js
|
||||
var lastClick = 0;
|
||||
/*
|
||||
var nbQuestionToAnswer = 10; // don't forget to change the progress bar max value in html
|
||||
var nbAnswerNeeded = 8; // out of nbQuestionToAnswer
|
||||
var nbPossibleQuestions = 15; //number of questions in database questions.js
|
||||
*/
|
||||
|
||||
function getRandomQuestion() {
|
||||
var continuer = true;
|
||||
var random;
|
||||
while (continuer){
|
||||
continuer=false; // do not continue loop
|
||||
random = Math.floor(Math.random() * nbPossibleQuestions) ; // number of possible questions
|
||||
if(questionNumber==1){
|
||||
return random;
|
||||
}
|
||||
for(i=0; i<questionNumber-1; i++){
|
||||
if (random == questionUsed[i]) {
|
||||
continuer=true; // continue loop only if random is already used
|
||||
}
|
||||
var random = Math.floor(Math.random() * nbPossibleQuestions)
|
||||
|
||||
while (true) {
|
||||
if (questionUsed.indexOf(random) === -1) {
|
||||
break
|
||||
}
|
||||
|
||||
random = Math.floor(Math.random() * nbPossibleQuestions)
|
||||
}
|
||||
questionUsed.push(random);
|
||||
return random;
|
||||
|
||||
questionUsed.push(random)
|
||||
|
||||
return random
|
||||
}
|
||||
|
||||
// Partial Functions
|
||||
|
||||
Reference in New Issue
Block a user