题解 | #添加元素#
添加元素
http://www.nowcoder.com/practice/941bcfa5b87940869fda681c1597fd3a
function insert(arr, item, index) {
var newArr=[]
for(let i=0;i<arr.length;i++){
if(i===index){
newArr.push(item)
}
newArr.push(arr[i])
}
return newArr
}
添加元素
http://www.nowcoder.com/practice/941bcfa5b87940869fda681c1597fd3a
function insert(arr, item, index) {
var newArr=[]
for(let i=0;i<arr.length;i++){
if(i===index){
newArr.push(item)
}
newArr.push(arr[i])
}
return newArr
}
相关推荐