Skip to content

Instantly share code, notes, and snippets.

@bhubr
Last active September 24, 2020 06:47
Show Gist options
  • Save bhubr/19138fa0052fda2c044a44bfe70a16fc to your computer and use it in GitHub Desktop.
Save bhubr/19138fa0052fda2c044a44bfe70a16fc to your computer and use it in GitHub Desktop.
Dojo removeDuplicates

Dojo removeDuplicates

Ecrire une fonction removeDuplicates qui prend en entrée un tableau (de valeurs scalaires c'est-à-dire strings, nombres, booléens), et renvoie un tableau d'où les doublons ont été enlevés.

Exemple de fonctionnement :

// should output ['one', 'two', 'three']
console.log(removeDuplicates(['one', 'two', 'three', 'two']));

Base de départ :

const assert = require('assert');


// --- WRITE YOUR CODE BELOW ---

// --- WRITE YOUR CODE ABOVE ---


// --- TESTS: Don't touch this :) ---
assert.equal(typeof removeDuplicates, 'function');
assert.equal(removeDuplicates.length, 1);
assert.deepStrictEqual(removeDuplicates(['one', 'two', 'three', 'two']), ['one', 'two', 'three']);
assert.deepStrictEqual(removeDuplicates([1, 2, 5, 7, 2, 4, 7, 1, 8]), [1, 2, 5, 7, 4, 8]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment