'set value to false if there is a duplicate
i don't know if there's a solution to this problem but here's what i want to do, i have this array
array=[
{'id': 1, 'isActive': true, 'name': apple},
{'id': 2, 'isActive': false, 'name': orange},
{'id': 3, 'isActive': false, 'name': apple},
{'id': 4, 'isActive': false, 'name': apple},
{'id': 5, 'isActive': false, 'name': orange},
{'id': 6, 'isActive': false, 'name': forest}
{'id': 7, 'isActive': false, 'name': forest}
]
i want to map through this array but i only want to show the array without duplicates but without changing the array ! i was thinking about adding another value so it will be like this
array=[
{'id': 1, 'isActive': true, 'name': apple, 'isShown': true},
{'id': 2, 'isActive': false, 'name': orange, 'isShown': true},
{'id': 3, 'isActive': false, 'name': apple, 'isShown': false},
{'id': 4, 'isActive': false, 'name': apple, 'isShown': false},
{'id': 5, 'isActive': false, 'name': orange, 'isShown': false},
{'id': 6, 'isActive': false, 'name': forest, 'isShown': true},
{'id': 7, 'isActive': false, 'name': forest, 'isShown': false},
]
I thought about this but i didn't know how to do it :x Any help or tips ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
