JSFiddle - React, Tailwind, and code Playground
JavaScript
var A = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"];
var B = ["B", "J", "C", "G"];
var C = ["SX", "S", "M", "L", "XL", "XXL", "ML", "LL", "XLL", "MK", "LK", "XLK", "MS", "LS", "XLS"];
var D = ["XLL", "XXL", "XLK"];
function customArrayFunction(A, B) {
var res = A.find(v => B.indexOf(v) > -1);
return res;
}
console.log(customArrayFunction(A, B));
console.log(customArrayFunction(C, D));