-
Notifications
You must be signed in to change notification settings - Fork 0
/
day7.js
48 lines (40 loc) · 1.08 KB
/
day7.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const book1={
title : "Blue Lock",
author : "Someone from Japan",
year : "2023",
titleAuthor : ()=>{
console.log(`Name of the book ${book1.title} written by ${book1.author}`)
},
updateYear : ()=>{
book1.year = "2024"
console.log(`Updated year : ${book1.year}`)
},
titleAuthorThis : function(){
console.log(`Name of the book ${this.title} written by ${this.author}`)
}
}
console.log(`Name of the book ${book1.title}`)
console.log(`Author of the book ${book1.author}`)
book1.titleAuthor();
book1.updateYear();
const book2={
title : "Naruto",
author : "Someone from Japan",
year : "2023",
}
const library={
name : "Anime Library",
books : [
book1,
book2
]
}
console.log(library)
console.log(`Name of the library ${library.name}`)
library.books.map((ele)=>{console.log(`Name of the book ${ele.title}`)})
book1.titleAuthorThis();
for(const key in book1){
if(book1.hasOwnProperty(key)) console.log(`${key} : ${book1[key]}`)
}
console.log(Object.keys(book1))
console.log(Object.values(book2))