function getPositionWeightThroughLengthAndIndex(length, index) {
  if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
    return (index % 2 === 0) ? 3 : 1;
  }

  return (index % 2 === 0) ? 1 : 3;
}
Get position weight given:
EAN length and digit index/position

@param {number} length
@param {number} index
@return {number}