create array with repeated values javascript code example
Example 1: javascript repeat element in array
Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Example 2: duplicate numbers in an array javascript
[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]