JS能力测评42:判断是否以元音字母结尾

思路:

首先确定元音集合[a,e,i,o,u],然后是以元音结尾,加上$,最后通配大小写,加上i。因此正则表达式为:/[a,e,i,o,u]$/i,最后用test方法去检测字符串str

function endsWithVowel(str) {
  var b=/[a,e,i,o,u]$/i
  return b.test(str);
 }

猜你喜欢

转载自blog.csdn.net/weixin_43160613/article/details/86534745
今日推荐