From fb841001afe9081b35f3ce5af9ef3540738c1da0 Mon Sep 17 00:00:00 2001 From: Moe Alam Date: Sun, 1 Nov 2020 17:45:25 -0800 Subject: [PATCH] add function to check string existance in array elements --- libs/common.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/common.js b/libs/common.js index 1944e627..cc1fbd1c 100644 --- a/libs/common.js +++ b/libs/common.js @@ -31,4 +31,12 @@ const mergeDeep = function(...objects) { return prev; }, {}); } +const arrayContains = (query,theArray) => { + var foundQuery = false + theArray.forEach((value) => { + if(value.indexOf(query) > -1)foundQuery = true + }) + return foundQuery +} exports.mergeDeep = mergeDeep +exports.arrayContains = arrayContains