Javascript Array findYoungestPerson()

Description

Javascript Array findYoungestPerson()


Array.prototype.findYoungestPerson = function findYoungestPerson() {
        var youngest = this[0];

    for (var person = 1; person < this.length; person += 1) {

        if (this[person].age < youngest.age) {
            youngest = this[person];/*from w  ww. j av  a 2s  . c om*/
        }
    }

    return youngest;
};



PreviousNext

Related