diff --git a/QandA/frontend/src/QuestionsData.ts b/QandA/frontend/src/QuestionsData.ts index 4b5fc97..51a8dc2 100644 --- a/QandA/frontend/src/QuestionsData.ts +++ b/QandA/frontend/src/QuestionsData.ts @@ -64,3 +64,14 @@ export const getQuestion = async ( const results = questions.filter((q) => q.questionId === questionId); return results.length === 0 ? null : results[0]; }; + +export const searchQuestions = async ( + criteria: string, +): Promise => { + await wait(500); + return questions.filter( + (q) => + q.title.toLowerCase().indexOf(criteria.toLowerCase()) >= 0 || + q.content.toLowerCase().indexOf(criteria.toLowerCase()) >= 0, + ); +};