Skip to content

Activity 5 completed for Day-8 #22

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 1 commit into from
Jul 20, 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
33 changes: 32 additions & 1 deletion Day8/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,35 @@ function product(a, b = 1) {
return a * b;
}

console.log(`Product of 5 and 2: ${product(5, 2)}`);
console.log(`Product of 5 and 2: ${product(5, 2)}`);

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

// Task 8: Use enhanced object literals to create an object with methods and properties, and log the object to the console.

let person = {
name: "Linus",
age: 30,
greet() {
console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
}
};

person.greet();

// Task 9: Create an object with computed property names based on variables and log the object to the console.

const prop1 = "firstName";
const prop2 = "lastName";
const prop3 = "age";

// Create an object with computed property names
const details = {
[prop1]: "John",
[prop2]: "Doe",
[prop3]: 30
};

// Log the object to the console
console.log(details);