Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
100
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. '185'
  3. ];
  4.  
  5. let print = this.print || console.log;
  6. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  7.  
  8. let arr = gets().split('').map(Number);
  9.  
  10. let firstNum = arr[0];
  11. let secondNum = arr[1];
  12. let thirdNum = arr[2];
  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