Javascript - Write program to Use the splice() method to remove elements from an array.

Requirements

Use the splice() method to remove "Orange" and "Apple" from fruits.

Here is the array

var fruits = ["Banana", "Orange", "Apple", "Kiwi"];

Hint

The splice() method takes 2 parameters: the index position to start at, and the number of elements to remove.

Array indexes start with 0.

Demo

var fruits = ["Banana", "Orange", "Apple", "Kiwi"];
console.log( fruits );/* w w w. j  a v a2s. c om*/
fruits.splice(1, 2);
console.log( fruits );

Result