MichalWalczak

Zadania JS obiekty

Mar 12th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Zadanie1
  2.  
  3. const prod1={
  4.   name: "Szynka",
  5.   price: 30,
  6.   weight: 1,
  7. }
  8. const prod2={
  9.   name: "Ziemniaki",
  10.   price: 20,
  11.   weight: 2,
  12. }
  13.  
  14. document.write("Produkt numer jeden to: "+prod1.name+"<br>");
  15. document.write("Produkt numer dwa to: "+prod2.name+"<br>");
  16. document.write("Kosztują razem:"+(prod1.price+prod2.price)+"zł <br>");
  17. document.write("Produkt numer jeden to: "+(prod1.weight+prod2.weight)+"kg<br>");
  18. //Zadanie2
  19.  
  20. const currentUser={
  21.   name: "Michał",
  22.   surname: "Walczak",
  23.   email: "[email protected]",
  24.   www: "localhost.com",
  25.   userType: "HeadAdmin",
  26.    show: function(){
  27.       document.write("Imię: "+currentUser.name+ "<br> Nazwisko: "+currentUser.surname+"<br> adres e-mail: "+currentUser.email+"<br> Adres strony WWW: "+currentUser.www+"<br> Typ Użytkownika: "+currentUser.userType+"<br>");
  28. }
  29. }
  30.  
  31. currentUser.show();
  32.  
  33. //Zadanie3
  34. const book={
  35.   name: "Silmarilion",
  36.   author: "J.R.R Tolkien",
  37.   pageCount: 482,
  38.   publisher: "Allen & Unwin",
  39.   showDetails: function(){
  40.   for(const key in book){
  41.   document.write(book[key]+"<br>");
  42.   }
  43.   }
  44.   }
  45.  
  46. book.showDetails();
  47.  
Advertisement
Add Comment
Please, Sign In to add comment