From d1a81b67ba8d67e3df8308a6c2c694198b051dd8 Mon Sep 17 00:00:00 2001 From: SaarHV Date: Fri, 13 Jan 2023 18:12:08 +0800 Subject: [PATCH] Add the util to judge whether two array strings are the same --- src/utils/arrayOperation.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/utils/arrayOperation.ts diff --git a/src/utils/arrayOperation.ts b/src/utils/arrayOperation.ts new file mode 100644 index 0000000..82ad39d --- /dev/null +++ b/src/utils/arrayOperation.ts @@ -0,0 +1,14 @@ +// 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 (let i in olds) { + for (let j in news) { + if (olds[i] === news[j]) count++; + } + } + return count === leng; +} + -- Gitee