Question: I'm trying to compare a list of dictionaries to list and if there is a match increment rank. Is there a better way(more efficient way) to do this. My code:

```
requirements = ["JSF","JSP","Spring"]
Employee_records = [{'job_seeker_id': 1, 'skills': ['Spring', 'JSP', 'JSF'], 'experience': '5 years', 'location': 'stockholm', 'rank': 3}, {'job_seeker_id': 2, 'skills': ['Servlets', 'JSP'], 'experience': '2 years', 'location': 'gothenburg', 'rank': 1}, {'job_seeker_id': 3, 'skills': ['JSP'], 'experience': '4 years', 'location': 'lund', 'rank': 1}, {'job_seeker_id': 4, 'skills': ['Servlets'], 'experience': '3 years', 'location': 'malmo', 'rank': 0}, {'job_seeker_id': 5, 'skills': ['Hibernate', 'Servlets'], 'experience': '1 years', 'location': 'stockholm', 'rank': 0}]

for dict_ in Employee_records:
    for elm in dict_["skills"]:
        for skill in requirements:
            if elm == skill:
                dict_["rank"]+=1

```

Answer: 
This can be easily done without `lodash`. You can first flat the data then `map` it as a key value pair and then make use of `Map` to remove the duplicate entries:

```js
var data=[{ id: 'id-1', uniqueName: 'operation-level-1', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-2', label: 'operation-2-label' } ] }, { id: 'id-2', uniqueName: 'operation-level-2', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-3', label: 'operation-3-label' } ] }];

var result =  [...new Map(data.flatMap(({operations})=>operations).map(k=>([k.name, k]))).values()];

console.log(result);
```

Or if you do not want to use `Map` then use `filter` method:

```js
var data=[{ id: 'id-1', uniqueName: 'operation-level-1', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-2', label: 'operation-2-label' } ] }, { id: 'id-2', uniqueName: 'operation-level-2', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-3', label: 'operation-3-label' } ] }];

var result = data.flatMap(({operations})=>operations).filter((val,i,self)=>self.findIndex(j=>j.name==val.name && j.label==val.label)==i);

console.log(result);
```
Use `_.flatMap()` to get a flattened array of `operations`, and then use `_.uniqBy()` to get only items with unique `name`:

```js
const data=[{ id: 'id-1', uniqueName: 'operation-level-1', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-2', label: 'operation-2-label' } ] }, { id: 'id-2', uniqueName: 'operation-level-2', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-3', label: 'operation-3-label' } ] }];

const result =  _.uniqBy(
  _.flatMap(data, 'operations'),
  'name'
);

console.log(result);
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js"></script>
```

With lodash/fp you can generate a function using `_.flow()` that flattens `operations`, and then get the unique values by `name`:

```js
const fn = _.flow(
  _.flatMap('operations'),
  _.uniqBy('name')
)

const data=[{ id: 'id-1', uniqueName: 'operation-level-1', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-2', label: 'operation-2-label' } ] }, { id: 'id-2', uniqueName: 'operation-level-2', operations: [ { name: 'operaion-1', label: 'operation-1-label' }, { name: 'operaion-3', label: 'operation-3-label' } ] }];

const result = fn(data);

console.log(result);
```

```html
<script src='https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)'></script>
```