0.1.1 • Published 2 months ago

@stdlib/array-base-count-falsy v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

countFalsy

NPM version Build Status Coverage Status

Count the number of falsy elements in an array.

Installation

npm install @stdlib/array-base-count-falsy

Usage

var countFalsy = require( '@stdlib/array-base-count-falsy' );

countFalsy( x )

Counts the number of falsy elements in an array.

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

var out = countFalsy( x );
// returns 2

Examples

var bernoulli = require( '@stdlib/random-array-bernoulli' );
var countFalsy = require( '@stdlib/array-base-count-falsy' );

var x = bernoulli( 100, 0.5, {
    'dtype': 'generic'
});
console.log( x );

var n = countFalsy( x );
console.log( n );

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.