Skip to main content

Posts

Featured

Junior Developer Central JS Practice Exercise - 22

  Question:  Write a Javascript function that accepts a string as a parameter and counts the number of vowels within the string.  Answer:  function vowelCount (str) {   let vowels = /[aeiou]/gi;   let result = str.match(vowels);   let count = result.length;   return count;       }; > we declare a function 'vowelCount'  > it has one parameter 'str', which is a string > we declare a variable 'vowels' and initialize it with the 5 vowels > the 'g' modifier is used on the 'vowels' variable to perform a global match  > a global match will find all matches and will not stop after finding the first match >  additionally   the 'i' modifier is used  on the 'vowels' variable to perform case insensitive matching > we declare another variable 'result' and initialize it with the result we get when we use the match () method on the 'str' parameter > the match() method searches a string for a ma...

Latest Posts

Junior Developer Central JS Practice Exercise - 21

Junior Developer Central JS Practice Exercise - 20

Junior Developer Central JS Practice Exercise - 19

Junior Developer Central JS Practice Exercise - 18

Junior Developer Central JS Practice Exercise - 17

Junior Developer Central JS Practice Exercise - 16

Junior Developer Central JS Practice Exercise - 15

Junior Developer Central JS Practice Exercise - 14

Junior Developer Central JS Practice Exercise - 13

Junior Developer Central JS Practice Exercise - 12