has-duplicates

Returns true if an array has duplicate elements or a string has duplicate characters.

Usage no npm install needed!

<script type="module">
  import hasDuplicates from 'https://cdn.skypack.dev/has-duplicates';
</script>

README

has-duplicates

A Node.js module that checks an array for duplicate elements or a string for duplicate characters.

Installation

npm install has-duplicates --save

Usage

const hasDuplicates = require('has-duplicates')

// Arrays
hasDuplicates([1, 1]) // true
hasDuplicates([1, 2]) // false

// Strings
hasDuplicates('aa') // true
hasDuplicates('ab') // false