Daily-Interview-Question
Daily-Interview-Question copied to clipboard
myflatten
function myflatten(arr){
let res = []
let temp
while(arr.length > 0){
temp = arr.shift()
console.log("temp",temp);
if(temp instanceof Array){
arr.unshift(...temp)
}
else{
res.push(temp)
}
}
return res
}