I have this AngularJS service.

```
demoService.getDemoData($scope.countEP).then(function (data) {
                console.log(data);
                for (var i = 0; i < data.length; i++) {
                    $scope.allEditorPicks.push(data[i]);
                }
            });

```

In this case,allEditorPicks is an array i have defined at the top of the code as follows.

> 
> $scope.allEditorPicks = [];
> 
> 
> 

Here's the problem, when I'm using this array and printing these data, the array has same items. Duplicating. So I need a way to check existing items and stop adding them in that allEditorPicks array. We need to do this inside the for loop. I tried adding another loop inside the for loop and read the allEditorPicks array and check. But that doesn't work too.

```
demoService.getDemoData($scope.countEP).then(function (data) {
                console.log(data);
                for (var i = 0; i < data.length; i++) {
                    for (var j = 0; j < $scope.allEditorPicks.length; j++) {
                        if ($scope.allEditorPicks[j].itemName == data[i].itemName) {
                            console.log("Item Exists")
                        } else {
                            $scope.allEditorPicks.push(data[i]);
                        }
                    }
                }
            });

```

This is the solution I tried. My browser got freezes and stopped working when I run this code. Please give me a solution.