function lastIndexOfAny(string, array) {
let highestIndex = -1;
for (let i in array) {
let index = string.lastIndexOf(array[i]);
if (index > highestIndex) {
highestIndex = index;
if (index == string.length - 1)
break;
}
}
return highestIndex;
}
const str = "javascript programming";
const i = lastIndexOfAny(str, ['y', 'x', 'a']);
console.log(i);
/*
run:
16
*/