File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* =====================================================================
2
+ ------ Programme for calculating Total vowels and consonants --------
3
+ ===================================================================== */
4
+
5
+ const countVowelsAndConsonants = textInput => {
6
+ const allLetters = textInput . toLowerCase ( ) ;
7
+ const vowels = 'aeiou' ;
8
+ let vowelsCount = 0 ;
9
+ let consonantsCount = 0 ;
10
+
11
+ for ( let i = 0 ; i < allLetters . length ; i ++ ) {
12
+ let letter = allLetters [ i ] ;
13
+
14
+ if ( / [ a - z ] / . test ( letter ) ) {
15
+
16
+ if ( vowels . includes ( letter ) ) {
17
+ vowelsCount ++ ;
18
+ }
19
+ else {
20
+ consonantsCount ++ ;
21
+ }
22
+ }
23
+
24
+ } ;
25
+ return { yourInput : textInput , totalVowels : vowelsCount , totalConsonants : consonantsCount } ;
26
+ } ;
27
+
28
+ console . log ( countVowelsAndConsonants ( "developer.shourav1@gmail.com" ) ) ;
You can’t perform that action at this time.
0 commit comments