1
00:00:00,210 --> 00:00:02,040
You might get a task like this.

2
00:00:02,130 --> 00:00:07,860
Find the number of occurrences of minimum value in the list, which actually means we have an array

3
00:00:07,860 --> 00:00:13,980
of numbers and with first of all, must find the minimum value inside and then calculate how many times

4
00:00:13,980 --> 00:00:15,000
we have this value.

5
00:00:18,370 --> 00:00:23,860
And actually, if you will try to use here for a loop, then it will be really tedious because you need

6
00:00:23,860 --> 00:00:24,940
to use it twice.

7
00:00:25,090 --> 00:00:30,250
First of all, to find the minimum value inside the ray and secondly, to calculate how many times we

8
00:00:30,250 --> 00:00:31,630
have this value inside.

9
00:00:31,990 --> 00:00:37,270
This is where extra legroom must find a correct function inside JavaScript to solve it easier.

10
00:00:37,570 --> 00:00:42,280
And actually, we have such function in, say, JavaScript, and it is called math minimum.

11
00:00:42,580 --> 00:00:47,800
As you can see, here are passing inside several arguments and it will return fire to the smallest.

12
00:00:48,100 --> 00:00:51,940
This is why we can use this function, but it doesn't work with race.

13
00:00:52,330 --> 00:00:58,240
What we can do instead, we can write math minimum and we can't pass inside the array, but we can use

14
00:00:58,240 --> 00:01:02,620
a spread operator here and it will convert our array to arguments.

15
00:01:02,800 --> 00:01:06,970
So here we can have an array one two three and we're getting back one.

16
00:01:07,150 --> 00:01:09,040
And that is exactly what we wanted.

17
00:01:09,340 --> 00:01:14,710
This is why, as you can see in a single line, we can replace our for loop, which will be much more

18
00:01:14,710 --> 00:01:15,670
difficult to write.

19
00:01:16,000 --> 00:01:18,610
So first of all, here, let's name it, mean value.

20
00:01:18,940 --> 00:01:21,640
And here we want to call it on our rate.

21
00:01:21,850 --> 00:01:25,030
And let's create our array, which will be one two three.

22
00:01:25,300 --> 00:01:30,100
And here we want to spread out very sober, found our minimum value in there.

23
00:01:30,580 --> 00:01:36,360
Now how we can find how many times we have this value inside the rate and actually the easiest way here

24
00:01:36,370 --> 00:01:37,810
is by using filter.

25
00:01:37,990 --> 00:01:44,170
If we will filter our rate by this minimum item, we will get in the way of our minimum items.

26
00:01:44,410 --> 00:01:47,410
And then we simply can get a length of this rate.

27
00:01:47,680 --> 00:01:49,360
So it will look something like this.

28
00:01:49,630 --> 00:01:54,220
We can get here our minimum array and what we want to do is rate filter.

29
00:01:54,430 --> 00:01:56,920
And here we have access to every single element.

30
00:01:57,130 --> 00:02:01,180
And we just compare if our element equals our minimum value.

31
00:02:01,510 --> 00:02:05,710
In this case, inside me in the rainbow, we have only our minimum values.

32
00:02:05,980 --> 00:02:10,480
And now we can write here just console.log mean array dot length.

33
00:02:10,660 --> 00:02:16,660
And it will return for us exactly how many occurrences of this minimum value we have inside of rape.

34
00:02:16,930 --> 00:02:22,780
Let's check the SA time to load in the page where get in one, if we will add here one and one twice,

35
00:02:23,020 --> 00:02:24,580
then here we have three of them.

36
00:02:24,850 --> 00:02:29,710
And as you can see, our code is working and in three lines we solved our problem.

37
00:02:30,010 --> 00:02:34,870
This is why I highly recommend you to always try and find the right tool for the right jump.
