You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Day7/Task.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -16,27 +16,27 @@ This workshop is divided into several activities:
16
16
17
17
### Activity 1: Object Creation and Access 🔍
18
18
19
-
-[]**Task 1:** Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console.
20
-
-[]**Task 2:** Access and log the `title` and `author` properties of the book object.
19
+
-[X]**Task 1:** Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console.
20
+
-[X]**Task 2:** Access and log the `title` and `author` properties of the book object.
21
21
22
22
### Activity 2: Object Methods 💡
23
23
24
-
-[]**Task 3:** Add a method to the book object that returns a string with the book's title and author, and log the result of calling this method.
25
-
-[]**Task 4:** Add a method to the book object that takes a parameter (year) and updates the book's year property, then log the updated object.
24
+
-[X]**Task 3:** Add a method to the book object that returns a string with the book's title and author, and log the result of calling this method.
25
+
-[X]**Task 4:** Add a method to the book object that takes a parameter (year) and updates the book's year property, then log the updated object.
26
26
27
27
### Activity 3: Nested Objects 🚀
28
28
29
-
-[]**Task 5:** Create a nested object representing a library with properties like `name` and `books` (an array of book objects), and log the library object to the console.
30
-
-[]**Task 6:** Access and log the name of the library and the titles of all the books in the library.
29
+
-[X]**Task 5:** Create a nested object representing a library with properties like `name` and `books` (an array of book objects), and log the library object to the console.
30
+
-[X]**Task 6:** Access and log the name of the library and the titles of all the books in the library.
31
31
32
32
### Activity 4: The `this` Keyword 🎯
33
33
34
-
-[]**Task 7:** Add a method to the book object that uses the `this` keyword to return a string with the book's title and year, and log the result of calling this method.
34
+
-[X]**Task 7:** Add a method to the book object that uses the `this` keyword to return a string with the book's title and year, and log the result of calling this method.
35
35
36
36
### Activity 5: Object Iteration 🛠️
37
37
38
-
-[]**Task 8:** Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.
39
-
-[]**Task 9:** Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.
38
+
-[X]**Task 8:** Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.
39
+
-[X]**Task 9:** Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.
// Task 5: Create a nested object representing a library with properties like `name` and `books` (an array of book objects), and log the library object to the console.
42
+
43
+
constlibrary={
44
+
name: "Library of Congress",
45
+
books: [
46
+
{
47
+
title: "EGO is the Enemy",
48
+
}
49
+
]
50
+
};
51
+
52
+
console.log(library);
53
+
54
+
// Task 6: Access and log the name of the library and the titles of all the books in the library.
55
+
56
+
console.log("The name of the library is:- "+library.name);
57
+
console.log("The titles of the books in the library are:- "+library.books[0].title);
// Task 7: Add a method to the book object that uses the `this` keyword to return a string with the book's title and year, and log the result of calling this method.
64
+
65
+
book.bookDetails=function(){
66
+
return`The book ${this.title} was published in ${this.year}.`;
0 commit comments