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: 
**Not working!**

```
var _firstArray = ["1", "3", "3", "2", "6", "55", "45", "36", "18"];
var _secondArray=["1", "2", "3", "4", "54", "55", "56", "56", "58"];

var areEqual = true;

_firstArray.forEach(function(item) {
    if (!(item in _secondArray)) {
        areEqual = false;
    }
});
console.log(areEqual);

```

**EDIT**: I was wrong about the "in" operator. It only checks properties for a given object. 

`"45" in _firstArray` will result in `false`, but `0 in _firstArray` will result in `true` as `0` is a property for that array, `'length' in _firstArray` will result in `true` as well. Here is a working solution:

```
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(item1) {
    _secondArray.forEach(function (item2) {
        if (item1 === item2) {
            console.log(item1 + '=' + item2 + '=' + 'true');
        } else {
            console.log(item1 + '=' + item2 + '=' + 'false');
        }
    });
});

```
Comparing **each** element of 1 array with **each** element of another array?

2 **each**'s means use 2 loops thats it.