forked from bpd01001/dmd-3475-assignment-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
function createPerson(name) { | ||
const obj = {}; | ||
obj.name = name; | ||
obj.introduceSelf = function () { | ||
console.log(`Hi! I'm ${this.name}.`); | ||
}; | ||
return obj; | ||
} | ||
|
||
const person1 = { | ||
name: ["Hongchan", "Lee"], | ||
age: 30, | ||
eyes: "black", | ||
height: "1.85m", | ||
bio() { | ||
console.log(`${this.name[0]} ${this.name[1]} is ${this.age} years old.`); | ||
}, | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name[0]}.`); | ||
} | ||
}; | ||
|
||
person1.farewell = function () { | ||
console.log("Goodbye everybody!"); | ||
}; | ||
|
||
const person2 = { | ||
name: ["James", "Hush"], | ||
age: 28, | ||
eyes: "blue", | ||
height: "1.79m", | ||
bio() { | ||
console.log(`${this.name[0]} ${this.name[1]} is ${this.age} years old.`); | ||
}, | ||
introduceSelf() { | ||
console.log(`Hi! I'm ${this.name[0]}.`); | ||
} | ||
}; | ||
|
||
person2.farewell = function () { | ||
console.log("It's time to say Goodbye!"); | ||
}; | ||
|
||
function logProperty(propertyName) { | ||
console.log(person[propertyName]); | ||
} | ||
|
||
logProperty("name"); | ||
|
||
logProperty("age"); | ||
|
||
|
||
const objectName = { | ||
member1Name: member1Value, | ||
member2Name: member2Value, | ||
member3Name: member3Value, | ||
}; | ||
|
||
const myDiv = document.createElement("div"); | ||
const myVideo = document.querySelector("video"); | ||
|
||
const myNotification = new Notification("Hello!"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>Object-oriented JavaScript example</title> | ||
</head> | ||
|
||
<body> | ||
<p>This example requires you to enter commands in your browser's JavaScript console (see <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools">What are browser developer tools</a> for more information).</p> | ||
|
||
<script src="js/script.js"></script> | ||
|
||
</body> | ||
|
||
</html> |