JSFiddle - React, Tailwind, and code Playground
JavaScript
var Window = function(tabs) {
this.tabs = tabs; // We keep a record of the array inside the object
};
// When you close a tab
Window.prototype.tabClose = function (index) {
// Only change code below this line
var tabsBeforeIndex = this.tabs.splice(0, index); // Get the tabs before the tab
var tabsAfterIndex = this.tabs.splice(index + 1); // Get the tabs after the tab
this.tabs = tabsBeforeIndex.concat(tabsAfterIndex); // Join them together
// this.tabs = [...this.tabs.slice(0, index), ...this.tabs.slice(index+1)];
// Only change code above this line
return this;
};
var videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites
console.log(videoWindow.tabClose(2).tabs);