...
/Challenge: Unit Test a Vowels Counter Function
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
Press + to interact
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
vowels
function that takes in one parameter,str
, which is a word passed into the function as a JavaScriptstring
to test. -
In line 2, we use a regular ...
Access this course and 1400+ top-rated courses and projects.