@cmarmar/

String Manipulation

ES6

No description

fork
loading
main.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
30
// Create a JavaScript function called vowelsCount(str). The str aka string parameter being passed should return the number of vowels the string contains. Do not count y as a vowel for this challenge.

// For Example:


// ```
// // INPUT: 'David Yang'
// vowelsCount('David Yang');
// // OUTPUT: 3;
// ```

// ```
// // INPUT: 'Nimit Maru'
// vowelsCount('Nimit Maru');
// // OUTPUT: 4;
// ```

const vowelsCount = (str)=> {
  const vowelBank ='aeiouAEIOU'
  let vowelCount = 0
  for (let i = 0; i < str.length; i++) {
    if(vowelBank.indexOf(str[i]) >=0){
      vowelCount++
    }
  }
  return vowelCount
}

vowelsCount('Nimit Maru')
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie