const arrayOfDuplicateElements = [ '-.........', '.....', '-....-', '.....' ]
const getNumberOfDuplicateItems = arr => {
const set = new Set()
arr.forEach(el => set.add(el))
const initialArrayLength = arr.length
const uniqueArrayLength = [...set].length
return initialArrayLength - uniqueArrayLength
}
console.log(getNumberOfDuplicateItems(arrayOfDuplicateElements))
or
const arrayOfDuplicateElements = [ '-.........', '.....', '-....-', '.....' ]
const getNumberOfDuplicateItems = arr => arr.length - [...new Set(arr)].length
console.log(getNumberOfDuplicateItems(arrayOfDuplicateElements))