Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active February 12, 2019 23:28
Show Gist options
  • Save wilmoore/e5a4eb459df82843c9b18be704336589 to your computer and use it in GitHub Desktop.
Save wilmoore/e5a4eb459df82843c9b18be704336589 to your computer and use it in GitHub Desktop.

Revisions

  1. wilmoore revised this gist Feb 12, 2019. No changes.
  2. wilmoore created this gist Feb 12, 2019.
    1 change: 1 addition & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    exports.flatten = (input) => input.toString().split(',').map(Number)
    5 changes: 5 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    const assert = require('assert')
    const { flatten } = require('./index')

    assert.deepEqual(flatten([[1, 2, [3]], 4]), [1, 2, 3, 4])
    assert.deepEqual(flatten([[1, 2, [3, 4]], 5]), [1, 2, 3, 4, 5])