Ad
const normalizeChance = (items) => items
    .reduce((acc, current, i) => {
      const last = acc [i-1];
      return [
        ...acc,
        {
          ...current,
          chance: current.chance + (last ? last.chance : 0)
        },
      ];
    }, []);

const raffel = (rng, items) => {
  const normalizedItems = normalizeChance(items);
  if(normalizedItems[normalizedItems.length-1].chance !== 1) throw new Error("Sum of chance should be equal to 1")
  return () => {
    const winningNumber = rng();
    const item = normalizedItems
      .find(({ chance }) => winningNumber <= chance)

    return {
      ...item,
      winningNumber,
    }
  }
}