var newArr=[];
function flattern(list,depth){
list.forEach(item=>(
depth === 0 ? newArr.push(item) :
typeof item==='object' ? flattern(item,depth-1) : newArr.push(item)
))
return newArr;
}