I currently have the following structure:
"name" : 'Invisibility',
"ingredients" : {
"CatTail" : 2,
"Arsenic" : 1,
"Newt" : 2,
},
"name" : "Super Strength",
"ingredients" : {
"Plutonium" : 2,
"CatPee" : 5,
"Rock" : 10
}
I'm taking input as an array in the following way:
input = {
firstIngredient : firstQuantity,
secondIngredient : secondQuantity,
thirdIngredient : thirdQuantity,
}
The idea is that I have a list of ingredients and quantities as input and now I want to see if the submitted values match one of the ingredients above.
Am I correct in thinking that I should create a function passing both items and doing a for loop over them and compare keys as described in this answer? Comparing Arrays of Objects in JavaScript
Thanks!