Essentially what I am trying to accomplish is to filter out only the indices I need. However I noticed that it only works when passing BOTH filter(v,i) into the method, even though v is never used! At first I believed this was a scoping issue, but v is never declared globally.
The computation below works fine:
wordObj.wordKeys[0] = wordObj.wordKeys[0].filter((v, i) => {
return indiciesToKeep.includes(i);
});
However, this computation without "v" does not:
wordObj.wordKeys[0] = wordObj.wordKeys[0].filter((i) => {
return indiciesToKeep.includes(i);
});
It is not throwing any syntax errors. It is simply just not returning the correct indices when I don't pass "v" into function. Any ideas on why this may not work would be greatly appreciated