Skip to content

Instantly share code, notes, and snippets.

@tphummel
Created September 19, 2019 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tphummel/1a658508b0da977680b0c793980aa10a to your computer and use it in GitHub Desktop.
Save tphummel/1a658508b0da977680b0c793980aa10a to your computer and use it in GitHub Desktop.
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