repeated values inside array javascript code example
Example 1: javascript repeat element in array
Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Example 2: how to check for duplicate syntax in javascript
let strArray = [ "q", "w", "w", "w", "e", "i", "u", "r"];
let findDuplicates = arr => arr.filter((item, index) => arr.indexOf(item) != index)
console.log(findDuplicates(strArray)) // All duplicates
console.log([...new Set(findDuplicates(strArray))]) // Unique duplicates