-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvowels.js
More file actions
42 lines (36 loc) · 818 Bytes
/
vowels.js
File metadata and controls
42 lines (36 loc) · 818 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
const vowelsCheck = str => {
const vowelsArray= str.split("");
let i=0;
for(let letter of vowelsArray) {
if (letter === "a") {
i += 1;
} else if (letter === "e") {
i += 1;
}
else if (letter === "i") {
i += 1;
}
else if (letter === "o") {
i += 1;
}
else if (letter === "u") {
i += 1;
}
}
return i;
}
vowelsCheck("beetle");
const findVowels = str => {
let count = 0
const vowels = ['a', 'e', 'i', 'o', 'u']
for(let char of str.toLowerCase()) {
if(vowels.includes(char)) {
count++
}
}
return count
};
const findVowels = str => {
const matched = str.match(/[aeiou]/gi)
return matched ? matches.length : 0
};