Skip to content

Latest commit

 

History

History

is-odd

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

isOdd

Test if a value is an odd number.

Usage

var isOdd = require( '@stdlib/utils/is-odd' );

isOdd( value )

Tests if a value is an odd number, i.e. an integer that is not a multiple of two.

var bool = isEven( 6.0 );
// returns true

bool = isEven( new Number( 6.0 ) );
// returns true

bool = isEven( 3.0 );
// returns false

bool = isEven( -3.14 );
// returns false

bool = isEven( null );
// returns false

isEven.isPrimitive( value )

Tests if a value is a primitive even number.

var bool = isEven.isPrimitive( -4.0 );
// returns true

bool = isEven.isPrimitive( new Number( -4.0 ) );
// returns false

isEven.isObject( value )

Tests if a value is a Number object representing an even number.

var bool = isEven.isObject( 4.0 );
// returns false

bool = isEven.isObject( new Number( 4.0 ) );
// returns true

isEven.isEvenArray( value )

Tests if a value is a number array containing only even numbers.

var bool = isEven.isEvenArray( [ -4.0, new Number(4.0) ] );
// returns true

bool = isEven.isEvenArray( [ 4.0, '-4.0' ] );
// returns false

isEven.isPrimitiveIntegerArray( value )

Tests if a value is a primitive number array containing only even numbers.

var bool = isEven.isPrimitiveEvenArray( [ 2.0, -2.0 ] );
// returns true

bool = isEven.isPrimitiveEvenArray( [ 2.0, new Number(-2.0) ] );
// returns false

Examples

var isOdd = require( '@stdlib/utils/is-odd' );

console.log( isOdd( 5.0 ) );
// returns true

console.log( isOdd( 0.0 ) );
// returns false

console.log( isOdd( new Number( 5 ) ) );
// returns true

console.log( isOdd( 4.0 ) );
// returns false

console.log( isOdd( NaN ) );
// returns false

console.log( isOdd( '5' ) );
// returns false

console.log( isOdd( null ) );
// returns false