Skip to content

Instantly share code, notes, and snippets.

@anthonybrown
Created September 14, 2019 15:16
Show Gist options
  • Save anthonybrown/735ecf75e272570d32134375e9616ccd to your computer and use it in GitHub Desktop.
Save anthonybrown/735ecf75e272570d32134375e9616ccd to your computer and use it in GitHub Desktop.

Revisions

  1. anthonybrown created this gist Sep 14, 2019.
    13 changes: 13 additions & 0 deletions getFirstLast.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function getFirstLast(array) {
    const {
    0: first,
    length: len,
    [len - 1]: last
    } = array

    return {first, last}
    }

    getFirstLast('Apple')

    getFirstLast(['apples', 'grapes', 'peaches', 'pears', 'cherries'])