I'm trying to use regex to evaluate whether the newArray
at index 0 is equivalent to the value stored in vowel
. I know that this method doesn't work but I don't understand why.
BTW I've just started learning how to code so I only really know Vanilla JS
function translate(val) {
let newArray = Array.from(val)
let vowel = /^[aeiouy]/gi
let consonant = /[^aeiouy]/
if (newArray[0] == vowel) {
return 'vowel';
} else if (newArray[0] == consonant) {
return 'consonant'
} {
return 'none';
}
}
translate('inglewood')