Advertisement
Guest User

Untitled

a guest
Jan 13th, 2024
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. две решения със .sort и със loop дават 100/100:
  2.  
  3. function sortNums(a, b, c){
  4.  
  5.     let array = [a, b, c];
  6.     array.sort((x, y) => y-x);
  7.     for(let i = 0; i < array.length; i++){
  8.         console.log(array[i]);
  9.     }
  10. }
  11. sortNums(2, 1, 3);
  12.  
  13.  
  14. function sortNums(a, b, c) {
  15.     if (a >= b && a >= c) {
  16.         console.log(a);
  17.  
  18.         if (b >= c) {
  19.             console.log(b);
  20.             console.log(c);
  21.         } else {
  22.             console.log(c);
  23.             console.log(b);
  24.         }
  25.     } else if (b >= a && b >= c) {
  26.         console.log(b);
  27.  
  28.         if (a >= c) {
  29.             console.log(a);
  30.             console.log(c);
  31.         } else {
  32.             console.log(c);
  33.             console.log(a);
  34.         }
  35.     } else {
  36.         console.log(c);
  37.  
  38.         if (a >= b) {
  39.             console.log(a);
  40.             console.log(b);
  41.         } else {
  42.             console.log(b);
  43.             console.log(a);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement