Javascript Array removeFirst(elementToRemove)

Description

Javascript Array removeFirst(elementToRemove)


function solve(args) {
var input =  args,
firstElement=input[0];//from ww w  .j  av a 2  s. c  o  m
Array.prototype.removeFirst=function (elementToRemove) {
    var i,
    len=this.length;
    for(i=0; i<len; i+=1) {
        if(elementToRemove===this[i]){
            this.splice(i, 1)
            i-=1;
        }
    }
    return this;
}
input.removeFirst(firstElement);
    console.log(input.join("\n")); 
}



PreviousNext

Related