I am new to JS and am trying to get a function to take the value of an array (at say index 0) and compare it to another array to find out how many times that value (index 0) is found in the other array, and add that number to a variable (currentCount += 1); then look at the next value (index 1) and do the same thing, etc… until all the index spots are reviewed. I have MOST of the code, but not sure how to loop through the whole comparing array before advancing to next index #. Any help would be appreciated.
PS - I have seen certain examples that use (what I will call) advanced JS, but my understanding is that I am only supposed to use what we have learned so far (1st Semester) - which has not included “reduce”, “.indexOf()”, “every”, “prototype”…etc.
A sample of what I have attempted to do is below (don’t laugh!):
function findZipCodeOccurance() {
"use strict";
// other variables and Arrays are listed GLOBALLY in main program...
var currentCount;
var index;
currentCount = INITIAL_VALUE;
for (index = 0; index < uniqueZipCodeArray.length; index += 1) {
if (uniqueZipCodeArray[index] === duplicateZipCodeArray) { // <-- not sure what should go here
currentCount += 1;
totalOccuranceArray[index] = currentCount + 1;
}
}
}