10 XP challenge
Weight Values by Their Position
easy
Build it yourself · 6 min
1 Learn2 Predict3 Solve
TaskYour mission
Return numbers[0] * 1 + numbers[1] * 2 + numbers[2] * 3, continuing to the end. Empty input returns 0. numbers contains 0 to 20 integers from -20 to 20.
Examples
| Input | Return |
|---|---|
numbers = [2,3]total: 0 → 2 → 8. The result is 8. | 8 |
numbers = [3,2]total: 0 → 3 → 7. The result is 7. | 7 |
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.