v2.vuejs.org icon indicating copy to clipboard operation
v2.vuejs.org copied to clipboard

Preventing array from storing duplicate values

Open sosmongare opened this issue 3 years ago • 1 comments

On the todo app, How do I prevent an array from duplicating the etext i have just inserted

sosmongare avatar Oct 16 '21 05:10 sosmongare

@sosmongare you can just find the index of that value first using find or indexOf before updating the array

['m', 'I', 'j'].find(data => data === value)

dammy001 avatar Oct 19 '21 06:10 dammy001