Skip to content

Commit c012ad6

Browse files
Merge pull request #16 from yashksaini-coder/backup
Merge Backup Co-authored-by: Garv Saini <garvkumarsaini@gmail.com>
2 parents 89534e0 + 2fb1356 commit c012ad6

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

Day7/Task.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ This workshop is divided into several activities:
1616

1717
### Activity 1: Object Creation and Access 🔍
1818

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.
2121

2222
### Activity 2: Object Methods 💡
2323

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.
2626

2727
### Activity 3: Nested Objects 🚀
2828

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.
3131

3232
### Activity 4: The `this` Keyword 🎯
3333

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.
3535

3636
### Activity 5: Object Iteration 🛠️
3737

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.
4040

4141
## Feature Requests (Optional) 🎨
4242

Day7/index.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,49 @@ book.updateYear = function(year) {
3636
console.log(book.updateYear("2021"));
3737

3838
console.log("-------------------------------------------------");
39-
console.log("Activity 3: ");
39+
console.log("Activity 3: ");
40+
41+
// 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+
const library = {
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);
58+
59+
60+
console.log("-------------------------------------------------");
61+
console.log("Activity 4: ");
62+
63+
// 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}.`;
67+
};
68+
69+
console.log(book.bookDetails());
70+
71+
console.log("-------------------------------------------------");
72+
console.log("Activity 5: ");
73+
74+
// Task 8: Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.
75+
76+
for (let key in book) {
77+
console.log(`${key}: ${book[key]}`);
78+
};
79+
80+
// Task 9: Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.
81+
82+
console.log("This is the keys:-"+Object.keys(book));
83+
console.log("This is the values:-"+Object.values(book));
84+

Day8/Task.md

Whitespace-only changes.

Day8/index.js

Whitespace-only changes.

0 commit comments

Comments
 (0)