Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function Autos () {
  2. this.patente = "",
  3. this.peso = ""
  4. }
  5.  
  6. Autos.prototype.agregarPatente = function () {
  7. this.patente = prompt("Ingrese patente:");
  8. };
  9.  
  10. Autos.prototype.agregarPeso = function() {
  11. this.peso = prompt("Ingrese peso:");
  12. this.peso = parseInt(this.peso);
  13. };
  14.  
  15. var auto1 = new Autos();
  16.  
  17. auto1.agregarPatente();
  18. auto1.agregarPeso();
  19.  
  20. var auto2 = new Autos();
  21.  
  22. auto2.agregarPatente();
  23. auto2.agregarPeso();
  24.  
  25. var sumario = [];
  26.  
  27. sumario.push(auto1, auto2);
  28.  
  29. for (var i = 0; i < sumario.length; i++) {
  30. if (sumario[i].peso > 1000) {
  31. console.log("El auto es muy pesado para ser cargado!");
  32. }
  33. else if (sumario[0].patente == sumario[1].patente) {
  34. console.log("Las patentes son iguales");
  35. }
  36. else {
  37. console.log("Patente:", sumario[i].patente);
  38. console.log("Peso:", sumario[i].peso,"kg");
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement