@stdlib/assert-is-odd
v0.2.2
Published
Test if a value is an odd number.
Downloads
12
Readme
isOdd
Test if a value is an odd number.
Installation
npm install @stdlib/assert-is-odd
Usage
var isOdd = require( '@stdlib/assert-is-odd' );
isOdd( value )
Tests if a value
is an odd number
.
var Number = require( '@stdlib/number-ctor' );
var bool = isOdd( 5.0 );
// returns true
bool = isOdd( new Number( 5.0 ) );
// returns true
bool = isOdd( 6.0 );
// returns false
bool = isOdd( -3.14 );
// returns false
bool = isOdd( null );
// returns false
bool = isOdd( NaN );
// returns false
isOdd.isPrimitive( value )
Tests if a value
is an odd primitive number.
var Number = require( '@stdlib/number-ctor' );
var bool = isOdd.isPrimitive( -5.0 );
// returns true
bool = isOdd.isPrimitive( new Number( -5.0 ) );
// returns false
isOdd.isObject( value )
Tests if a value
is a Number
object having an odd number value.
var Number = require( '@stdlib/number-ctor' );
var bool = isOdd.isObject( 5.0 );
// returns false
bool = isOdd.isObject( new Number( 5.0 ) );
// returns true
Examples
var Number = require( '@stdlib/number-ctor' );
var isOdd = require( '@stdlib/assert-is-odd' );
var bool = isOdd( 5.0 );
// returns true
bool = isOdd( new Number( 5 ) );
// returns true
bool = isOdd( 0.0 );
// returns false
bool = isOdd( 4.0 );
// returns false
bool = isOdd( NaN );
// returns false
bool = isOdd( '5' );
// returns false
bool = isOdd( null );
// returns false
See Also
@stdlib/assert-is-even
: test if a value is an even number.
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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.