find vowel & consonants in a string java script
const str = "The quick brown fox jumps over a lazy dog";
const vowels = str.match(/[aeiou]/gi);
const consonants = str.match(/[^aeiou]/gi);
vowels.concat([''],consonants).forEach(k => { console.log(k); } );
function getCount(str) {
let vowelList = 'AEIOUaeiou'
let vowelsCount = 0;
for(var i = 0; i < str.length ; i++)
{
if (vowelList.indexOf(str[i]) !== -1)
{
vowelsCount += 1;
}
}
return vowelsCount;
}
// BEST and FASTER implementation using regex
const countVowels = (str) => (str.match(/[aeiou]/gi) || []).length
Also in JavaScript:
- jqeury cdn
- animate in jquery
- js split last occurence
- fizzbuzz javascript
- js get number from string
- mongodb gte
- javascript key pressed enter
- jquery array compare values
- javascript inbuilt funcctions to match the word and return boolean
- json minecraft
- react how to manipulate children
- javascript preencher array com 0
- javascript conditional ? :
- get selected text js
- javascript array group by id
- js cound how many clicks
- strapi cloudinary how to use
- javascript function convert bytes into mb
- build an api in nodejs using express to send emails using the gmail rest api without client libraries
- for each array javascript
- javascript to array
- in javascript how to split string
- square brackets vs curly brackets javascript
- random int between two numbers javascript