const colors: Record<string, number> = {
  black: 0,
  brown: 1,
  red: 2,
  orange: 3,
  yellow: 4,
  green: 5,
  blue: 6,
  violet: 7,
  grey: 8,
  white: 9,
};

export const decodedResistorValue = ([color1, color2, color3]: [
  string,
  string,
  string
]): string =>
  ((
    value1: number = colors[color1],
    value2: number = colors[color2],
    isSecondAZero = value2 === 0,
    noOfZeros: number = colors[color3] + (isSecondAZero ? 1 : 0)
  ): string =>
    ((
      isKilo: boolean = noOfZeros >= 3,
      remainingNoOfZeros = isKilo ? noOfZeros - 3 : noOfZeros
    ): string =>
      `${value1}${isSecondAZero ? "" : value2}${new Array(remainingNoOfZeros)
        .fill(0)
        .join("")} ${isKilo ? "kiloohms" : "ohms"}`)())();
