-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloops.js
29 lines (27 loc) · 937 Bytes
/
loops.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Task
Complete the vowelsAndConsonants function.
It has one parameter, a string, 's', consisting of lowercase English alphabetic letters (i.e., a through z).
The function must do the following:
First, print each vowel in 's' on a new line.
The English vowels are a, e, i, o, and u, and each vowel must be printed in the same order as it appeared in 's'.
Second, print each consonant (i.e., non-vowel) in 's' on a new line in the same order as it appeared in 's'.
*/
/*
* Complete the vowelsAndConsonants function.
* Print your output using 'console.log()'.
*/
function vowelsAndConsonants(s) {
const vowels = 'aeiou';
let consonants = [];
for(let i = 0; i < s.length; i++){
if(vowels.includes(s[i])) {
console.log(s[i]);
} else {
consonants.push(s[i]);
}
}
for (let j = 0; j<consonants.length; j++) {
console.log(consonants[j]);
}
}