Last active
August 13, 2018 21:00
-
-
Save darksh3ll/f4430eda8458ccfc3eba62b400c7ddd5 to your computer and use it in GitHub Desktop.
Algorithme qui recherche un doublon dans un tableau
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let score = [10,2,3,3,2]; | |
| let doublon = []; | |
| for (let i = 0; i < score.length; i++) { | |
| var temp = score[i]; | |
| for (let j = i+1; j < score.length; j++) { | |
| if (temp === score[j]) { | |
| doublon.push(temp) | |
| } | |
| } | |
| } | |
| console.log(doublon); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arr = [12,12,102,12] | |
| const clone = []; | |
| arr.forEach(function(x){ | |
| if (clone.includes(x) === false) { | |
| clone.push(x); | |
| } | |
| }) | |
| console.log(clone) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment