• Returns a number constrained within a range.

    Parameters

    • num: number

      Number

    • Optional range: [number, number] = ...

      Range

    Returns number

    Example

    const n1 = Chalkboard.numb.constrain(2); // Returns 1
    const n2 = Chalkboard.numb.constrain(1); // Returns 1
    const n3 = Chalkboard.numb.constrain(0.5); // Returns 0.5
    const n4 = Chalkboard.numb.constrain(0); // Returns 0
    const n5 = Chalkboard.numb.constrain(-1); // Returns 0

Generated using TypeDoc