Im trying to filter my array of objects by the current month. Using animal crossing fish as an example
const fishData = {
"fish_name": "Barreleye",
"price": "15,000",
"location": "Sea",
"shadow_size": "Small",
"n_March": true,
"n_3": true,
},
{
"fish_name": "Coelacanth",
"price": "15,000",
"location": "Sea (Rainy Days)",
"shadow_size": "Largest",
"n_3": true,
}
]
var today = new Date();
var currentMonth = today.getMonth();
var fishMonth = `n_ + ${currentMonth}`;
console.log(fishMonth);
var filteredFish = fishData.filter(function(i) {
return i.fishMonth == true;
});
now by return if i put "n_3" instead of "fishMonth" the code runs fine. I've checked the "fishMonth" and it does return n_3. What would be stoping this from working?