I'm using Adobe ExtendScript Toolkit to debug. I'm coding for InDesign and really don't have deep JavaScript knowledge (and don't know what ES6 means). ExtendScript doesn't accept let as reserved word. Maybe something about this ES6 you're meaning?
I need to compare all the items in an array and join some of them if one of its child are the same. Let me explain:
Based on the following array:
var array = [[1,"luis"] , [2,"felipe"] , [2,"erick"] , [2,"mark"] , [3,"dustin"]]
So, I want to get as result this array:
var array = [[1,"luis"] , [2,"felipe; erick; mark"] , [3,"dustin"]]
How can I compare the array items to get the desired result?
I already tried two for loops and a while. Maybe I made them wrong. Because of that, I'm here to ask you guys.
If I use this:
for (var i=0; i<array.length-1; i++) {
for (var j=i+1; j<array.length; j++) {
if (array[i][0] == array[j][0]) {
array[i][1] = array[i][1] + "; " + array[j][1];
}
}
}
I have all results. Like this:
1,luis
2,felipe; erick; mark
2,erick; mark
2,mark
3,dustin