distanceBetween = (a, b) => {
  if (Number.isFinite(a) && Number.isFinite(b)) {
    return Math.abs(a - b)
  } else if (Array.isArray(a) && Array.isArray(b)) {
    if (a.length !== b.length) {
      throw new Error('The operands must have the same number of dimensions.')
    }
    let sum = 0
    for (let i = 0; i < a.length; i++) {
      sum += (b[i] - a[i]) * (b[i] - a[i])
    }
    return Math.sqrt(sum)
  } else {
    throw new Error('The operands must be of the same type, either number or array.')
  }
}
Calculates the Euclidean distance between two n-dimensional points.

@example
const distance = distanceBetween([0, 0], [0, 10]); // calculate distance between 2D points
console.log(distance); // output 10

@param {Array} a - first operand.
@param {Array} b - second operand.
@returns {Number} - distance.