nouvelle fonction correcte

This commit is contained in:
joniboy74prog
2023-12-08 04:41:02 +01:00
parent 0d68aaf3e6
commit c4cdd44846
10 changed files with 14 additions and 139 deletions
+13 -2
View File
@@ -156,8 +156,19 @@ function getImg2(categorie, indice){
// function for random index of a function
function getIndex(){
function getIndex(tableauDentiers){
if (tableauDentiers.length == 0){
return -1;
}
const indiceAleatoire = Math.floor(Math.random() * tableauDentiers.length);
tableauDentiers.splice(indiceAleatoire, 1);
console.log(tableauDentiers); // Affiche : [1, 2, 4, 5]
return indiceAleatoire;
}
document.addEventListener('DOMContentLoaded', ()=>
{
const tableauDentiers = [1, 2, 3, 4, 5];
}
)