FED77. 判断是否以元音字母结尾
描述
给定字符串 str,检查其是否以元音字母结尾示例1
输入:
'gorilla'
输出:
true
HTML/CSS/JavaScript 解法, 执行用时: 858ms, 内存消耗: 77828KB, 提交时间: 2020-11-22
{"css":"","js":"function endsWithVowel(str) {\n return /(a|e|i|o|u)/.test(str[str.length-1].toLocaleLowerCase())\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 860ms, 内存消耗: 77844KB, 提交时间: 2021-01-31
{"css":"","js":"/*\nfunction endsWithVowel(str) {\n var arr = ['a','e','i','o','u','A','E','I','O','U'];\n return arr.includes(str[str.length-1])\n}\n*/\n\n/*\nfunction endsWithVowel(str) {\n return (\"aeiouAEIOU\".indexOf(str[str.length-1])!=-1)\n}\n*/\nfunction endsWithVowel(str) {\n var reg = /(a|o|e|i|u)$/gi;\n return reg.test(str);\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 861ms, 内存消耗: 77840KB, 提交时间: 2020-11-08
{"css":"","js":"function endsWithVowel(str) {\n return /([a,e,i,o,u])$/i.test(str)\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 862ms, 内存消耗: 77832KB, 提交时间: 2020-12-13
{"css":"","js":"function endsWithVowel(str) {\n return /[a,e,i,o,u]$/i.test(str);\n}","html":"","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 863ms, 内存消耗: 77772KB, 提交时间: 2020-11-09
{"css":"","js":"function endsWithVowel(str) {\n return /[aeiouAEIOU]$/.test(str);\n}","html":"","libs":[]}