1
00:00:00,180 --> 00:00:03,540
You might get a cut in exercise to implement the range.

2
00:00:03,750 --> 00:00:04,830
What does it have a mean?

3
00:00:05,130 --> 00:00:07,530
It is a helper function, which looks like this.

4
00:00:07,770 --> 00:00:14,400
For example, if we are calling the range from one to 50, it will generate force energy one two, three

5
00:00:14,400 --> 00:00:17,850
four, five six and so on until 15.

6
00:00:18,060 --> 00:00:22,920
And this is actually a really nice helper when you need to generate some data, for example, you want

7
00:00:22,920 --> 00:00:24,720
to generate 50 random users.

8
00:00:24,990 --> 00:00:30,570
In this case, you simply generate such array and then for every single element you mapping in your

9
00:00:30,570 --> 00:00:31,310
random user.

10
00:00:31,650 --> 00:00:37,200
This is why this helper exists in almost all helper libraries like, for example, a dash or render.

11
00:00:40,400 --> 00:00:45,910
And obviously the easiest solution without thinking here is by using for loop, this is where you can

12
00:00:45,920 --> 00:00:52,220
ride this function like this, you have a function range and you have here start and end, for example,

13
00:00:52,220 --> 00:00:58,160
from one to 50 and then inside, we must try to follow up from start point to the end point.

14
00:00:58,430 --> 00:01:01,400
This is why here let I equals time.

15
00:01:01,420 --> 00:01:07,010
So we're not starting from zero, but from start here we're right and I less or equal end.

16
00:01:07,190 --> 00:01:13,550
And here we are making A-plus plus now inside this four loop, we must push every single index to our

17
00:01:13,550 --> 00:01:14,120
result.

18
00:01:14,390 --> 00:01:14,890
This is body.

19
00:01:14,900 --> 00:01:17,030
Let's create our let result.

20
00:01:17,330 --> 00:01:18,410
This is our array.

21
00:01:18,590 --> 00:01:24,650
Now inside, we can write results, push and we're pushing here our eye, and now we just return our

22
00:01:24,650 --> 00:01:25,160
result.

23
00:01:25,520 --> 00:01:29,600
This is how you can build the range function by using for Loop Let's Chicken Browser.

24
00:01:29,750 --> 00:01:36,860
I am right in here range function one comma 50 and we're getting our array from one to 50, which means

25
00:01:36,860 --> 00:01:42,080
our code is completely fine, but it is super low level and we can make it better.

26
00:01:42,380 --> 00:01:48,890
More advanced level is to leverage our rate so we can write in browser array and then our end, for

27
00:01:48,890 --> 00:01:49,340
example.

28
00:01:49,340 --> 00:01:49,820
50.

29
00:01:50,030 --> 00:01:56,240
And as you can see, this returns fast AMP territory where we have reserved 50 elements and what we

30
00:01:56,240 --> 00:01:58,370
can write after this dot keys.

31
00:01:58,640 --> 00:02:02,380
And now we are just calling this keys and we get an array iterate.

32
00:02:02,780 --> 00:02:09,110
Now, if we will try to spread this reiterate inside array, as you can see, we're getting our 50 keys

33
00:02:09,110 --> 00:02:11,210
starting from zero to 49.

34
00:02:11,390 --> 00:02:16,580
And after this, we simply need to map every single element and add our start point to it.

35
00:02:16,580 --> 00:02:18,230
So here we can write that map.

36
00:02:18,440 --> 00:02:21,170
And here we have every single element and where right?

37
00:02:21,170 --> 00:02:27,260
And Element plus tard in our case, for example, +1 and we're getting exactly the same outcome.

38
00:02:27,290 --> 00:02:29,600
This is an array from one to 50.

39
00:02:29,810 --> 00:02:32,630
This is why this variant is a little bit more advanced.

40
00:02:32,900 --> 00:02:37,280
So here we can create our range function and we're getting here, start and end.

41
00:02:37,520 --> 00:02:40,820
And now inside, we want to return this logic.

42
00:02:41,060 --> 00:02:46,520
And as you can see, this is an array where we are provided and we're making keys and we're spread in

43
00:02:46,520 --> 00:02:53,690
this array traitor inside our own USA and we're in every single element and we're adding here our start

44
00:02:53,700 --> 00:02:54,080
point.

45
00:02:54,350 --> 00:02:56,720
Let's reload the page and check if it's working.

46
00:02:56,930 --> 00:03:03,110
So I'm passing inside our range function one and 50, and we're getting a nice array from one to 15.

47
00:03:03,260 --> 00:03:07,430
And this is how people typically write this function inside help libraries.

48
00:03:07,580 --> 00:03:09,350
For example, Lambda Olivet.
