1
00:00:01,140 --> 00:00:01,620
All right.

2
00:00:01,620 --> 00:00:04,950
Let me show you how I'm going to solve this particular challenge.

3
00:00:04,980 --> 00:00:10,470
Well, this challenge didn't specify the format of the object.

4
00:00:10,470 --> 00:00:14,610
How you supposed to make it so we can create any object?

5
00:00:14,640 --> 00:00:15,330
Okay.

6
00:00:15,420 --> 00:00:17,910
So let's go by using the user object.

7
00:00:17,940 --> 00:00:18,400
Okay.

8
00:00:18,420 --> 00:00:23,280
You can make a book object or let's use book object for this time.

9
00:00:23,310 --> 00:00:23,910
Okay.

10
00:00:24,540 --> 00:00:27,300
So let's say cast book.

11
00:00:28,210 --> 00:00:30,340
Object is equal to.

12
00:00:30,520 --> 00:00:35,230
And now let's say the name of the book is called.

13
00:00:37,030 --> 00:00:39,670
Web development.

14
00:00:42,100 --> 00:00:45,150
Development Guide.

15
00:00:45,160 --> 00:00:51,670
You name the book and then let's see, the author of the book is I Knew Take.

16
00:00:53,790 --> 00:00:54,780
Academy.

17
00:00:55,110 --> 00:00:57,900
And then we can say number of pages.

18
00:00:57,900 --> 00:01:00,540
So number of pages.

19
00:01:00,750 --> 00:01:13,470
Let's say it's go to 5000 pages and then we can say the ISBN of the book is b, b, n, let's say quoting

20
00:01:13,890 --> 00:01:19,590
i n to file for it can be anything here as matter.

21
00:01:19,650 --> 00:01:22,140
So now we are finished creating our object.

22
00:01:22,350 --> 00:01:24,060
So the next one is what?

23
00:01:24,270 --> 00:01:28,550
Let's create a function to iterate over this particular object.

24
00:01:28,560 --> 00:01:35,580
So let me have my comment here and I will call this one solution solution.

25
00:01:35,580 --> 00:01:38,850
And then the next one is my function, right?

26
00:01:38,850 --> 00:01:42,870
So const I'm going to use function expression.

27
00:01:42,870 --> 00:01:48,420
So const print object, print object.

28
00:01:48,810 --> 00:01:54,030
Okay is equal to my function parentheses and my carry braces.

29
00:01:54,030 --> 00:01:59,760
This function will take in the object I'm going to pass into address over now inside.

30
00:01:59,760 --> 00:02:04,320
Remember, how can we get the properties of an object where have two ways of doing it?

31
00:02:04,320 --> 00:02:13,440
You can get you can use the object dot keys and then you can use the for loop to loop through them.

32
00:02:13,440 --> 00:02:19,200
But we have one method that going to make our life easier and that is for in loop.

33
00:02:19,380 --> 00:02:29,400
So for a next is let's is a special keyword and then a key is what I'm specifying or I want in my object

34
00:02:29,400 --> 00:02:33,960
that are passed in in the object when I call this particular function.

35
00:02:34,290 --> 00:02:40,530
And now inside I can cancel that, log back, take here my keys and my value.

36
00:02:40,740 --> 00:02:43,260
I write my keys and my value.

37
00:02:43,290 --> 00:02:47,070
So before I move on, let's try to console that log.

38
00:02:47,070 --> 00:02:49,410
The object there are passed in.

39
00:02:49,410 --> 00:02:52,050
For the meantime, let's move step by step here.

40
00:02:52,260 --> 00:02:55,650
Next is let me call the function called print object.

41
00:02:55,650 --> 00:02:58,380
Then I'll pass in my book object.

42
00:02:58,380 --> 00:02:59,970
That's what I'm trying to get.

43
00:03:00,120 --> 00:03:02,520
So if I save it now, check it out here.

44
00:03:02,520 --> 00:03:08,940
We have some beautiful result here because this one, it has printed out all the values here because

45
00:03:08,940 --> 00:03:17,220
let's have a look at the final one so that we have the object is the original object I pass in, which

46
00:03:17,220 --> 00:03:18,750
is this particular one.

47
00:03:18,750 --> 00:03:19,740
Which is this one.

48
00:03:19,740 --> 00:03:20,670
Let me show you here.

49
00:03:20,970 --> 00:03:25,500
This object is the object passing here and this object is this one.

50
00:03:25,740 --> 00:03:29,640
That's why I have them in my console as that.

51
00:03:29,730 --> 00:03:30,660
Did you get it?

52
00:03:30,780 --> 00:03:31,230
Yes.

53
00:03:31,230 --> 00:03:33,090
So what about the keys?

54
00:03:33,120 --> 00:03:36,900
Okay, so if I console the keys to here.

55
00:03:37,320 --> 00:03:43,080
If I console the keys, the keys represent this one's name, author pages and ISBN.

56
00:03:43,080 --> 00:03:49,740
So you see that I have the keys here, but I also want to console.log the value also.

57
00:03:49,770 --> 00:03:52,230
How am I going to get it?

58
00:03:52,440 --> 00:04:03,720
And remember guys, if we have the keys here, we can use the object and the key to get the value because

59
00:04:03,720 --> 00:04:10,290
the question says that we should print out the format, the key semicolon and the value.

60
00:04:10,320 --> 00:04:16,769
Meaning if you print out the key and a value in the console and here we have the key, what about the

61
00:04:16,769 --> 00:04:17,310
value?

62
00:04:17,310 --> 00:04:23,310
Remember how we can get I mean, properties of an object.

63
00:04:23,310 --> 00:04:27,180
You can use the dot notation or the square bracket.

64
00:04:27,630 --> 00:04:35,370
So for this one, okay, if I make use of objects here, then I say dot name.

65
00:04:36,060 --> 00:04:36,840
Let's see.

66
00:04:38,210 --> 00:04:41,300
Now you see that we got what?

67
00:04:41,300 --> 00:04:43,380
Web Development Guide?

68
00:04:43,400 --> 00:04:45,200
That's the name of the book.

69
00:04:45,770 --> 00:04:53,630
So if I also want the title, let's say the author is going to be the author of the book.

70
00:04:53,690 --> 00:04:54,440
Let her look.

71
00:04:54,560 --> 00:04:55,160
Yes.

72
00:04:55,160 --> 00:04:58,790
That we have the book title.

73
00:04:58,790 --> 00:05:04,520
And then the more you call it the the author of the book.

74
00:05:04,610 --> 00:05:13,270
So if I want those values, unless I duplicate many codes like this one with a dot notation, then I

75
00:05:13,270 --> 00:05:17,810
will say ISBN and then the number of pages.

76
00:05:18,560 --> 00:05:24,680
Now of pages if I save it, see that I have them being printed in in the console.

77
00:05:25,160 --> 00:05:29,390
So with this one, see that is making our life difficult.

78
00:05:29,390 --> 00:05:35,510
Assuming we have, let's say, 20 properties here, are we going to console.log everything here?

79
00:05:35,540 --> 00:05:43,250
That is why the bracket notation is really shine over here because with the bracket notation for getting

80
00:05:43,250 --> 00:05:46,700
the value from an object, it makes it more dynamic.

81
00:05:47,000 --> 00:05:51,890
So we are going to use that method because for that one, we're going to make it more flexible.

82
00:05:51,920 --> 00:05:52,610
Okay.

83
00:05:52,640 --> 00:05:55,430
So we can take now let's remove this one.

84
00:05:55,430 --> 00:05:59,750
So instead of using the dot notation, you're going to use the square bracket.

85
00:05:59,960 --> 00:06:05,320
And now I'm going to pass in the dynamic key, which is this one you see.

86
00:06:05,330 --> 00:06:11,660
So with this key is something like the object dot key and the key represent this one.

87
00:06:11,900 --> 00:06:12,620
Okay.

88
00:06:12,620 --> 00:06:16,550
So it's going to be the object dot key, which is this.

89
00:06:16,670 --> 00:06:18,290
Now this one is more dynamic.

90
00:06:18,470 --> 00:06:23,820
So if I console.log this one, you see that I have the values inside here.

91
00:06:23,840 --> 00:06:25,160
So what about the property?

92
00:06:25,550 --> 00:06:27,080
The key is really simple.

93
00:06:27,110 --> 00:06:28,910
I have the key here already.

94
00:06:29,120 --> 00:06:35,070
So one line of code using the this square bracket, I have the properties being console.log and then

95
00:06:35,210 --> 00:06:38,060
using the dot notation to repeat how many times?

96
00:06:38,060 --> 00:06:39,730
One, two, three, four times.

97
00:06:39,740 --> 00:06:43,550
So now I have this one so I can now use mine.

98
00:06:43,970 --> 00:06:50,410
Let me cut from here for the mean time use but take then main the dollar sign.

99
00:06:50,420 --> 00:06:52,490
Kerberos is in the key.

100
00:06:52,520 --> 00:06:53,030
Okay.

101
00:06:53,030 --> 00:06:54,950
Then I'll make a semicolon.

102
00:06:54,950 --> 00:06:55,850
And then.

103
00:06:56,750 --> 00:07:00,320
Mandela saying you now pace my lesson, but not this one.

104
00:07:00,440 --> 00:07:01,580
Let me start from scratch here.

105
00:07:01,610 --> 00:07:09,320
My dollar sign, percentage sign, my army cape raises, then my object, and then I'll pass in the

106
00:07:09,320 --> 00:07:10,790
key manuscript record.

107
00:07:10,790 --> 00:07:11,900
And then the key.

108
00:07:11,900 --> 00:07:12,890
And that is it.

109
00:07:12,890 --> 00:07:14,660
So if I save it, let's see.

110
00:07:14,660 --> 00:07:17,510
Indeed, we have achieved what we are supposed to do.

111
00:07:17,540 --> 00:07:21,350
We have the name semicolon and the property name and the value.

