I am creating a program in javascript which deletes the first instance of a vowel in a word. eg
original text: quick brown fox jumps over the lazy dog output: th qck brwn fox jumps over the lzy dog
I cannot get the function to work, it always outputs the original sentence with no changes
disappearString = (myString, toErase) => {
let newString = myString.split();
let newErase = toErase.split();
for(let i = 0; i < newString.length; i++){
if(newString[i] === newErase[i]){
console.log(newString.delete(toErase[i]));
}
}
return newString.join();
}
let testStrings = [
"the quick brown fox jumps over the lazy dog",
"hello world",
"software engineering is fun",
"i like javascript",
"clown case",
"rhythms"
]
let stringToDisappear = "aeiou"
let correctStrings = [
"th qck brwn fox jumps over the lzy dog",
"hll world",
"sftwr engneering is fn",
" lik jvascript",
"clwn cs",
"rhythms"
]
for (let strIdx = 0; strIdx < testStrings.length; strIdx++) {
let test = testStrings[strIdx];
let correct = correctStrings[strIdx];
let got = disappearString(test, stringToDisappear);
if (got == correct) {
console.log(`${strIdx + 1}: Testing ${test}: Correct!`);
} else {
console.log(`${strIdx + 1}: Testing ${test}: Wrong, got ${got}, expected ${correct}`);
}
}