10 XP challenge
Insert One Item at a Position
easy
Build it yourself · 6 min
1 Learn2 Predict3 Solve
TaskYour mission
Return numbers with value inserted at position. Valid insertion positions are 0 through the list length, inclusive; position equal to length appends at the end. numbers has 0 to 30 integers from -100 to 100; value is in that range.
Examples
| Input | Return |
|---|---|
numbers = [1,3], position = 1, value = 2answer: [] → [1] → [1,2] → [1,2,3]. The result is [1,2,3]. | [1,2,3] |
numbers = [1,2], position = 2, value = 9answer: [] → [1] → [1,2] → [1,2,9]. The result is [1,2,9]. | [1,2,9] |
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.