Question: I have 2 arrays: cars & bikes.
I want to compare each element of car array to all the other elements of bike array, If both are equal, then alert true else false.

```
$scope.getComparison = function() {
$scope.bikes = ["1", "3", "3", "2", "6", "55", "45", "36", "18"];
angular.forEach($scope.bikes, function(value, key) {
    $scope.p_Id = value.bikes;
    $scope.cars = ["1", "2", "3", "4", "54", "55", "56", "56", "58"];
    angular.forEach($scope.cars, function(value, key) {
        $scope.b_Id = value.cars;
        if ($scope.p_Id == $scope.b_Id) {
            alert(b_Id + "=" + p_Id + "=" + "true");
        } else {
            alert(b_Id + "=" + p_Id + "=" + "false");
        }
    });
  });
};

```

Where am I wrong ? I need help.

Answer: 
You can use `forEach` & `indexOf` array methods to find the match

```
var _firstArray = ["1", "3", "3", "2", "6", "55", "45", "36", "18"];
var _secondArray=["1", "2", "3", "4", "54", "55", "56", "56", "58"];
_firstArray.forEach(function(item){
  if (_secondArray.indexOf(item) !==-1){
     console.log(item)  
  }
  else{
  console.log("not matched");
  }
})

```

Note: You can same array methods in your code

Check this [jsfiddle](https://jsfiddle.net/o1owo30u/3/)
There were some issue with your code, try below code and should work perfectly:

```
$scope.getComparison = function() {
                        $scope.bikes = ["1", "3", "3", "2", "6", "55", "45", "36", "18"];
                        angular.forEach($scope.bikes, function(value, key) {
                            $scope.p_Id = value;
                            $scope.cars = ["1", "2", "3", "4", "54", "55", "56", "56", "58"];
                            angular.forEach($scope.cars, function(value, key) {
                                $scope.b_Id = value;
                                if ($scope.p_Id == $scope.b_Id) {
                                    alert($scope.b_Id + "=" + $scope.p_Id + "=" + "true");
                                } else {
                                    alert($scope.b_Id + "=" + $scope.p_Id + "=" + "false");
                                }
                            });
                        });
                    };

```