10 XP challenge
Total Readings Before the Stop Signal
easy
Build it yourself · 6 min
1 Learn2 Predict3 Solve
TaskYour mission
Add the readings in numbers only until the first -1, excluding the -1 and everything after it. If no -1 appears, add all readings. numbers contains 0 to 30 values, each either -1 or an integer from 0 to 100.
Examples
| Input | Return |
|---|---|
numbers = [2,3,-1,9]total: 0 → 2 → 5. The result is 5. | 5 |
numbers = [-1,8] | 0 |
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.