Created
January 29, 2017 20:43
-
-
Save chrisdel101/76bd73c835dd257823e49ad54aeef566 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countPositivesSumNegatives(input) { | |
if (input == null){ | |
return [] | |
} else if (input == []){ | |
return Array.lenght === 0 | |
} else { | |
var blankArray = []; | |
var posCount = 0; | |
var negSum = 0; | |
for (var i = 0;i < input.length;i++){ | |
if (input[i] > 0){ | |
// console.log([i]) | |
posCount += 1; | |
// console.log(posCount) | |
} else { | |
negSum += input[i]; | |
} | |
} | |
blankArray.push(posCount, negSum) | |
return(blankArray); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment