I am storing a number of objects within the below array in my Typescript project
(I have removed some data to make the code easier to read):
workoutExercises = [
{
id: 0,
exerciseComplete: false,
},
{
id: 1,
exerciseComplete: false,
},
{
id: 2,
exerciseComplete: false,
},
];
I am trying to write some code that checks if all the exerciseComplete
vaues are TRUE
.
If all of them are TRUE
, I want to perform a certain action. If at least one of them is FALSE
, I want to perform a different action.
I'm able to loop through the objects with the below For Loop, but I'm not sure how to check all the exerciseComplete
values.
for (let i = 0; i < this.workoutExercises.length; i++) {
console.log(this.workoutExercises[i].exerciseComplete);
}
Can someone please tell me how I would check the above with this loop?