Challenge: Unit Test a Vowels Counter Function
Challenge yourself by checking how many vowels are there in a word.
We'll cover the following...
Challenge overview
const vowels = (str) => {const matches = str.match(/[aeiou]/gi);return matches ? matches.length : 0;};
Let’s explain the code written in the example above:
-
In line 1, we have a
vowelsfunction that takes in one parameter,str, which is a word passed into the function as a JavaScriptstringto test. -
In line 2, we use a regular ...
Ask