5 XP challenge
Alternate Plus and Minus
very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve
TaskYour mission
Return 1 - 2 + 3 - 4 + ... through n, with the sign determined by the counting number. n is 0 to 30.
Examples
| Input | Return |
|---|---|
n = 0 | 0 |
n = 1total: 0 → 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.