const maxIndex = (digits) => {
  let index = 0;
  digits.forEach((d, i) => {
    if (d > digits[index]) index = i;
  });