function Car teg none this teg teg Car prototype getSpeed function arr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Car(teg = 'none') {
this.teg = teg;
}
Car.prototype.getSpeed = function(array = []) {
let tempArr = [];
for (let i = 0; i < array.length; i ++)
tempArr.push(array[i].speed);
for (let i = 0; i < array.length; i ++)
if (tempArr[i] === Math.max(...tempArr))
console.log(array[i]);
}
const arrayCar = [ {name: 'BMW', speed: 20, color: 'red'},
{name: 'Shkoda', speed: 110, color: 'green'},
{name: 'Dodge', speed: 50, color: 'blue'},
{name: 'Maz', speed: 60, color: 'black'}];
Car.prototype.getSpeed(arrayCar);