Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Autos () {
- this.patente = "",
- this.peso = ""
- }
- Autos.prototype.agregarPatente = function () {
- this.patente = prompt("Ingrese patente:");
- };
- Autos.prototype.agregarPeso = function() {
- this.peso = prompt("Ingrese peso:");
- this.peso = parseInt(this.peso);
- };
- var auto1 = new Autos();
- auto1.agregarPatente();
- auto1.agregarPeso();
- var auto2 = new Autos();
- auto2.agregarPatente();
- auto2.agregarPeso();
- var sumario = [];
- sumario.push(auto1, auto2);
- for (var i = 0; i < sumario.length; i++) {
- if (sumario[i].peso > 1000) {
- console.log("El auto es muy pesado para ser cargado!");
- }
- else if (sumario[0].patente == sumario[1].patente) {
- console.log("Las patentes son iguales");
- }
- else {
- console.log("Patente:", sumario[i].patente);
- console.log("Peso:", sumario[i].peso,"kg");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement