JAVASCRIPT, ARRAY: JavaScript algorithm that counts the total number of occurences of an integer in an array