function* repeatedArray(arr) {
let index = 0;
while (true) {
yield arr[index++ % arr.length];
}
}
const lifts = ['squat', 'bench', 'deadlift', 'press'];
const nextLiftGenerator = repeatedArray(lifts);
const numWeeks = 3;
const daysPerWeek = 6;
const totalNumSessions = numWeeks * daysPerWeek;
// This creates an empty array of totalNumSessions length
// for me to map over
const cycle = [...Array(totalNumSessions)].map(() => ({
lift: nextLiftGenerator.next().value,
}));
Created
July 10, 2018 16:11
-
-
Save andrit/62e6673247943ff88ac4246e212d580a to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment