{"ScriptPreparationCode":null,"TestCases":[{"Name":"With Array.splice","Code":"function arrayInsert(array, index, value) {\r\n array.splice(index, 0, value);\r\n}\r\n\r\nconst months = [\u0027Jan\u0027, \u0027March\u0027, \u0027April\u0027, \u0027June\u0027];\r\narrayInsert(months, 1, \u0027Feb\u0027);","IsDeferred":false},{"Name":"Tweaked version","Code":"function arrayInsert(array, index, value) {\r\n let end = array.length;\r\n while (end \u003E index) {\r\n const previousEnd = end - 1;\r\n array[end] = array[previousEnd];\r\n end = previousEnd;\r\n }\r\n array[index] = value;\r\n}\r\n\r\nconst months = [\u0027Jan\u0027, \u0027March\u0027, \u0027April\u0027, \u0027June\u0027];\r\narrayInsert(months, 1, \u0027Feb\u0027);","IsDeferred":false}]}