Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDN object tutorial
  • Loading branch information
nlz18001 committed Feb 23, 2024
1 parent 31c1b3a commit 580795a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions week-06/oojs.html
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>MDN Object Tutorial</title>
</head>

<body>
<script>
const person = {
name: {
first: "Bob",
last: "Smith",
},
age: 32,
bio() {
console.log(`${this.name.first} ${this.name.last} is ${this.age} years old.`);
},
introduceSelf() {
console.log(`Hi! I'm ${this.name.first}.`);
},
};
const myDataName = "height";
const myDataValue = "1.75m";
person[myDataName] = myDataValue;

const person1 = {
name: "Chris",
introduceSelf() {
console.log(`Hi! I'm ${this.name}.`);
},
};
const person2 = {
name: "Deepti",
introduceSelf() {
console.log(`Hi! I'm ${this.name}.`);
},
};

function Person(name) {
this.name = name;
this.introduceSelf = function () {
console.log(`Hi! I'm ${this.name}.`);
};
}
</script>
</body>

</html>

0 comments on commit 580795a

Please sign in to comment.