JSFiddle - React, Tailwind, and code Playground

by masaab algailani

JavaScript

var houseArray = ["house", "door", "lock", "window", "toilet"];

//remove item from original collection and also add item in  original collection
//returns array of removed items
var spliceArray = houseArray.splice(0,2,'kitchen');

for(var i = 0; i< houseArray.length; i++){
    alert("Items in houseArray: "+ houseArray[i]);  
}
for(var i = 0; i< spliceArray.length; i++){
    alert("Item in spliceArray: "+ spliceArray[i]);  
}