I have an array of different exercises:
exercises: {
push: ['Push up', 'Bench press'],
legs: ['Squat', 'Power squats'],
pull: ['Pull up', 'Chin up'],
cardioCore: ['Running high knees', 'Plank']
}
How can I combine all of these into a single array or object? I need to create this:
allExercises: ['Push up', 'Bench press', 'Squat', 'Power squats', 'Pull up', 'Chin up', 'Running high knees', 'Plank']
I'm also going to sort alphabetically so the order isn't important.
I think I could do this with a forEach, something like this:
let allExercises = [];
exercises.forEach(exerciseGroup=>{
allExercises.push(exerciseGroup);
});
But this feels a bit messy. Is there a nicer ES6 solution?
.concat().