/**
 * Returns the next bigger number from a sorted Array of numbers.
 * Returns null if num is the biggest number
 * @param {Number} idx
 * @param {Array<Number>} sortedArray
 */
export function getNextBiggerNumber(num, sortedArray) {
  for (let currentNumber of sortedArray) {
    if (currentNumber > num) return currentNumber
  }
  return null
}

/**
 * Returns the next smaller number from a sorted Array of numbers.
 * Returns null if num is the smallest number
 * @param {Number} idx
 * @param {Array<Number>} sortedArray
 */
export function getNextSmallerNumber(num, sortedArray) {
  let reversedArray = [...sortedArray].reverse()
  for (let currentNumber of reversedArray) {
    if (currentNumber < num) return currentNumber
  }
  return null
}

export function lastEntry(arr) {
  return arr[arr.length - 1]
}
