SyntaxFix
Write A Post
Hire A Developer
Questions
Solution by recursion
function count(arr, value) { if (arr.length === 1) { return arr[0] === value ? 1 : 0; } else { return (arr.shift() === value ? 1 : 0) + count(arr, value); } } count([1,2,2,3,4,5,2], 2); // 3