'Javascript / Google Apps Script compare 2 arrays, return items with NO match

Target: Compare list of attendees with list of invitees and send email reminder to those who did not attend.

Method: I am attempting to compare 2 arrays [invited & attended] and return items that are NOT found in each i.e who did not attend training so I can trigger an email reminder.

I've got myself stuck and am mentally blank to the solution. My current code compares the 2 arrays and returns matches. If I set the if statement criteria to if (value[x] !== value[y]) {Logger.log[x]} I am shown rather undesirable output.

Current function as below:

function getAttendees() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName('Attendees');

    var inviteSheet = ss.getSheetByName('Invitees');
    var inviteLRow = inviteSheet.getLastRow();
    var inviteRange = inviteSheet.getRange("K2:K" + inviteLRow);
    var getInvite = inviteRange.getValues();

    var attendLRow = sheet.getLastRow();
    var getAttendRange = sheet.getRange("A2:A" + attendLRow)
    var getAttend = getAttendRange.getValues();

    for (var v = 0; v < getAttend.length; v++) {
        var vn = v + 2;
        for (var e = 0; e < getInvite.length; e++) {
            var en = e + 1;

            if (getAttend[v].toString() !== getInvite[e].toString()) {
                Logger.log(getAttend[v] + " attended training.");
            }
        }
    }
}

If I can return the items not in the "Attendees" array, I can trigger the email function (pretty sure I have that one in the bag already.)

Any help would be greatly appreciated. Will buy digital coffee for whoever fixes it... If I figured it out, I get coffee.



Solution 1:[1]

You may filter then out as follows;

var invited = [1,2,3,4,5,6,7,8,9],
   attended = [1,5,7,8],
     missed = invited.filter(e => attended.indexOf(e) === -1);
console.log(missed)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Redu