📌  相关文章
📜  javascript 循环遍历字母表并返回元音 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:36.447000             🧑  作者: Mango

代码示例1
function vowelsAndConsonants(s) {
//Create Array of vowels
   const vowels = ["a","e","i","o","u"];
//Convert String to Array
   const arr = s.split("");
//Empty vowels and cons array
   var vowelsFound = [];
   var cons = [];
//Push vowels and cons to their arrays
   for (var i in arr) {
     if (vowels.includes(arr[i])) {
        vowelsFound.push(arr[i]);
        } else {
            cons.push(arr[i]);
        }
   }
//ConsoleLog so that they in order and cons follows vowels on new lines
   console.log(vowelsFound.join('\n') + '\n' + cons.join('\n'))
}
//Test, Exclude in copy
vowelsAndConsonants(javascriptloops);