I am trying to use Javascript to remove the dash and everything after in an array of product ids. But not if the dash is in the middle of the product id. For example product ids:
["630932-8", "640993-8", "1951-83044226", "641452-10", "1924-57044108", "630695-8 DD/F", "641058-8", "630932-20", "630695-14 DD/F", "630695-22 D/DD", "630695-12 C/D", "661049-6", "661050-4", "630692-8 C/D", "630513-38 G", "630513-36 F", "630655-36 DD", "630695-8 C/D", "661049-4", "630695-16 C/D"]
This is for use within a tag management system and need the to drop everything after the "-" so it would be
["630932", "640993", "1951-83044226", "641452", "1924-57044108", "630695", "641058", "630932", "630695", "630695", "630695", "661049", "661050", "630692", "630513", "630513", "630655", "630695", "661049", "630695"]
There will be some that have will have 4 digits then the dash and those need to stay. The Product ids are currently populated in a datalayer with the "-" they are referenced by utag.data.product_skus