The While loop is a way to iterate a block of code for a number of times until given condition is true. As condition evaluates as false the control will be out of while loop to the next line of code.
The indexOf method is used to search in arrays. You have to specify an element to be found in the given array and indexOf method will return its index in the array if that array contains the given element. If given search element does not exist in the array the indexOf method will return -1 value.
The splice method of the arrays is used to add new elements or remove existing elements from an array. The JS splice method also returns an array of removed elements.