I'm not entirely sure how to title the question, but I'm trying to add to one Array from a second based on a matched string at index 0
. This is in a Google Apps Script web app, which is why it's all JavaScript-based rather than PHP.
// Sent from client
Array1: ["A"]
// Stored on server
Array2: [["A", "June","15"], ["B","October","30"]]
I'd like to return the entire matching array based on the client-submitted form object.
I've tried:
Array1 = Array1.filter(function(val) {
return Array2.indexOf(val) !== -1; // I thought this would return indices that matched
});
but I get an empty array returned instead of ["A","June","15"]
. Any ideas?