AreWe

WrongResult 2

Jun 11th, 2020
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wrongResult = (...nums) => {
  2.  
  3.     const isNegativeMultiply = (nums) => {
  4.         let negativeCount = 0;
  5.         for(let num of nums) {
  6.             if(num === 0) {
  7.                 return false;
  8.             } else if(num < 0) {
  9.                 negativeCount++;
  10.             }
  11.         }
  12.  
  13.         return negativeCount % 2 === 1;
  14.     };
  15.  
  16.     console.log( isNegativeMultiply(nums) ? 'Negative' : 'Positive' );
  17. };
Advertisement
Add Comment
Please, Sign In to add comment