mirror of
https://github.com/jlengrand/undercover.git
synced 2026-03-10 08:51:23 +00:00
10 lines
307 B
JavaScript
10 lines
307 B
JavaScript
export function arrayHasDuplicates(array) {
|
|
return array.length !== new Set(array).size;
|
|
}
|
|
|
|
export function arrayHasDuplicateValue(array, value) {
|
|
if (!value) throw new Error('No value to find duplicates on!');
|
|
const theArray = array.map(item => item[value]);
|
|
return arrayHasDuplicates(theArray);
|
|
}
|