find vowel in javascript code example

Example 1: find the vowel js

function vowel_count(str1)
{
  var vowel_list = 'aeiouAEIOU';
  var vcount = 0;
  
  for(var x = 0; x < str1.length ; x++)
  {
    if (vowel_list.indexOf(str1[x]) !== -1)
    {
      vcount += 1;
    }
  
  }
  return vcount;
}
console.log(vowel_count("The quick brown fox"));

Example 2: how to make a vowel counter in javascript

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;
}

Example 3: how to make a vowel counter in javascript

function countVowels(str) {
  return str.match(/[aeiou]/g).length;
}

Example 4: vowel check in javascript

// check the word is vowel or not
let words = "aeiou";

let newWords = "";

function isVowelOrNot(words) {
   for (let word of words) {
      if (
         word === "a" ||
         word === "e" ||
         word === "i" ||
         word === "o" ||
         word === "u"
      ) {
         newWords = newWords + word;
      }
   }
   if (newWords === words) {
      return true;
   } else {
      return false;
   }
}

let result = isVowelOrNot(words);
console.log(result);