Here's the task - I have an input field where I can enter a text and I would like to replace the occurrence of Vowels with numbers eg (A,E,I,O,U - 1,2,3,4,5) and add 'a' to all the other consonants eg - The input field takes in 'Victor as an input and what is printed on the page is 'Va3cata4ra'.
So far, i've been able to get the consonants to display an 'a' at the end of it using template literals and passing the variable to a setState. However I'm having issues getting the Vowels to show their numerical values as explained above. I've tried Switch , if else, for some reason, none is working
export default class App extends Component {
state = {
mytext: ''
}
onChangeHandler = (event) => {
const newText = event.target.value;
const splitText = newText.split('');
let tempArr = []
for (let onye in splitText) {
else if (onye === 'e') {
onye.replace(parseInt('2'))
} else if (onye === 'i') {
onye.replace(parseInt('3'))
} else if (onye === 'o') {
onye.replace(parseInt('4'))
} else if (onye === 'u') {
onye.replace(parseInt('5'))
} else {
return onye
}
//This got the consonants to display a after each one
const raCon = `${splitText[onye]}a`
tempArr.push(raCon)
}
this.setState({
mytext: tempArr
})
Expected result would have 'a' at the end of each consonant and numerical values for every vowel corresponding with (A,E,I,O,U)- (1,2,3,4,5)