Answers for "how to print repeated number from the array in javascript"

1

javascript create array with repeated values

Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Posted by: Guest on February-17-2021
0

how to get duplicate values from array in javascript

const arr = ["q", "w", "w", "e", "i", "u", "r"]
arr.reduce((acc, cur) => { 
  if(acc[cur]) {
    acc.duplicates.push(cur)
  } else {
    acc[cur] = true //anything could go here
  }
}, { duplicates: [] })
Posted by: Guest on June-19-2020

Code answers related to "how to print repeated number from the array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language