String.prototype.slice取字符串末位字符,判定其是否在元音集数组中即可。

function endsWithVowel(str) {
  const vowels = 'aeiouAEIOU'.split('')
  return vowels.indexOf(str.slice(str.length-1)) !== -1
}