Procházet zdrojové kódy

Finish objects101

Signed-off-by: Michael Tang <michael.h.tang@gmail.com>
Michael Tang před 5 roky
revize
e173c3712e
1 změnil soubory, kde provedl 30 přidání a 0 odebrání
  1. 30 0
      objects-101.js

+ 30 - 0
objects-101.js

@@ -0,0 +1,30 @@
+let myBook = {
+    title: '1984',
+    author: 'George Orwell',
+    pageCount: 326
+}
+
+console.log(`${myBook.title} by ${myBook.author}`)
+
+myBook.title = 'Animal Farm'
+
+console.log(`${myBook.title} by ${myBook.author}`)
+
+// Challenge area
+
+// name, age, location
+
+// name is age and lives in location
+// increase age by 1 and print message again
+
+let person = {
+    name: 'Michael',
+    age: 32,
+    location: 'Canada'
+}
+
+console.log(`${person.name} is ${person.age} and lives in ${person.location}.`)
+
+person.age ++
+
+console.log(`${person.name} is ${person.age} and lives in ${person.location}.`)