function indexOfAny(string, array) {
let lowestIndex = -1;
for (let i in array) {
let index = string.indexOf(array[i]);
if (index > -1) {
if (lowestIndex == -1 || index < lowestIndex) {
lowestIndex = index;
if (index == 0) {
break;
}
}
}
}
return lowestIndex;
}
const str = "node.js programming";
const i = indexOfAny(str, ['v', 'x', 'g']);
console.log(i);
/*
run:
11
*/