Advertisement
ErolKZ

Untitled

Sep 4th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1.  
  2. function addTogether() {
  3.  
  4.  
  5. let args = [... arguments];
  6.  
  7. let sum = 0;
  8.  
  9.  
  10.  
  11.  
  12.  
  13. console.log(typeof args[1] === Number);
  14.  
  15.  
  16. if (!Number.isInteger(args[0]) || !Number.isInteger(args[1]) && args.length > 1) {
  17.  
  18. return undefined;
  19.  
  20. } else if (args.length > 1) {
  21.  
  22. sum = args[0] + args[1];
  23.  
  24. } else if (args.length === 1) {
  25.  
  26. return x => Number.isInteger(x) ? x + args[0] : undefined;
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. console.log(args);
  37.  
  38.  
  39. return sum;
  40. }
  41.  
  42.  
  43.  
  44. console.log(addTogether(5)([7]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement