Count the vowels · 数元音字母
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Count the vowels
Count the vowels (a e i o u) in a String, treating upper- and lower-case the same. Lower-case it first with s.toLowerCase(), then loop with s.charAt(i) and compare against each vowel.
中文
数元音字母
数一数 String 中的元音字母(a e i o u),大小写视为相同。先用 s.toLowerCase() 转成小写,再用 s.charAt(i) 遍历,并与每个元音比较。
Complete countVowels(String s) so it returns how many letters are vowels (a, e, i, o, u), ignoring case. · 完成 countVowels(String s),返回其中元音字母(a、e、i、o、u)的个数,不区分大小写。
Click Run to see the output here. · 点击“运行”查看此处输出。