Trouble with filtering array based on data from two other arrays
I'm really struggling to figure out how to solve this filtering problem.
I have an array of exercises that are each objects. I am fetching the data and putting it in a let called highResistanceTotalBodyPower_API on ./script row 4.
Each exercise objects has data such as .restrictions and .equip
I also have an example fitness client ( ./script row 15-17) which contains a client's restrictions and available equipment (equip).
I need to filter the array of exercises to match what is available to the client's restrictions and equipment (equip). For instance, if a client does NOT have a barbell then all of the exercises that require barbells should be filtered out. In addition, if a client has a lowBack restriction then all exercises that do NOT contain the restriction should be filtered out.
I gave it a shot in ./script row 21-54; however, it's clearly not working and I'm sure my code is bloated. Any help would be AMAZING as I've been working of this for over a month.
Thanks in advance!!
@cburrus That's weird...
Anyway, I think the problem you're facing is with the for loop order. I'm having a hard time understanding your variable names 😅 (and I'm not really good with JS), but I think your function should look like this:
Also, quick question, this is a list of exercises right:
Then what's this:
So you convert an exercise to a string array? And what does the string array store?