Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions challenge-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

let exampleArray = ['not','funny','but','not','correct','but','correct']

let uniqueArray = [...new Set(exampleArray)]

module.exports = uniqueArray




/*
Explanation:
I chose this method ("Set" + Spread Operator) as it's the simplest and cleanest I've found: using the "Set" object appears to be the most concise way to return unique values in the new array "uniqueArray". In this situation using "Set" + "Array.from" would be my next choice, which yields similar performace to using "Set" + Spread Operator.
*/
5 changes: 5 additions & 0 deletions challenge-1.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const uniqueArray = require('./challenge1')

test('remove all duplicates from array', () => {
expect(uniqueArray).toStrictEqual(['not','funny','but','correct'])
})