Well I am stuck here and I would appreciate some directions of methods I can accomplish this with.
I got an array with questions:
questions: [
{
question: 'lala',
answer: 'papa',
categories: ['Handla']
},
{
question: 'xxxx',
answer: 'yyyy',
categories: ['Reklamation']
}
]
Based on the categories I want to be able to list the questions accordingly when filtering.
So lets say I want to filter on 'Handla' I should be able to loop out all the questions that has the value 'Handla' matched in the categories array.
mapping through the questions array and doing returning them with an if/else statement will work but im not sure this is the optimal way.
Summary: I want to iterate through questions and pick out objects that matches with my desired category query.
My desired output when requesting "Reklamation" should be
const desiredArray = [{
{
question: 'xxxx',
answer: 'yyyy',
categories: ['Reklamation']
}
}]