function countPositivesSumNegatives(input) { if (!input || input.length === 0) { return []; } var total1 = 0; var total2 = 0; for (i = 0; i < input.length; i++) { if (input[i] > 0) { total1 += 1; } if (input[i] < 0) { total2 += input[i]; } } return [total1, total2]; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter