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