All matrix combination in javascript

  const combinations = courses.flatMap(course =>
    durations.flatMap(duration =>
      isMembers.flatMap(isMember =>
        isFreeHours.flatMap(isFreeHour => ({
          course,
          duration,
          isMember,
          isFreeHour
        }))
      )
    )
  );

If there is more combination, there will be more nesting, how to fix it?