Advertisement
teofarov13

Untitled

Feb 10th, 2023
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sorting(arr) {
  2.  
  3.     let upDown = []
  4.  
  5.     arr.sort((a, b) => b - a)
  6.     while (arr.length > 0) {
  7.         let biggest = arr.shift()
  8.         upDown.push(biggest)
  9.         let smallest = arr.pop()
  10.         upDown.push(smallest)
  11.     }
  12.     console.log(upDown.join(" "))
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement