// Program that identifies common element(s) that exist within both two arrays

function intersection(firstArray, secondArray) {
	var hashMap = {};
	var commonElements = [];

	// create hashmap with elements of first array as keys
	arrOne.forEach(function(element) {
		hashMap[element] = 1;
	})
}



@@ -287,13 +287,371 @@
 = 1;%0A%09%7D)
+%0A%0A%09// use hashmap's O(1) look up time to check if an element in second array exists in the hash (i.e. first array)%0A%09secondArray.forEach(function(element) %7B // iterate through entire second array%0A%09%09if (hashMap%5Belement%5D === 1) %7B // if element in second array exists in hashmap%0A%09%09%09commonElements.push(element); // add matching element into output array%0A%09%09%7D%0A%09%7D);
 %0A%7D%0A%0A%0A

Use hashmap's O(1) look up time to check if an element in second array exists in the hash (i.e. first array), iterating through entire second array