From 3cf12958a12505b4f2c3854cd75947179e8ad623 Mon Sep 17 00:00:00 2001 From: SaarHV Date: Fri, 27 Jan 2023 14:05:56 +0800 Subject: [PATCH] Add the function to judge whether two array strings are the same --- src/utils/arrayOperation.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/utils/arrayOperation.ts b/src/utils/arrayOperation.ts index 82ad39d..039a8b0 100644 --- a/src/utils/arrayOperation.ts +++ b/src/utils/arrayOperation.ts @@ -1,3 +1,17 @@ +// Judge whether two array strings are the same +export function judementSameArr(newArr: unknown[] | string[], oldArr: string[]): boolean { + const news = removeDuplicate(newArr) + const olds = removeDuplicate(oldArr) + let count = 0 + const leng = olds.length + for (const i in olds) { + for (const j in news) { + if (olds[i] === news[j]) count++ + } + } + return count === leng +} + // Judge whether two array strings are the same export function judementSameArr(newArr: unknown[] | string[], oldArr: string[]): boolean { const news = removeDuplicate(newArr); -- Gitee