I believe what I'm attempting to create is a 3d array in JS. The data I'm pulling is from a Google sheet, and I've created a dummy sheet with a sudo-console log showing what the ideal end result would be.
In short, I want a list of Client-Project pairings where the pair looks like this: [[Client], [Project(s)]].
However, I'm producing a list where each client is assigned to every project in list, not just the projects they share a row with (please reference the dummy sheet for context).
How should I restructure this code to get the result I'm looking for?
Thank you! All help is appreciated :D
const ss = SpreadsheetApp.openById("1BWutWGYPW9RjewRNdgLdHCn-Rytbyi63xbPF2Hd3tPg");
function getProjects(){
/** Getting List of Projects */
const projectsSH = ss.getSheetByName("Projects");
const projects = projectsSH.getRange(2,8,projectsSH.getLastRow()-1).getValues();
const clients = projectsSH.getRange(2,2,projectsSH.getLastRow()-1).getValues();
for (i = 0; i<clients.length; i++){
for(j = 0; j<projects.length; j++){
Logger.log([clients[i], projects[j]])
}
}
}
https://docs.google.com/spreadsheets/d/1CqZSMtSsxzYZwgq5XlwWxN_vSfpgP35rSV0dnCVLeVU/edit#gid=0
{client1: [project1, project2], client2: [project3, project4,...], ...etc}