function people(name,age){
return{
name:name,
age:age,
hello(){
alert(`hello my name ${this.name}`);
}
}
}
function car(name,color){
return{
model: name,
col: color,
people:names,
sit(names){
return{
people:name
}
},
start(){},
go(){},
stop(){},
leave(){}
}
class Car {
constructor(model, color) {
this.model = model
this.color = color
this.passengers = []
}
sit(passengers) {
this.passengers = this.passengers.concat(passengers)
}
}
class People {
constructor(name, age) {
this.name = name
this.age = age
}
greet() {
alert(`Hello, I'm ${this.name}`)
}
}
const boomer = new Car('BMW', 'black')
const alex = new People('Alex', '26')
const vika = new People('Vika', '27')
boomer.sit([alex, vika])
boomer.passengers.forEach(function (passenger) {
passenger.greet()
})