Advertisement
Michal_Pilarski

obiekty w js

Feb 3rd, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. zad 1
  2. <!DOCTYPE html>
  3. <html lang="pl">
  4. <head>
  5. <meta charset="utf-8" />
  6. <script type="text/javascript">
  7. let prod1 =
  8. {
  9.     name: "Mleko",
  10.     price: 5,
  11.     weight: 0.3
  12. }
  13. let prod2 =
  14. {
  15.     name: "Ketchup",
  16.     price: 3,
  17.     weight: 0.2
  18. }
  19.  
  20. document.write("Produkt numer jeden to: ",prod1.name,"<br>");
  21. document.write("Produkt numer jeden to: ",prod2.name,"<br>");
  22. document.write("Produkty kosztuja razem: ",prod2.price+prod1.price,"<br>");
  23. document.write("Produkty waza razem: ",prod2.weight+prod1.weight);
  24.  
  25. </script>
  26. </head>
  27. <body>
  28. </body>
  29. </html>
  30.  
  31. zad 2
  32. <!DOCTYPE html>
  33. <html lang="pl">
  34. <head>
  35. <meta charset="utf-8" />
  36. <script type="text/javascript">
  37. let currentUser =
  38. {
  39.     name: "Michal",
  40.     surname: "Pilarski",
  41.     email: "michalpilarski17@gmail.com",
  42.     www: "www.sampleText.com",
  43.     userType: "Klient",
  44.     show: function()
  45.     {
  46.         document.write("Imie: ",this.name,"<br>");
  47.         document.write("Nazwisko: ",this.surname,"<br>");
  48.         document.write("Mail: ",this.email,"<br>");
  49.         document.write("Strona: ",this.www,"<br>");
  50.         document.write("Rodzaj uzytkownika: ",this.userType,"<br>");
  51.     }
  52. }
  53. currentUser.show();
  54.  
  55. </script>
  56. </head>
  57. <body>
  58. </body>
  59. </html>
  60.  
  61. zad 3
  62. <!DOCTYPE html>
  63. <html lang="pl">
  64. <head>
  65. <meta charset="utf-8" />
  66. <script type="text/javascript">
  67. let a = 0;
  68. let book =
  69. {
  70.     title: "Wiedzmin",
  71.     author: "Sapkowski",
  72.     pageCount: "300",
  73.     publisher: "ZSE",
  74.     showDetails: function()
  75.     {
  76.         for (const key in book)
  77.         {
  78.             a++;
  79.             if(a<5)
  80.             {
  81.                 document.write(key," ",book[key],"<br>");
  82.             }
  83.         }
  84.     }
  85. }
  86. book.showDetails();
  87.  
  88. </script>
  89. </head>
  90. <body>
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement