function Car(){ } Car.prototype.getSpeed = function (array = []) { if (array === undefined) return; let tempArr = []; for (let i = 0; i < array.length; i++) tempArr.push(array[i].speed); return tempArr; } Car.prototype.getMaxSpeed = function (arr = [], array = []) { if (array === undefined || arr === undefined) return; let tempArr = []; let tempMaxSpeed = Math.max(...arr); for (let i = 0; i < array.length; i++) if (arr[i] === tempMaxSpeed) tempArr.push(array[i]); return tempArr; } const arrayCar = [ {name: 'BMW', speed: 20, color: 'red'}, {name: 'Shkoda', speed: 110, color: 'green'}, {name: 'Dodge', speed: 110, color: 'blue'}, {name: 'Maz', speed: 60, color: 'black'}]; Car.prototype.getMaxSpeed(Car.prototype.getSpeed(arrayCar), arrayCar).forEach(element => { console.log(element) });