1
00:00:00,790 --> 00:00:01,940
Welcome back.

2
00:00:01,960 --> 00:00:04,840
Let me show you how I'm going to solve this challenge.

3
00:00:05,020 --> 00:00:08,560
Well, this challenge is indeed a challenge.

4
00:00:08,800 --> 00:00:15,190
We need to think and use most of the arithmetic that we have talked about.

5
00:00:15,400 --> 00:00:20,110
So it says that create a function to remove all duplicate values.

6
00:00:20,530 --> 00:00:21,550
Oh, my God.

7
00:00:21,580 --> 00:00:22,780
How is it possible?

8
00:00:22,810 --> 00:00:24,070
Okay, so let's.

9
00:00:24,070 --> 00:00:26,620
Let's go step by step.

10
00:00:26,710 --> 00:00:30,310
So first, let's see, we have our arrays of duplicate value.

11
00:00:30,340 --> 00:00:30,930
Let's say this.

12
00:00:30,940 --> 00:00:41,500
My array cost array data here is equal to let's say I have this, let's say two, four, 624, four,

13
00:00:41,500 --> 00:00:43,510
five, eight, nine.

14
00:00:43,510 --> 00:00:46,030
See that we have some duplicate values.

15
00:00:46,300 --> 00:00:49,270
For example, we have four here, four here, four here.

16
00:00:49,270 --> 00:00:51,310
Four and two has appeared 2 to 2.

17
00:00:51,340 --> 00:00:53,650
I want to remove those values.

18
00:00:53,650 --> 00:00:55,940
So now this is my sample data.

19
00:00:55,960 --> 00:00:58,090
So here comes the function.

20
00:00:58,510 --> 00:01:00,100
So function.

21
00:01:02,510 --> 00:01:04,940
Remove duplicates.

22
00:01:06,670 --> 00:01:07,450
Then.

23
00:01:08,800 --> 00:01:11,530
My parentheses and then my carry braces.

24
00:01:11,530 --> 00:01:14,350
This function should take in the array.

25
00:01:14,440 --> 00:01:16,720
I want to remove this, which is this one.

26
00:01:17,260 --> 00:01:18,730
So now here comes.

27
00:01:20,440 --> 00:01:24,910
Next is we need to remove the value switch here.

28
00:01:24,940 --> 00:01:28,020
Remove duplicates.

29
00:01:29,390 --> 00:01:29,920
Good.

30
00:01:29,930 --> 00:01:33,200
So cost, let's say, duplicate.

31
00:01:34,200 --> 00:01:34,890
By that.

32
00:01:35,830 --> 00:01:37,180
Duplicates removed.

33
00:01:38,550 --> 00:01:42,250
Is equal to let me say duplicate whatever.

34
00:01:42,270 --> 00:01:46,500
I think sometimes the naming convention is equal to.

35
00:01:47,460 --> 00:01:47,780
Now.

36
00:01:47,790 --> 00:01:49,860
Here comes first.

37
00:01:50,250 --> 00:01:54,150
I need to take the highway or pass in my area.

38
00:01:54,180 --> 00:01:54,820
Dot.

39
00:01:55,380 --> 00:02:03,300
I want to filter out that so dot filter because it says that create a new array with all the duplicates

40
00:02:03,300 --> 00:02:04,110
removed.

41
00:02:04,560 --> 00:02:10,860
So here I'm going to be the let me say a filtered, filtered the more precise filtered data.

42
00:02:11,430 --> 00:02:12,120
Yes.

43
00:02:12,270 --> 00:02:14,220
So here on the array.

44
00:02:14,220 --> 00:02:17,920
On the array, I have filter how to few automated sorry.

45
00:02:17,940 --> 00:02:22,920
And then for the filter, I'm going to pass in the callback function.

46
00:02:23,250 --> 00:02:26,970
And remember as that and then my parenthesis.

47
00:02:27,330 --> 00:02:27,900
Good.

48
00:02:27,900 --> 00:02:33,480
So inside my callback function before I can filter out.

49
00:02:33,510 --> 00:02:34,650
Let's see the logic.

50
00:02:35,880 --> 00:02:42,900
Well, I need to get the entire array itself in my filter out.

51
00:02:43,260 --> 00:02:43,980
Okay.

52
00:02:44,070 --> 00:02:55,320
And after that, I'm going to use the index off to check the element which is equal to the index of

53
00:02:55,320 --> 00:02:56,790
the individual record.

54
00:02:56,790 --> 00:02:59,760
Then it means that it has been faded out.

55
00:03:00,180 --> 00:03:02,340
So here, inside a callback.

56
00:03:02,340 --> 00:03:07,140
As for the reduce, we can have access to the element itself.

57
00:03:07,200 --> 00:03:08,890
Meaning the actual record here.

58
00:03:08,910 --> 00:03:09,600
Data here.

59
00:03:10,400 --> 00:03:11,990
And this is the index.

60
00:03:12,000 --> 00:03:13,580
Index for the index.

61
00:03:13,580 --> 00:03:15,170
Meaning at which point.

62
00:03:16,160 --> 00:03:19,210
Can we find that particular record in the array?

63
00:03:19,220 --> 00:03:20,560
That's an index.

64
00:03:20,570 --> 00:03:24,770
And then I have the original array that has been passed in.

65
00:03:25,190 --> 00:03:26,730
So to try out here.

66
00:03:26,750 --> 00:03:28,850
Let's console.log all these.

67
00:03:30,250 --> 00:03:35,470
So first one let me console.log the l the elements as that.

68
00:03:35,470 --> 00:03:40,150
So let me copy this one three times and show you.

69
00:03:41,570 --> 00:03:42,440
These ones.

70
00:03:42,440 --> 00:03:49,550
So we always say ID X for index when I bring the original array as my original array.

71
00:03:49,760 --> 00:03:51,470
So let's save it and let's see.

72
00:03:51,980 --> 00:03:58,990
Well, unless I call it a function, so come down here called remove duplicates, remove duplicate,

73
00:03:59,000 --> 00:04:05,810
then I'll pass in the array data because I want to call it and see and pass in this data to have this

74
00:04:05,810 --> 00:04:07,210
logic to operate on.

75
00:04:07,220 --> 00:04:07,640
Okay.

76
00:04:07,820 --> 00:04:10,550
So if I save it now, let's have a look.

77
00:04:11,120 --> 00:04:15,620
You can see that for the first one we have the element, which is two.

78
00:04:16,510 --> 00:04:17,800
That is the first one.

79
00:04:18,490 --> 00:04:24,490
The elements and the index is at what point does this work occurs at index zero.

80
00:04:24,490 --> 00:04:26,920
So here we have two and zero.

81
00:04:27,310 --> 00:04:29,740
That's why we have the index or which zero.

82
00:04:29,980 --> 00:04:37,240
And this array is an original array from two forces, two, four, four, five, eight, nine four which

83
00:04:37,240 --> 00:04:41,230
is this two forces 222445894.

84
00:04:41,260 --> 00:04:41,980
That is it.

85
00:04:41,980 --> 00:04:46,720
So now that we've got that one, next is now let's remove this one.

86
00:04:47,620 --> 00:04:48,190
Good.

87
00:04:48,400 --> 00:04:53,830
So we want to also go ahead and filter again this one.

88
00:04:54,830 --> 00:04:56,060
Soft vitrine.

89
00:04:56,210 --> 00:05:06,860
So here we going to use the let's return from here return here and then on the array dot index of remember

90
00:05:06,860 --> 00:05:08,630
the index of how we do it.

91
00:05:09,380 --> 00:05:14,960
The index of is used to determine at which position this particular element worked.

92
00:05:14,990 --> 00:05:18,170
If it returns zero, it means it doesn't exist.

93
00:05:18,470 --> 00:05:19,040
Right.

94
00:05:19,040 --> 00:05:25,280
But if it is going to give us some kind of give us, let's say, the index of that particular element

95
00:05:25,280 --> 00:05:26,180
we are searching for.

96
00:05:26,360 --> 00:05:28,580
So an index of.

97
00:05:29,150 --> 00:05:30,020
Of what?

98
00:05:30,440 --> 00:05:31,820
Of the element.

99
00:05:33,050 --> 00:05:40,070
So here, if I return this one, let's see if this one going to retain the actual element or given the

100
00:05:40,070 --> 00:05:42,730
index at which this element occurred.

101
00:05:42,740 --> 00:05:49,670
For the meantime, let's consider the log inside my function, the filtered data here.

102
00:05:51,300 --> 00:05:52,220
Take data here.

103
00:05:52,230 --> 00:05:53,100
So let's see.

104
00:05:54,120 --> 00:05:59,880
Now you see that I got it because all of them has an array that's indexed.

105
00:06:00,240 --> 00:06:05,430
So now I want to go ahead and measure that if in this record here.

106
00:06:06,310 --> 00:06:09,520
If the if it is equal to the index.

107
00:06:10,410 --> 00:06:18,390
So let me console.log the index again for to see here console.log the index, which is the index.

108
00:06:18,390 --> 00:06:19,230
So let's see.

109
00:06:19,800 --> 00:06:21,210
Oh yeah.

110
00:06:21,270 --> 00:06:24,690
It's I know I need to come in here.

111
00:06:24,690 --> 00:06:26,040
It's outside my function.

112
00:06:26,040 --> 00:06:26,910
So here.

113
00:06:27,450 --> 00:06:28,170
Yes.

114
00:06:28,170 --> 00:06:31,320
So the first one is the index and the actual response here.

115
00:06:31,350 --> 00:06:39,480
Now you can see we have zero one, two, three, four.

116
00:06:39,480 --> 00:06:41,310
So if you see that.

117
00:06:42,040 --> 00:06:44,050
Is there a net zero in this one?

118
00:06:44,080 --> 00:06:44,830
No.

119
00:06:45,660 --> 00:06:46,770
What about one?

120
00:06:47,040 --> 00:06:47,790
No.

121
00:06:47,970 --> 00:06:49,080
What about two?

122
00:06:49,260 --> 00:06:49,980
No.

123
00:06:50,130 --> 00:06:51,120
About three?

124
00:06:51,150 --> 00:06:51,840
No.

125
00:06:51,990 --> 00:06:52,950
What about four?

126
00:06:52,980 --> 00:06:53,700
Yes.

127
00:06:54,250 --> 00:06:57,180
So I'm going to filter out to go for a password.

128
00:06:57,390 --> 00:07:00,480
This, this and this and this.

129
00:07:00,870 --> 00:07:02,000
Okay, so this.

130
00:07:02,030 --> 00:07:02,730
I'm going to do.

131
00:07:02,820 --> 00:07:07,950
So inside this retain if it is equal to.

132
00:07:08,130 --> 00:07:08,610
Yeah.

133
00:07:08,670 --> 00:07:11,370
Is equal to the index.

134
00:07:11,810 --> 00:07:13,510
That means that it has been.

135
00:07:13,590 --> 00:07:14,600
It exists.

136
00:07:14,610 --> 00:07:18,940
Then we can filter out those records.

137
00:07:19,080 --> 00:07:22,650
So now if I save this one.

138
00:07:22,650 --> 00:07:23,610
Now let's see.

139
00:07:24,030 --> 00:07:25,200
Let's refresh it.

140
00:07:25,240 --> 00:07:27,580
Now something has happened.

141
00:07:27,600 --> 00:07:28,740
Now this one.

142
00:07:29,020 --> 00:07:30,840
Remove this one from here and let's see.

143
00:07:31,610 --> 00:07:32,900
Now we see that.

144
00:07:33,200 --> 00:07:34,610
Do we have duplicate again?

145
00:07:34,640 --> 00:07:35,750
No, we don't have.

146
00:07:35,960 --> 00:07:39,590
So you have two, four, six, five, eight, nine.

147
00:07:39,600 --> 00:07:45,200
We don't have two, two and four, four in it anymore because here we have filter out that.

148
00:07:45,560 --> 00:07:47,030
So that is it.

149
00:07:47,030 --> 00:07:54,260
So if knowing this way we can come down here and let's say let's say the because and return from this

150
00:07:54,260 --> 00:07:57,680
function, return the filtered data.

151
00:07:58,100 --> 00:07:58,300
Yeah.

152
00:07:58,430 --> 00:08:03,770
So now I can assign cause the results equal to that.

153
00:08:04,280 --> 00:08:05,230
And now.

154
00:08:06,840 --> 00:08:11,790
Let's console.log the response.

155
00:08:11,880 --> 00:08:12,600
Let's see.

156
00:08:13,860 --> 00:08:22,170
And before let's also console.log the original array, which is this one and let's compare now let's

157
00:08:22,170 --> 00:08:25,110
see we see that now this origin array.

158
00:08:26,040 --> 00:08:28,680
Now there is no duplicate.

159
00:08:28,680 --> 00:08:32,159
Again, we have quality here but here have to two here original one.

160
00:08:32,159 --> 00:08:33,840
We have one for fall.

161
00:08:33,840 --> 00:08:38,400
Here we have one that's about the filtering duplicate values.

162
00:08:38,760 --> 00:08:40,110
Then this video.

163
00:08:40,140 --> 00:08:44,760
Let's have our last coding challenge about letters.

