how can I find the times that 1 (for example) is repeated in this array?
myArray = [1, 2, 3, 1, 4, 5, 1, 6];
how can I find the times that 1 (for example) is repeated in this array?
myArray = [1, 2, 3, 1, 4, 5, 1, 6];
Try this solution
function getOccurrence(myArray, value) {
var count = 0;
myArray .forEach((val) => (val === value && count++));
return count;
}