Last active
March 22, 2020 04:02
-
-
Save krowter/d9ca28329e71d0c1484a07ffca0b433b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//array input | |
let input = [9, -1, 8, 3, -2, 9, 4, -3, 9] | |
//bilangan yang ingin kita pindahkan ke belakang | |
const numberToMove = 9 | |
input.sort((a,b) => { | |
if(b===9) { | |
return -1 | |
} else { | |
return 0 | |
} | |
}) | |
console.log(input) //output: [-1, 8, 3, -2, 4, -3, 9, 9, 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment