0

The api I am working with returns an array of exercises in a workout and another array that provides an array of the completed exercises in the workout.

So far I have been able log out the int values if the exercise ID's, compare the values in the arrays to see if the ID is present in both arrays and return a truthy value.

What I need and havn't been able to do is get the ID of those exercises that are not completed(falsey) values.

How can I achieve this?

Example of my code below:

let curExGroups = this.props.activeWorkout.grouped[0];
let curExercises = curExGroups && curExGroups.map(exId => exId.id);
console.log('curExercises', curExercises);

const completedExercises = this.props.exerciseCompletion;
let completedExerciseId = Object.keys(completedExercises);

let completedExerciseIdParsed = completedExerciseId.map(exIdParsed => parseInt(exIdParsed, 10));

My current output is:

curExercises (2) [7465, 7467]
completedExerciseIdParsed [7465]
true

So what I am looking for in this instance is the exercise that has not been completed, currently, that is '7467'. I need to log that result and store in a separate variable.

Serdar Mustafa
  • 575
  • 1
  • 6
  • 14

0 Answers0