Substituindo "the"
Crie uma função que substitua "the" na frase por "an" ou "a". Lembre-se de que, se a próxima palavra começar com uma vogal, você deve usar "an". Se começar com uma consoante, use "a".
Exemplos
replace_the("the dog and the envelope"); // "a dog and an envelope"
replace_the("the boy ran at the wall"); // "a boy ran at a wall"
replace_the("the egg, the spoon and the espionage"); // "an egg, a spoon and an espionage"Notas
- As frases estarão sempre em letras minúsculas.
- A última palavra da frase nunca será "the".
- Isso não abrange casos especiais como "an hour" ou "a unique thing" (pois eles soam de maneira diferente do que indica a regra).