Skip to content

Instantly share code, notes, and snippets.

@yury
Forked from NaN1235123/test.rs
Created January 31, 2024 16:07
Show Gist options
  • Save yury/248a7df18a7a93443973629525f973ce to your computer and use it in GitHub Desktop.
Save yury/248a7df18a7a93443973629525f973ce to your computer and use it in GitHub Desktop.
Function for my uncle
function Unic(array) {
array.filter((item, index, arr) => {
if(item == -1) {
arr.splice(item)
arr.unshift(item)
}
})
return array
}
console.log(Unic([1,1,1,1,-1,-1,-1, -1, 1]))
// Вернет данный результат [-1, -1, -1, -1, -1,1, 1, 1, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment