Advertisement
3vo

Problem 7. Sum of greatest and smallest

3vo
Oct 25th, 2022
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = [
  2.     '1',  // the input is always a string, so it's '3' and not 3
  3.     '2',
  4.     '3',
  5.  
  6. ];
  7. let print = this.print || console.log;
  8. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  9.  
  10. let num1 = +gets();
  11. let num2 = +gets();
  12. let num3 = +gets();
  13.  
  14. let greatNum = Math.max(num1, num2, num3);
  15. let smallestNum = Math.min(num1, num2, num3);
  16.  
  17. let sum = greatNum + smallestNum;
  18.  
  19. print(sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement