10 XP challenge
Balance Positive and Negative Votes
easy
Build it yourself · 6 min
1 Learn2 Predict3 Solve
TaskYour mission
Return the count of positive values minus the count of negative values in numbers. Ignore zeros. numbers contains 0 to 30 integers from -100 to 100.
Examples
| Input | Return |
|---|---|
numbers = [8,-2,3]balance: 0 → 1 → 0 → 1. The result is 1. | 1 |
numbers = [-1,-9,2]balance: 0 → -1 → -2 → -1. The result is -1. | -1 |
Your code
Write your answer inside Solution, then use return to send it back.
Ln 1, Col 1
JavaScript
Try examples runs the public examples. Check my code checks your full answer and saves your completion.