Created
September 19, 2019 23:49
-
-
Save tphummel/1a658508b0da977680b0c793980aa10a to your computer and use it in GitHub Desktop.
This file contains 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 assert = require('assert').strict | |
function dedupe (input) { | |
return Object.keys(input.reduce((memo, num) => { | |
memo[num] = true | |
return memo | |
}, {})).map((numStr) => { | |
return parseInt(numStr, 10) | |
}) | |
} | |
const input = [1, 2, 3, 4, 4, 4, 5, 5, 6, 7, 7] | |
const actual = dedupe(input) | |
const expected = [1, 2, 3, 4, 5, 6, 7] | |
assert.deepEqual(actual, expected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment