Skip to content

Instantly share code, notes, and snippets.

@hannahhch
Created June 5, 2020 14:54
Show Gist options
  • Select an option

  • Save hannahhch/8f921fc87df0165ae4c27aa1d65d8d15 to your computer and use it in GitHub Desktop.

Select an option

Save hannahhch/8f921fc87df0165ae4c27aa1d65d8d15 to your computer and use it in GitHub Desktop.

Exercise Exercises

Given the exercise data:

const exercises = {
  "Forward Lunge": {
    musclesTargeted: ["quadriceps", "gluteus", "adductor magnus"],
    difficultyLevel: 5
  },
  "Reverse Lunge": {
    musclesTargeted: ["quadriceps", "gluteus", "adductor magnus"],
    difficultyLevel: 5
  },
  "Pushup": {
    musclesTargeted: ["pectorals", "triceps", "anterior deltoids"],
    difficultyLevel: 7
  },
  "Squat": {
    musclesTargeted: ["quadriceps", "gluteus ", "hamstrings"],
    difficultyLevel: 7
  },
  "Burpee": {
    musclesTargeted: ["hamstrings", "quadriceps", "calves", "triceps", "pectorals", "quadriceps"],
    difficultyLevel: 10
  },
  "Plank": {
    musclesTargeted: ["abdominal", "erector spinae"],
    difficultyLevel: 8    
  }  
};

Level One

Write a function to output all of the exercise names for exercises that have a difficulty level of 7. The output should look like:

["Pushup", "Squat"];

Level Two

Modify your function to rearrange the data and output exercises grouped by their difficulty level. The output should look something like:

{
  5: ["Forward Lunge", "Reverse Lunge"],
  7: ["Pushup", "Squat"],
  8: ["Plank"],
  10: ["Burpee"]
};

Level Three

Modify your function to return a list of all of the exercises with only their last two musclesTargeted:

{ 
  Forward Lunge: ['gluteus', 'adductor magnus'],
  Reverse Lunge: ['gluteus', 'adductor magnus'],
  Pushup: ['triceps', 'anterior deltoids'], 
  Squat: ['gluteus ', 'hamstrings'],
  Burpee: ['pectorals', 'quadriceps'],
  Plank: ['abdominal', 'erector spinae']
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment