Skip to content

Commit 6f4ace8

Browse files
Merge pull request #22 from yashksaini-coder/backup
Activity 5 completed for Day-8 Co-authored-by: Garv Saini <garvkumarsaini@gmail.com>
2 parents 3f9ee89 + 1bf3fa1 commit 6f4ace8

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Day8/index.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,35 @@ function product(a, b = 1) {
6969
return a * b;
7070
}
7171

72-
console.log(`Product of 5 and 2: ${product(5, 2)}`);
72+
console.log(`Product of 5 and 2: ${product(5, 2)}`);
73+
74+
console.log("-------------------------------------------------");
75+
console.log("Activity 5: ");
76+
77+
// Task 8: Use enhanced object literals to create an object with methods and properties, and log the object to the console.
78+
79+
let person = {
80+
name: "Linus",
81+
age: 30,
82+
greet() {
83+
console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
84+
}
85+
};
86+
87+
person.greet();
88+
89+
// Task 9: Create an object with computed property names based on variables and log the object to the console.
90+
91+
const prop1 = "firstName";
92+
const prop2 = "lastName";
93+
const prop3 = "age";
94+
95+
// Create an object with computed property names
96+
const details = {
97+
[prop1]: "John",
98+
[prop2]: "Doe",
99+
[prop3]: 30
100+
};
101+
102+
// Log the object to the console
103+
console.log(details);

0 commit comments

Comments
 (0)