From 5e0ecfd0b5539b0f9fc589856376eaffd83b0cad Mon Sep 17 00:00:00 2001 From: Satish Jhanwer Date: Tue, 23 Oct 2018 16:45:55 +0530 Subject: [PATCH] chore: added another solution for the 116 --- solutions/116.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/solutions/116.js b/solutions/116.js index ca5083b..e9643f1 100644 --- a/solutions/116.js +++ b/solutions/116.js @@ -16,6 +16,13 @@ const solution = (arr) => { return arr; }; +// Flatten a array +// Satish Jhanwer +// Check the performance on http://jsben.ch/ for below code +const flatten = (arr) => { + return Array.isArray(arr) ? Array.prototype.concat(...arr.map(flatten)) : arr; +}; + module.exports = { solution: solution, };