I am trying to implement a logic where I have an array [3,4,63,5,5,1,5,2,63,2,4,5,6,2,4,56,74,2,671,1,4,5,7,3,6] . I want to find all repeated elements and I want to store these all repeated elements into a new array. I tried very hard but didn't find a solution.
It would be great if someone write simple code and also explain what code doing .
Thanks
First of all you need to understand some basics.
Array Map - Information on MDN
Array map creates a new array and doesn't alter your current array.
Array.indexOf(element) Information on MDN
Returns the index of the element in an array, -1 not found, 0 based.
To wrap things up:
Array Filter Information on MDN
This is the most basic explanation i can give, no use of conditional operators, storing in variables etc.. if you are a bit more advanced in programming you can write less shorter code, called 1 liners. But i hope this will give you to inspiration to go on with this. But you have to understand the basic first, that means learn, read, learn more and practice a lot.