Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Boolean overview
- * if (a < b) {
- * // do this because it's true
- * } else {
- * // do this because it's false
- * }
- */
- const arr = [4,1,2,5,3,2];
- function ascendingSortBool(a,b) {
- return +(a > b) || -(a < b)
- }
- console.log(`Ascending -> `, .sort(ascendingSortBool)) // [ 1, 2, 2, 3, 4, 5 ]
Add Comment
Please, Sign In to add comment