-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamen9.js
More file actions
35 lines (35 loc) · 1007 Bytes
/
Copy pathexamen9.js
File metadata and controls
35 lines (35 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let autosImportados = require("./examen1");
const concesionaria = {
autos: autosImportados,
buscarAuto: function (patente) {
return this.autos.find((auto) => auto.patente === patente) || null;
},
venderAuto: function (patente) {
let auto = this.buscarAuto(patente);
if (auto) {
auto.vendido = true;
}
},
autosParaLaVenta: function () {
return this.autos.filter(function (auto) {
return !auto.vendido;
});
},
autosNuevos: function () {
return this.autosParaLaVenta().filter((auto) => auto.km < 100);
},
listaDeVentas: function () {
return this.autos.filter((auto) => auto.vendido).map((auto) => auto.precio);
},
totalDeVentas: function () {
return this.listaDeVentas().reduce(function (total, precio) {
return total + precio;
});
},
puedeComprar: function (auto, persona) {
return (
persona.capacidadDePagoTotal >= auto.precio &&
persona.capacidadDePagoEnCuotas >= auto.precio / auto.cuotas
);
},
};