-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVowelContain.js
More file actions
43 lines (33 loc) · 920 Bytes
/
VowelContain.js
File metadata and controls
43 lines (33 loc) · 920 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
43
// const VowelContain = (str) => {
// const vowels = ['a', 'e', 'i', 'o', 'u'];
// str = str.toLowerCase();
// let newstr=""
// for (let char of str) {
// if (vowels.includes(char)) {
// return true;
// }
// }
// return false;
// };
// const str = "I am Avneesh Singh Yadav";
// console.log("Does the string contain vowels " + VowelContain(str));
// vowel count and cosonant count
let str = "Hello Avneesh";
str = str.toLowerCase();
let vowels = "aeiou";
let vowelCount = 0, consonantCount = 0;
for (let i = 0; i < str.length; i++) {
let ch = str[i];
if (ch === " ") {
continue;
}
if (vowels.includes(ch)) {
vowelCount++;
console.log("Vowel: " + ch);
} else {
consonantCount++;
// console.log("Consonant: " + ch);
}
}
console.log("Total vowels: " + vowelCount);
console.log("Total consonants: " + consonantCount);