UNPKG

lenye_base

Version:

基础方法

11 lines (8 loc) 210 B
'use strict'; /** * Counts the occurrences of a value in an array. */ var countOccurrences = (arr, val) => { return arr.reduce((a, v) => v === val ? a + 1 : a, 0); }; module.exports = countOccurrences;