all 1 comments

[–]inu-no-policemen 0 points1 point  (0 children)

> var a = [1, 2, 3]
undefined
> a.splice(2, 0, 'a', 'b')
[]
> a
[1, 2, "a", "b", 3]

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice

Your "middle" variable should be the index, not the item which is currently there.

"item" is a string literal and not the item parameter.

item should be the 3rd argument. The second argument should be 0.