I have a number of data-attributes on page which will have different values, but there will be duplicates of these values, for example:
<div data-user-val="[Adult-Young-25]"></div>
<div data-user-val="[Adult-Young-25]"></div>
<div data-user-val="[Adult-Young-25]"></div>
<div data-user-val="[Adult-Mid-35]"></div>
<div data-user-val="[Adult-Mid-35]"></div>
<div data-user-val="[Adult-Old-75]"></div>
I want to loop through and grab each unique value ('[Adult-Young-25]','[Adult-Mid-35]','[Adult-Old-75]') and split these up to pass to an array as key-value pairs like:
var array = {"Adult Young": "25", "Adult Mid": "35", "Adult Old": "75"};
I'm struggling to 1. grab one instance of each repeated data value, and 2. to 'split' the value to map as key-value pairs.