1
00:00:00,240 --> 00:00:04,110
Here's one more task for you, which is taken from the rail project.

2
00:00:04,230 --> 00:00:10,290
So this is not just some task for the interview, but the task that you will see in your everyday life.

3
00:00:10,650 --> 00:00:15,660
And as you can see from must map data to the front and format, which actually means we're getting our

4
00:00:15,660 --> 00:00:19,440
data, for example, from the back, not informant like we want.

5
00:00:19,740 --> 00:00:21,600
This is why we want to convert them.

6
00:00:21,870 --> 00:00:28,020
And the main element is location key, and we need to map all data to it and we will have it then five

7
00:00:28,020 --> 00:00:29,700
objects, as you can see here.

8
00:00:29,700 --> 00:00:33,540
First of all, we have a location array and here we have two objects.

9
00:00:33,810 --> 00:00:35,310
First of all, location key.

10
00:00:35,310 --> 00:00:41,970
And this is our unique identifier and we have here some ideas and outside and exactly the same in the

11
00:00:41,970 --> 00:00:42,810
second object.

12
00:00:43,080 --> 00:00:45,600
And now here we have a bulk configuration.

13
00:00:45,900 --> 00:00:49,830
So this is also the array with objects and inside every single object.

14
00:00:49,830 --> 00:00:52,650
We have a data values and confer key.

15
00:00:52,920 --> 00:00:58,740
The main point is that we're making them one to one, which actually means the ZOHRA Index in location

16
00:00:58,740 --> 00:01:01,590
array equals bulk config zero index.

17
00:01:01,800 --> 00:01:05,220
And in this case, we need to map everything to this structure.

18
00:01:05,310 --> 00:01:09,760
So at the end, we must get an array of objects with, first of all, config key.

19
00:01:09,780 --> 00:01:12,800
This is the spot and location key 32mm.

20
00:01:13,020 --> 00:01:19,080
As you can see, your location key 32 is that this part and also outer assigned from it, which actually

21
00:01:19,080 --> 00:01:21,540
means our a second element will also conflict.

22
00:01:21,540 --> 00:01:23,940
100 location key 22.

23
00:01:24,180 --> 00:01:28,590
This is our second number and then aside and so on and so on.

24
00:01:28,830 --> 00:01:34,740
And this is said the unique difference is this, which actually means we're getting here one two three

25
00:01:34,920 --> 00:01:36,360
four five objects.

26
00:01:36,510 --> 00:01:39,990
So at the end, we must have an array with five objects.

27
00:01:43,210 --> 00:01:48,040
Now, let's try to ride this logic, and actually we won't hear anything complicated here.

28
00:01:48,220 --> 00:01:49,900
It's all about data mapping.

29
00:01:50,140 --> 00:01:56,020
So let's right here our result as they want to do it directly result for loops inefficient way.

30
00:01:56,230 --> 00:02:02,080
And they want here to work with location just because inside we have our unique ideas and here in said

31
00:02:02,080 --> 00:02:06,700
location, we're getting map, which actually means we're looking through these objects.

32
00:02:06,940 --> 00:02:11,760
And here inside the map, we're getting location element and also where get in here?

33
00:02:12,200 --> 00:02:12,280
Index.

34
00:02:12,490 --> 00:02:14,920
This is why I must put additional brackets here.

35
00:02:15,280 --> 00:02:17,980
Solar case and index are what we need to.

36
00:02:18,190 --> 00:02:24,100
And now inside, we can do our magic because now inside location element, we're getting every single

37
00:02:24,100 --> 00:02:24,580
object.

38
00:02:24,790 --> 00:02:31,120
So we want here one more map because inside our location element, we want to move through our location

39
00:02:31,120 --> 00:02:31,510
key.

40
00:02:31,690 --> 00:02:34,750
This is where here we can return our location element.

41
00:02:34,960 --> 00:02:37,210
And here we have our location key.

42
00:02:37,540 --> 00:02:42,520
And here I also have a map and we have access to our location key.

43
00:02:42,700 --> 00:02:47,980
And as you can see, I wrote it with camel case because we are right in JavaScript code and typically

44
00:02:47,980 --> 00:02:50,080
all our variables are camel case.

45
00:02:50,620 --> 00:02:53,170
Here inside, we want to return what we need to.

46
00:02:53,260 --> 00:02:55,690
And first of all, we need here allocation key.

47
00:02:55,720 --> 00:02:58,180
This is why here I am, right in location key.

48
00:02:58,360 --> 00:03:01,480
We can live it with underscore like from beckoned over.

49
00:03:01,480 --> 00:03:02,980
Can convert it to uppercase.

50
00:03:02,980 --> 00:03:04,630
Just depends on what you want.

51
00:03:04,900 --> 00:03:07,480
And here we are, just assigning our location key.

52
00:03:07,870 --> 00:03:10,160
After this, we must get our config key.

53
00:03:10,390 --> 00:03:16,270
And this is extremely easy to do because here inside bulk config, we can just get this config key by

54
00:03:16,270 --> 00:03:16,780
index.

55
00:03:17,050 --> 00:03:23,440
This is where here we can write bulk config index because it is the same lake and location dot data

56
00:03:23,440 --> 00:03:25,300
values dot config key.

57
00:03:25,570 --> 00:03:32,410
And the last part is ultrasound and ultrasound, where getting inside location, element dot ultrasound.

58
00:03:32,770 --> 00:03:34,900
And this is how we mapped what we needed.

59
00:03:35,140 --> 00:03:41,030
So first of all, we have a map through our location, through this subject and in America for our location.

60
00:03:41,620 --> 00:03:45,990
This is why, for every single unique ID, we can map data that we need to.

61
00:03:46,210 --> 00:03:47,110
Let's check this out.

62
00:03:47,110 --> 00:03:48,750
I will write console.log here.

63
00:03:48,760 --> 00:03:49,540
Our result?

64
00:03:49,810 --> 00:03:50,260
Endless.

65
00:03:50,260 --> 00:03:51,190
Check if it's working.

66
00:03:51,400 --> 00:03:54,940
I'm reloading the page and we get an array of race.

67
00:03:55,210 --> 00:04:00,580
And in the first three, we're get an allocation key conflict, older, assign and all is good.

68
00:04:00,860 --> 00:04:06,610
The only problem that we have is that we get an array of race, but we actually want a flat array.

69
00:04:06,820 --> 00:04:13,030
This is why we must do something with this code and we can use here reduce to just create a flattery

70
00:04:13,180 --> 00:04:16,930
because we don't have fled the method natively inside JavaScript.

71
00:04:17,170 --> 00:04:19,930
So here we have our array and accumulator.

72
00:04:20,110 --> 00:04:23,320
And at the beginning, we can say that we get an empty array.

73
00:04:23,530 --> 00:04:27,490
And what we want to do inside is to use array dot concatenate.

74
00:04:27,700 --> 00:04:29,380
And here were concatenate in.

75
00:04:29,380 --> 00:04:30,490
This was accumulator.

76
00:04:30,820 --> 00:04:32,470
So what is done here by default?

77
00:04:32,470 --> 00:04:37,330
We have here empty array and we have every single array that you can see here.

78
00:04:37,630 --> 00:04:40,600
And we want to concatenate our array with accumulator.

79
00:04:40,750 --> 00:04:45,670
So essentially, for every single element Vulkan could donate and it was our accumulator.

80
00:04:45,850 --> 00:04:50,800
Let's check the time to load in the page and we're getting our flat array of subjects.

81
00:04:51,040 --> 00:04:55,840
And this is how you map data, for example, from in format to our frontend format.
