Advertisement
MarcinMolenda

ZadaniaJSObiekty

Feb 15th, 2021 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Zadanie 1
  2.  
  3. const prod1 =
  4. {
  5.     name:"Chleb",
  6.     price: 2,
  7.     weight: 0.5
  8. };
  9.  
  10. const prod2 =
  11. {
  12.     name:"Dżem",
  13.     price: 4,
  14.     weight: 0.3
  15. };
  16. document.write ("Produkt numer jeden to: "+prod1.name+"<br>"+"Produkt numer dwa to: "+prod2.name+"<br>"+"Produkty kosztują razem: "+(prod1.price+prod2.price)+"zł"+"<br>"+"Produkty ważą razem: "+(prod1.weight+prod2.weight)+);
  17.  
  18. //Zadanie 2
  19.  
  20. const currentUser={
  21.     name:"Marcin",
  22.     surname:"Molenda",
  23.     email:"marcin.molenda17@wp.pl",
  24.     www:"localhost",
  25.     userType:"admin",
  26.     show(){
  27.         document.write("Imię: "+currentUser.name+"<br>"+"Nazwisko: "+currentUser.surname+"<br>"+"E-mail: "+currentUser.email+"<br>"+"Strona www: "+'<a href="http://localhost">'+currentUser.www+"</a>"+"<br>"+"Typ użytkownika: "+currentUser.userType);
  28.     }
  29. };
  30.         currentUser.show();
  31.  
  32. //Zadanie 3
  33.  
  34. const book={
  35.     title:"JavaScript i jQuery. Interaktywne strony WWW dla każdego.",
  36.     author:"J.Duckett",
  37.     pageCount: 648,
  38.     publisher:"Helion",
  39.  
  40.     showDetails(){
  41.         for(const key in book)
  42.     {
  43.         document.write((key)+": "+book[key]+"<br>");
  44.        
  45.     }
  46.     }
  47. };
  48. book.showDetails();
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement