UNPKG

@mattseligman/lotide

Version:

Lotide is a mini clone of the Lodash Library to practice crating a personal npm package. It's like lodash, but without all that extra stuff. Just the things you need to start your project.

21 lines (16 loc) 405 B
const flatten = function(array) { let flattenedArray = []; const checkFlat = (array)=>{ for (let arrayIndex in array) { let isArray = Array.isArray(array[arrayIndex]); if (!isArray) { flattenedArray.push(array[arrayIndex]); } else { checkFlat(array[arrayIndex]); } } }; checkFlat(array); return flattenedArray; }; module.exports = flatten;