This function I'm creating will calculate the quantity of food data.
const countFood = (foodType) => {
let foodNeeded = 0;
if (animal.food.type === foodType) {
foodNeeded += +animal.food.amount;
};
const food = foodType;
if (foodNeeded > (pavilion.food[food] - 1)) return true;
countFood(foodType);
}
countFood('meat');
This piece of code is used within a for loop.
I want to utilize this argument to access it in the form of pavilion.food.meat