-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountVowels.js
More file actions
32 lines (26 loc) · 777 Bytes
/
Copy pathcountVowels.js
File metadata and controls
32 lines (26 loc) · 777 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
function countVowels(string) {
const vowles = ['a', 'e', 'i', 'o', 'u']
let count = 0;
for (let ele of string) {
if (vowles.includes(ele.toLowerCase())) {
count++
}
}
return count
}
let result = countVowels('The only thing we have to fear is fear itself.')
console.log(result) // 14
function lenOfVowels(string) {
let vowels = ['a', 'e', 'i', 'o', 'u']
let len = 0
for (let ele of string) {
if (vowels.includes(ele)) {
len++
}
}
return len
}
console.log(lenOfVowels('my pyx')); // 0
console.log(lenOfVowels('pear tree')); // 4
console.log(lenOfVowels('abracadabra')); // 5
console.log(lenOfVowels('o a kak ushakov lil vo kashu kakao')); // 13