UNPKG
@kowo0403hk/lotide
Version:
latest (1.0.1)
1.0.1
1.0.0
lotide library by LHL Bootcamp student
github.com/kowo0403hk/lotide
kowo0403hk/lotide
@kowo0403hk/lotide
/
flatten.js
17 lines
(15 loc)
•
271 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const
flatten
= (
arr
) => {
let
flat = [];
function
helper
(
arr
) {
for
(
let
item
of
arr) {
if
(
Array
.
isArray
(item)) {
helper
(item); }
else
{ flat.
push
(item); } } }
helper
(arr);
return
flat; };
module
.
exports
= flatten;