-
Notifications
You must be signed in to change notification settings - Fork 0
/
task7.js
64 lines (54 loc) · 1.11 KB
/
task7.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//Activity 1:
let book={
'title':'Computer',
'author':'Soham',
'year': 2004,
};
console.log(book);
let acess=book.author;
console.log(acess);
//Activity 2:
const books={
book1:"Harry Potter",
author:"Soham Das",
result:function(){
console.log(`${this.book1} ${this.author}`);
}
};
books.result();
//Activity 3:
const library={
name:"Central Library",
books:[
{
name:"Harry Potter",
title:"Fairy tails",
year:2004,
},
{
name:"Cars",
title:"Scary tails",
year:2001,
},
],
};
console.log(library);
console.log(library.name);
console.log(library.books[0].title);
console.log(library.books[1].title);
//Activity 4:
const novel={
title: "Ikigai: The Japanese Secret to a Long and Happy Life",
author: "Héctor García",
year:2016,
getnovel(){
return `${this.title} and ${this.author}`
}
}
console.log(novel.getnovel());
//Activity 5:
for (let key in novel){
if(novel.hasOwnProperty(key)){
console.log(`${key}: ${novel[key]}`);
}
}