1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// https://stackoverflow.com/questions/24943200/javascript-2d-array-indexof // https://stackoverflow.com/a/24943461 // Rechercher si une valeur est déjà présente dans un tableau bi-dimensionnel function wasLetterAlreadyPushedInArray(array, value) { for (var i = 0; i < array.length; i++) { // This if statement depends on the format of your array for (var j = 0; j < array[i].length; j++) { if (array[i][j] === value) { return true; // Found it } } } return false; // Not found } |
1 2 3 |
if ( wasLetterAlreadyPushedInArray(arr_words, index) === false ) { inGameLetterCount = inGameLetterCount -1; } |