0

I have an array grouping. My array value is

var arr = [ 'One', 'One', 'Two', 'Three', 'Two' ];

I want the array's value to be

arr = [ 'One', 'Two', 'Three' ];

How do I group by array value?

Natan Streppel
  • 5,759
  • 6
  • 35
  • 43
Elango
  • 415
  • 3
  • 7
  • 18

1 Answers1

0

You can use a solution like the one I've built for you in this fiddle. You could also use the uniq function from underscore. However, my advice to you is to:

  1. think about the problem
  2. get some before and after data
  3. try to solve the problem by programming
  4. compare the output of your solution applied to your "before" data with the "after" data.

This way you are likely to not only solve the problem, but also to grow as a programmer.

Welcome to StackOverflow!

Ziggy
  • 21,845
  • 28
  • 75
  • 104