objects-101.js 595 B

123456789101112131415161718192021222324252627282930
  1. let myBook = {
  2. title: '1984',
  3. author: 'George Orwell',
  4. pageCount: 326
  5. }
  6. console.log(`${myBook.title} by ${myBook.author}`)
  7. myBook.title = 'Animal Farm'
  8. console.log(`${myBook.title} by ${myBook.author}`)
  9. // Challenge area
  10. // name, age, location
  11. // name is age and lives in location
  12. // increase age by 1 and print message again
  13. let person = {
  14. name: 'Michael',
  15. age: 32,
  16. location: 'Canada'
  17. }
  18. console.log(`${person.name} is ${person.age} and lives in ${person.location}.`)
  19. person.age ++
  20. console.log(`${person.name} is ${person.age} and lives in ${person.location}.`)