Skip to content

Latest commit

 

History

History

count-same-value

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

countSameValue

Count the number of elements that are equal to a given value in an array.

Usage

var countSameValue = require( '@stdlib/array/base/count-same-value' );

countSameValue( x, value )

Counts the number of elements that are equal to a given value in an array.

var x = [ 0, 1, 0, 1, 2 ];

var out = countSameValue( x, 1 );
// returns 2

Examples

var sample = require( '@stdlib/random/sample' );
var countSameValue = require( '@stdlib/array/base/count-same-value' );

var x = sample( [ 1, 2, 3, 4, 5 ] );
console.log( x );

var n = countSameValue( x, 1 );
console.log( n );