DEV Community

Discussion on: Javascript Array Condensing

Collapse
mitchmalinin profile image
Mitchell Malinin

sortArray = (arr) => {
arr.reverse()
arr.forEach((singleElm,i)=>{
if(singleElm > 0){
arr.splice(i,1)
arr.unshift(singleElm)
}
})
return arr
}