我正在尝试过滤从数组中收集的母子数组之间的匹配元素,必须将其转换为字符串并针对任何空白进行修剪,以使第三个数组具有来自母数组的不匹配元素。
function getVehicles() {
//motherArray = ["a","b","c","d","e"];
//childArray = ["a","c","e"];
//thirdArray = ["b","d"]
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Main Responses");
var ds = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Drivers and Vehicls");
var ap = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Approval Page");
var hp = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("helpersheet");
var lr= 15;
var Vehicles = ds.getRange(2,5,vehicleslr-1).getValues();
Vehicles = [].concat.apply([], Vehicles);
var availableDrivers=[];
var availableVehicles=[];
var assignedDriver= [];
var foundVehicles = [];
foundVehicles = ss.getRange(lr,22,1,8).getValues();
foundVehicles = [].concat.apply([], foundVehicles);
availableVehicles = Vehicles.filter(function(val) { return foundVehicles.indexOf(val) == -1;});
//The expected output is the third array(availableVehicles) in the code i tried.
}