Radismela

ExchangeIfGreater

Oct 29th, 2021 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['5', '2'];
  2. // let input = ['3', '4'];
  3. // let input = ['5.5', '4.5'];
  4.  
  5. let print = this.print || console.log;
  6. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  7.  
  8. let a = Number(gets());
  9. let b = Number(gets());
  10.  
  11. if ( a > b){
  12.     let temp = a;  // the temporary variable that kept a-value
  13.     a = b;
  14.     b = temp;
  15. }
  16.  
  17. print(`${a} ${b}`)  // OUTPUT => 2 5
  18.  
Add Comment
Please, Sign In to add comment