Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Created January 29, 2017 20:43
Show Gist options
  • Save chrisdel101/76bd73c835dd257823e49ad54aeef566 to your computer and use it in GitHub Desktop.
Save chrisdel101/76bd73c835dd257823e49ad54aeef566 to your computer and use it in GitHub Desktop.
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