has()

Checks whether the value is in the range of a specified `Range` object

Range.prototype.has()

The has() method checks whether the value is in the range of a specified Range object.

range.class.ts
public has(value: number): boolean {
  return (
    (this.minLessThan(value) && this.maxGreaterThan(value)) ||
    value === this.min ||
    value === this.max
  );
}

Parameters

value:number

The value of number type to test.

Return type

Returns

The return value is a boolean indicating whether the given value is in the range of a specified Range object.

Example usage

// Example usage.
import { Range } from '@angular-package/range';

// Create new instance.
const range = new Range(4, 27);

// Returns false.
range.has(3);

// Returns true.
range.has(4);

// Returns false.
range.has(28);

// Returns true.
range.has(27);

Last updated