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.
"value.bikes"? Check console for errors..