Having recently transitioned from Matlab to apps script, I am facing a challenge with subsetting arrays. Specifically, I need to filter the array "names" based on the values in another array called "index", which are of equal length:
names = [["name1"], ["name2"], ["name3"], ["name4"], ["name5"],["name6"],["name7"],["name8"],["name9"],["name10"]];
index = [0,0,1,0,1,0,0,0,0,1];
My goal is to extract only the names from the "names" array where the corresponding index value is 1. I attempted the following code:
var subsetNames = names[index];
Although the code executes without errors, "subsetNames" remains undefined. How can I modify the code to successfully achieve the desired subsetting? Thank you.