A question, that it helps me to outsource a property, I have created a total property with the method get, but for what is necessary? Since doing a method I can call it the same with () and return what I want, instead of getting total () I do total () and already, I do not see much the novelty of the method get
class Factura {
constructor(divisa, nombre, importe, IVA = importe * .1) {
this._divisa = divisa;
this._nombre = nombre;
this._importe = importe;
this._IVA = IVA;
}
presentacion (){
return ' La factura ' + this._nombre + ' tiene un importe de ' + this._importe + ' ' + this._divisa + ' y con el IVA, se queda en '
}
get total(){
return this._importe + this._IVA;
}
// totalDescuento(){
// return this._importe + this._IVA -
// }
}
let factura1 = new Factura('eur', 'Transportes Chemita', 300);
let factura2 = new Factura('eur', 'Transportes Fran', 600);
let factura3 = new Factura('eur', 'Transportes Ailyn', 900);
let factura4 = new Factura('eur', 'Transportes alvaro', 9000);
let factura5 = new Factura('eur', 'Transportes carlos', 9200);
let factura6 = new Factura('eur', 'Transportes pepito', 9100);
document.write(factura1.presentacion() + factura1.total + ' eur' + '<br>');
document.write(factura2.presentacion() + factura2.total + ' eur' + '<br>');
document.write(factura3.presentacion() + factura3.total + ' eur' + '<br>');
document.write(factura4.presentacion() + factura4.total + ' eur' + '<br>');
document.write(factura5.presentacion() + factura5.total + ' eur' + '<br>');
document.write(factura6.presentacion() + factura6.total + ' eur' + '<br>');