Advertisement
vladovip

Sign Check

Feb 7th, 2021
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wrongResult(...nums) {
  2.  
  3.     recursiveSign(nums);
  4.  
  5.     function recursiveSign(nums, sign = 'Positive') {
  6.  
  7.         if (nums.length === 0 ) {
  8.  
  9.             console.log(sign);
  10.  
  11.             return;
  12.  
  13.         }
  14.  
  15.         let num = nums.pop();
  16.  
  17.         if (num === 0 ) {
  18.  
  19.             console.log('Positive');
  20.  
  21.             return;
  22.  
  23.         }
  24.  
  25.         if ((sign === 'Positive' && num > 0) || (sign === 'Negative' && num < 0)) {
  26.  
  27.             recursiveSign(nums, 'Positive');
  28.  
  29.         } else {
  30.  
  31.             recursiveSign(nums, 'Negative');
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement