Okay I'm trying to search an array and find the duplicates and return the number of times each of the duplicates occurs. This is what I have so far, I need to pass in two arguments first the array being searched and then a specific term within that array:
countMatchingElements = function(arr, searchTerm){
var count = 0;
for(i = 0; i <= arr.length; i++){
count++;
}
return count;
};
Array I want to search:
var arrayToSearch = ['apple','orange','pear','orange','orange','pear'];