I would like to know if there is a native javascript code that does the same thing as this:
function f(array,value){
var n = 0;
for(i = 0; i < arr
Here is my solution without using an additional object and using reduce:
const occurrencesOf = (number,numbers) => numbers.reduce((counter, currentNumber)=> (number === currentNumber ? counter+1 : counter),0);
occurrencesOf(1, [1,2,3,4,5,1,1]) // returns 3
occurrencesOf(6, [1,2,3,4,5,1,1]) // returns 0
occurrencesOf(5, [1,2,3,4,5,1,1]) // returns 1