javascript Count the occurrences of a value in an array
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
// Examples
countOccurrences([2, 1, 3, 3, 2, 3], 2); // 2
countOccurrences(['a', 'b', 'a', 'c', 'a', 'b'], 'a'); // 3
Also in JavaScript:
- momentjs docs
- what is jsonwebtoken
- jest input value
- send data from form to another page angular
- how to do radio button validation in jquery
- how to check if an object from database is undefined in javascript
- how to compare javascript objects
- play audio javascript
- js add event listener
- deploy create react app pm2
- javascript return promise
- on click move item top react
- javascript test login password in bootstrap studio
- big o theory
- how to check if object exists in javascript
- node js how to basic auth to specific urk
- dynsmic calss in react add
- string to boolean javascript
- pdfjs customizing viewer.html js event handler
- Robux gift
- how to add oAuth google signin in react native app
- square root in javascript
- react native loading
- js replace all symbols in string