Skip to content

Instantly share code, notes, and snippets.

@i-havr
Created May 30, 2023 20:03
Show Gist options
  • Save i-havr/a0b6c1e1090346ef0f5f4dd6bcdbe11d to your computer and use it in GitHub Desktop.
Save i-havr/a0b6c1e1090346ef0f5f4dd6bcdbe11d to your computer and use it in GitHub Desktop.
Функція перевіряє, чи дублюється новий об'єкт при додаванні в масив (по конкретному ключу-значенню). Повертає Boolean.
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