diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4b1164232..ac39ceccc 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -24,7 +24,7 @@ Here's what you can do to help:
- Follow snippet descriptions with an empty line.
- **Snippet code** must be enclosed inside ` ```js ` and ` ``` `.
- Remember to start your snippet's code on a new line below the opening backticks.
- - Use ES6 notation to define your function. For example `const myFunction = arg1, arg2 => { }`.
+ - Use ES6 notation to define your function. For example `const myFunction = ( arg1, arg2 ) => { }`.
- Try to keep your snippets' code short and to the point. Use modern techniques and features. Make sure to test your code before submitting.
- All snippets must be followed by one (more if necessary) test case after the code, on a new line, in the form of a comment, along with the expected output. The syntax for this is `myFunction('testInput') -> 'testOutput'`. Use multiline comments only if necessary.
- Try to make your function name unique, so that it does not conflict with existing snippets.
@@ -57,7 +57,7 @@ Here's what you can do to help:
- Use `()` if your function takes no arguments.
- Use `_` if an argument inside some function (e.g. `Array.reduce()`) is not used anywhere in your code.
- Specify default parameters for arguments, if necessary. It is preferred to put default parameters last unless you have pretty good reason not to.
-- If your snippet's function takes variadic arguments, use `..args` (although in certain cases, it might be needed to use a different name).
+- If your snippet's function takes variadic arguments, use `...args` (although in certain cases, it might be needed to use a different name).
- If your snippet function's body is a single statement, omit the `return` keyword and use an expression instead.
- Always use soft tabs (2 spaces), never hard tabs.
- Omit curly braces (`{` and `}`) whenever possible.
diff --git a/README.md b/README.md
index 57328c55a..c13cf2fad 100644
--- a/README.md
+++ b/README.md
@@ -110,6 +110,7 @@
* [`anagrams`](#anagrams)
* [`capitalize`](#capitalize)
* [`capitalizeEveryWord`](#capitalizeeveryword)
+* [`countVowels`](#countvowels)
* [`escapeRegExp`](#escaperegexp)
* [`fromCamelCase`](#fromcamelcase)
* [`reverseString`](#reversestring)
@@ -1452,6 +1453,21 @@ const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperC
[⬆ back to top](#table-of-contents)
+### countVowels
+
+Retuns `number` of vowels in provided string.
+
+Use a regular expression to count number of vowels `(A, E, I, O, U)` in a `string`.
+
+```js
+const countVowels = str =>
+ return (str.match(/[aeiou]/ig) || []).length;
+// countVowels('foobar') -> 3
+// countVowels('gym') -> 0
+```
+
+[⬆ back to top](#table-of-contents)
+
### escapeRegExp
Escapes a string to use in a regular expression.
diff --git a/docs/index.html b/docs/index.html
index 3e4e53b93..d0c93846e 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -135,6 +135,7 @@
anagrams
capitalize
capitalizeEveryWord
+countVowels
escapeRegExp
fromCamelCase
reverseString
@@ -886,6 +887,14 @@ Omit the lowerRest parameter to keep the rest of the string intact,
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
// capitalizeEveryWord('hello world!') -> 'Hello World!'
+Retuns number of vowels in provided string.
Use a regular expression to count number of vowels (A, E, I, O, U) in a string.
const countVowels = str =>
+ return (str.match(/[aeiou]/ig) || []).length;
+// countVowels('foobar') -> 3
+// countVowels('gym') -> 0
+
Escapes a string to use in a regular expression.
Use replace() to escape special characters.