function findRunIndex(input) {
const cleanedInput = input.replace(/\s+/g, '');
const runIndex = cleanedInput.indexOf('run');
if (runIndex !== -1) {
let indexInOriginal = 0;
for (let i = 0; i < input.length; i++) {
if (input[i] !== ' ') {
if (indexInOriginal === runIndex) {
return i;
}
indexInOriginal++;
}
}
}
return -1;
}
const input1 = "arun";
const input2 = "a b runrun";
const input3 = "a r u n";
const index1 = findRunIndex(input1);
const index2 = findRunIndex(input2);
const index3 = findRunIndex(input3);
console.log(index1);
console.log(index2);
console.log(index3);
console