Challenge: Unit Test a Vowels Counter Function
Explore how to write unit tests for a JavaScript vowels counter function using Jest. Understand regex usage for matching vowels and practice verifying expected outcomes to ensure function correctness.
We'll cover the following...
We'll cover the following...
Challenge overview
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 expression to find all the matches of vowels in the string (i.e.,
/aeiou/gi...