Заменить this.curr_category
в функции предиката фильтра на category
var data_obj_arr = [{"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}, {"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}, {"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}];
function updateChosenOption(category_choice, category) {
var arr = [];
for (let i in data_obj_arr) {
if (data_obj_arr[i][category] === category_choice) {
arr.push(data_obj_arr[i]["Collection_Name"]);
}
}
console.log(`Array: ${arr}`);
var results = data_obj_arr.filter((el => el[category] === category_choice))
.map(el => el["Collection_Name"]);
console.log(`Results: ${results}`);
}
updateChosenOption('Built Before 1980','Age');
Результат:
"Array: test,test,test"
"Results: test,test,test"