Skip to content

Commit

Permalink
12 -optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
john-smilga committed Apr 25, 2021
1 parent 2312a0f commit df45f88
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions 12-optional-chaining/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const people = [
{
name: 'bob',
location: { street: '123 main street', timezone: { offset: '+7:00' } },
},
{ name: 'peter', location: { street: '123 Pine street' } },
{
name: 'susan',
location: { street: '123 Apple street', timezone: { offset: '+9:00' } },
},
]

people.forEach((person) => {
// console.log(person.name)
// console.log(person.location)
// console.log(person.location.street)
// console.log(person.location.timezone.offset)
// console.log(
// person.location &&
// person.location.timezone &&
// person.location.timezone.offset
// )
console.log(person?.location?.timezone?.offset)
})
14 changes: 14 additions & 0 deletions 12-optional-chaining/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Optional Chaining</title>
<link rel="stylesheet" href="../global.css" />
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<h2>Optional Chaining</h2>
<script src="app.js"></script>
</body>
</html>
Empty file added 12-optional-chaining/styles.css
Empty file.

0 comments on commit df45f88

Please sign in to comment.