Created
May 30, 2023 20:03
-
-
Save i-havr/a0b6c1e1090346ef0f5f4dd6bcdbe11d to your computer and use it in GitHub Desktop.
Функція перевіряє, чи дублюється новий об'єкт при додаванні в масив (по конкретному ключу-значенню). Повертає Boolean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkDuplicate = (array, newObject) => { | |
const isDuplicate = array.some((obj) => obj.key === newObject.key); | |
return isDuplicate; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment