1arr.splice(index, 0, item);
2//explanation:
3inserts "item" at the specified "index",
4deleting 0 other items before it
1var colors=["red","blue"];
2var index=1;
3
4//insert "white" at index 1
5colors.splice(index, 0, "white"); //colors = ["red", "white", "blue"]
6
1//HOW TO ADD:
2var num1 = 4;
3var num2 = 6;
4var answer = 4 + 6; //You can do num1 + num2 here!
5function add(num1, num2) {
6 return num1 + num2;
7};
8console.log("4 + 6 is: " + add());
9console.log("I hope this helped!");
1arr.splice(index, 0, item);
2// will insert item into arr at the specified index
3// (deleting 0 items first, that is, it's just an insert).