Skip to content

Merge Backup #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Day7/Task.md
Original file line number Diff line number Diff line change
@@ -16,27 +16,27 @@ This workshop is divided into several activities:

### Activity 1: Object Creation and Access 🔍

- [ ] **Task 1:** Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console.
- [ ] **Task 2:** Access and log the `title` and `author` properties of the book object.
- [X] **Task 1:** Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console.
- [X] **Task 2:** Access and log the `title` and `author` properties of the book object.

### Activity 2: Object Methods 💡

- [ ] **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.
- [ ] **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.
- [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.
- [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.

### Activity 3: Nested Objects 🚀

- [ ] **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.
- [ ] **Task 6:** Access and log the name of the library and the titles of all the books in the library.
- [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.
- [X] **Task 6:** Access and log the name of the library and the titles of all the books in the library.

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

- [ ] **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.
- [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.

### Activity 5: Object Iteration 🛠️

- [ ] **Task 8:** Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.
- [ ] **Task 9:** Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.
- [X] **Task 8:** Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.
- [X] **Task 9:** Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.

## Feature Requests (Optional) 🎨

47 changes: 46 additions & 1 deletion Day7/index.js
Original file line number Diff line number Diff line change
@@ -36,4 +36,49 @@ book.updateYear = function(year) {
console.log(book.updateYear("2021"));

console.log("-------------------------------------------------");
console.log("Activity 3: ");
console.log("Activity 3: ");

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

const library = {
name: "Library of Congress",
books: [
{
title: "EGO is the Enemy",
}
]
};

console.log(library);

// Task 6: Access and log the name of the library and the titles of all the books in the library.

console.log("The name of the library is:- " + library.name);
console.log("The titles of the books in the library are:- " + library.books[0].title);


console.log("-------------------------------------------------");
console.log("Activity 4: ");

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

book.bookDetails = function() {
return `The book ${this.title} was published in ${this.year}.`;
};

console.log(book.bookDetails());

console.log("-------------------------------------------------");
console.log("Activity 5: ");

// Task 8: Use a `for...in` loop to iterate over the properties of the book object and log each property and its value.

for (let key in book) {
console.log(`${key}: ${book[key]}`);
};

// Task 9: Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object.

console.log("This is the keys:-"+Object.keys(book));
console.log("This is the values:-"+Object.values(book));

Empty file added Day8/Task.md
Empty file.
Empty file added Day8/index.js
Empty file.