GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/String/CountVowels.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathCountVowels.jsMore file actions 21 lines (17 loc) · 534 Bytes / Copy pathCountVowels.jsFile metadata and controls21 lines (17 loc) · 534 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 /** * @function countVowels * @description Given a string of words or phrases, count the number of vowels. * @param {String} str - The input string * @return {Number} - The number of vowels * @example countVowels("ABCDE") => 2 * @example countVowels("Hello") => 2 */ const countVowels = (str) => { if (typeof str !== 'string') { throw new TypeError('Input should be a string') } const vowelRegex = /[aeiou]/gi const vowelsArray = str.match(vowelRegex) || [] return vowelsArray.length } export { countVowels } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |