Skip to content

Instantly share code, notes, and snippets.

Nicolas Amabile nicolas-amabile

Block or report user

Report or block nicolas-amabile

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicolas-amabile
nicolas-amabile / flattenArray.js
Last active Apr 3, 2019
Flatten an array of nested arrays
View flattenArray.js
/*
* This function returns a flat array given an array of arbitrarily nested arrays
* e.g. [[1,2,[3]],4] -> [1,2,3,4].
*/
const flattenArray = arr => {
const result = []
arr.map(item => {
if (Array.isArray(item)) {
result.push(...flattenArray(item))
} else {
You can’t perform that action at this time.