Kacper_Michalak

Zadania JavaScript 5

Feb 7th, 2022 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //ZAD 1
  2. /*
  3. const oferta = {
  4.     marka:"Kia",
  5.     model:"Carens",
  6.     cena:60000,
  7.     koszt100km: function(){
  8.         return "37zł"
  9.     }
  10. }
  11.  
  12. document.write(oferta.koszt100km());
  13. */
  14.  
  15. //ZAD 2
  16. /*
  17. const pb95 = 6;
  18. const oferta = {
  19.     marka:"Kia",
  20.     model:"Carens",
  21.     cena:60000,
  22.     spalanie:8,
  23.     koszt100km: function(){
  24.         return this.spalanie * pb95
  25.     }
  26. }
  27.  
  28. document.write(oferta.koszt100km());
  29. */
  30.  
  31. //ZAD 3
  32. /*
  33. const oferta = {
  34.     marka:"Kia",
  35.     model:"Carens",
  36.     cena:60000,
  37.     spalanie:8,
  38.     koszt100km: function(){
  39.         return this.spalanie * pb95
  40.     },
  41.     wiekSamochodu:function(){
  42.         let x = prompt();
  43.          x = parseInt(x);
  44.         var d = new Date;
  45.          d = d.getFullYear();
  46.          d = parseInt(d);
  47.         return d - x;
  48.     }
  49. }
  50.  
  51. document.write(oferta.wiekSamochodu());
  52. */
  53.  
  54. // ZAD 4
  55.  
  56. const oferta = {
  57.     marka:"Kia",
  58.     model:"Carens",
  59.     cena:60000,
  60.     spalanie:8,
  61.     koszt100km: function(){
  62.         return this.spalanie * pb95
  63.     },
  64.     wiekSamochodu:function(){
  65.         let x = prompt();
  66.          x = parseInt(x);
  67.         var d = new Date;
  68.          d = d.getFullYear();
  69.          d = parseInt(d);
  70.         return d - x;
  71.     }
  72. }
  73.  
  74. function Oferta(mk,md,c,s)
  75. {
  76.     this.marka = mk;
  77.     this.model = md;
  78.     this.cena =c;
  79.     this.spalanie = s;
  80. }
  81.  
  82. const oferta1 = new Oferta("Volkswagen","Touran",20000,7);
  83. document.write(oferta1 + "<br>");
  84. document.write(oferta1.marka + " " + oferta1.model + " " + oferta1.cena + " " + oferta1.spalanie);
  85.  
Add Comment
Please, Sign In to add comment