Skip to content

Instantly share code, notes, and snippets.

@darksh3ll
Last active August 13, 2018 21:00
Show Gist options
  • Select an option

  • Save darksh3ll/f4430eda8458ccfc3eba62b400c7ddd5 to your computer and use it in GitHub Desktop.

Select an option

Save darksh3ll/f4430eda8458ccfc3eba62b400c7ddd5 to your computer and use it in GitHub Desktop.
Algorithme qui recherche un doublon dans un tableau
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);
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