Function toBeCloseTo

  • check if the given value is close to the expected one

    Parameters

    • expected: number

      value to be compared with.

    • actual: number

      actual value to compare

    • Optionalprecision: number = 2

      float precision for the comparison

    Returns boolean

    if close to

    // test if the given value is close to 10
    if (math.toBeCloseTo(10, value)) {
    // do something
    }