[Solved] Return matching elements after comparing in lower case?


You could filter the value after a check, if the lower case value is included in the fields array.

var mainArray = ["Title", "AssignedTo", "IssueStatus", "Priority", "Comment", "Category", "RelatedIssues", "V3Comments", "TaskDueDate", "Attachments"],
    fields = ["title", "comment"],
    result = mainArray.filter(a => fields.includes(a.toLowerCase()));

console.log(result);

ES5

var mainArray = ["Title", "AssignedTo", "IssueStatus", "Priority", "Comment", "Category", "RelatedIssues", "V3Comments", "TaskDueDate", "Attachments"],
    fields = ["title", "comment"],
    result = mainArray.filter(function (a) {
        return fields.indexOf(a.toLowerCase()) + 1;
    });

console.log(result);

0

solved Return matching elements after comparing in lower case?