Advertisement
Spocoman

01. Sort Numbers

Jan 15th, 2022 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(first, second, third) {
  2.  
  3.     for (let i = 0; i < 3; i++) {
  4.  
  5.         if (first > second && first > third) {
  6.             console.log(first);
  7.             first = Number.MIN_VALUE;
  8.         } else if (second > first && second > third) {
  9.             console.log(second);
  10.             second = Number.MIN_VALUE;
  11.         } else{
  12.             console.log(third);
  13.             third = Number.MIN_VALUE;
  14.         }
  15.     }
  16. }
  17.  
  18. Решение с масив и няколко метода:
  19.  
  20. function solve(first, second, third) {
  21.  
  22.     let print = [first, second, third].sort().reverse();
  23.  
  24.     for (let i = 0; i < 3; i++){
  25.         console.log(print[i]);
  26.     }
  27. }
  28.  
  29. Тарикатско решение:
  30.  
  31. function solve(first, second, third) {
  32.  
  33.     console.log([first, second, third].sort().reverse().join(`\n`));
  34.  
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement