Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. let input = [
  2. '1',
  3. '8',
  4. '5'
  5. ];
  6.  
  7. let print = this.print || console.log;
  8. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  9.  
  10. let firstNum = Number(gets());
  11. let secondNum = Number(gets());
  12. let thirdNum = Number(gets());
  13.  
  14. let totalSum = 0;
  15.  
  16. if (firstNum <= 1 && secondNum > 1 && thirdNum > 1) {
  17. totalSum = firstNum + secondNum * thirdNum;
  18. } else if (firstNum > 1 && secondNum <= 1 && thirdNum > 1) {
  19. totalSum = firstNum + secondNum * thirdNum;
  20. } else if (firstNum > 1 && secondNum > 1 && thirdNum <= 1) {
  21. totalSum = firstNum * secondNum + thirdNum;
  22. } else if (firstNum > 1 && secondNum > 1 && thirdNum > 1) {
  23. totalSum = firstNum * secondNum * thirdNum;
  24. }else{
  25. totalSum = firstNum + secondNum + thirdNum;
  26. }
  27. print(totalSum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement