MarcinKrol

Zad 1 - 3 JS - Obiekty

Feb 3rd, 2021
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. const prod1 = {
  2. name : "Kustosz",
  3. price : 4.99,
  4. weight : 0.3
  5. }
  6.  
  7. const prod2 = {
  8. name : "Mąka",
  9. price : 4.99,
  10. weight : 1
  11. }
  12.  
  13. document.write(`Produkt numer 1 to: ${prod1["name"]}<br>`);
  14. document.write(`Produkt numer 2 to: ${prod2["name"]}<br>`);
  15. document.write(`Produkty kosztują razem: ${prod2["price"] + prod1["price"]} zł<br>`);
  16. document.write(`Produkty ważą razem: ${prod2["weight"] + prod1["weight"]} kg`);
  17.  
  18. const currentUser = {
  19. name : "Marcin",
  20. surname : "Król",
  21. email : "[email protected]",
  22. www: "github.com/marcin_krol",
  23. userType: "Male",
  24. show() {
  25. document.write(`Imię: ${this.name}<br>`);
  26. document.write(`Imię: ${this.surname}<br>`);
  27. document.write(`Imię: ${this.email}<br>`);
  28. document.write(`Imię: ${this.www}<br>`);
  29. document.write(`Imię: ${this.userType}<br>`);
  30. }
  31. };
  32.  
  33. currentUser.show();
  34.  
  35. const book = {
  36. title : "JavaScript - Interaktywne Aplikacje Internetowe",
  37. author : "Tomasz Sochacki",
  38. pageCount : 200,
  39. publisher : "Helion",
  40. showDetails() {
  41. for (const key in book){
  42. document.write(`${key} : ${this[key]} <br>`);
  43. }
  44. }
  45.  
  46. };
  47. book.showDetails();
Advertisement
Add Comment
Please, Sign In to add comment