I need to get the "grid_id" from the "grids" array ( Step 1 )
Check if this "grid_id" exists in the "variationsDB" array ( Step 2 )
Using this "grid_id", take the "variation_id" and check if it exists in the "variations" array ( Step 3 )
If in any step the return is false, return an error
I can only think of two or more forEach :(
I need something cleaner
Code:
// Step 1
"grids": [
{
"grid_id": 1
},
{
"grid_id": 2
}
],
// Step 2
"variationsDB": [
{
"variation_id": 3,
"grid_id": 1
},
{
"variation_id": 7,
"grid_id": 2
}
],
// Step 3
"variations": [
{
"variation_id": 3
},
{
"variation_id": 7
}
]
Setto make your code cleaner (opinionated of course)