Skip to content

Instantly share code, notes, and snippets.

@ahafidi
Created July 30, 2020 22:31
Show Gist options
  • Save ahafidi/fbb3d0a3ad650cce431089a37d72ce48 to your computer and use it in GitHub Desktop.
Save ahafidi/fbb3d0a3ad650cce431089a37d72ce48 to your computer and use it in GitHub Desktop.
const fibonacci = n =>
[...Array(n)].reduce(
(acc, val, i) => acc.concat( // concat returns the new acc
i > 1
? acc[i - 1] + acc[i - 2]
: i
),
[]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment