You might also get a task like this right to function, which counts vowels in the string, and it is
not always vowels, but something that you must count in the string.
And actually, it is not that difficult, because the main idea is that first, we must define something
like a range of possible loopholes or possible symbols, and then just try and check every single letter
inside our strength.
Let's do this now.
So first of all, here we want to create a function, find the walls, and we're getting history and
as an argument.
Now, second live, we must define what our walls.
So here we can create walls.
And let's define here a e o i and you, and we can solve it with two different ways, either with follow
up or with reduce.
And actually, both are fine.
So here, first of all, I want to create a counter because we want to increase it every single time
when we find our wall.
Now we need a for loop, so here we can write lead character off.
And here will restrain to lower our case.
In this case, we're getting access to every single character inside our street.
And we can check, OK, if the wealth includes our character, then we want to increase our counter.
So here will be count plus plus.
And after this for loop, we just must return our account that we created.
And here, let's try to find the balls.
And we have some strain.
As you can see here, we're getting three vowels because we have here e three times.
And actually, I would say that this code is OK, but we can write it better with reduced.
This is why I want to comment.
Told this let code and follow up and directly here.
Return as a deuce.
So here, first of all, we want to convert our string to lowercase.
So here we can just write string to lowercase.
And after this, we want to split it in characters.
This is where here will be split empty string.
Now we want to call here, reduce and get an excess, first of all, to our accumulator.
And secondly, to every single character.
And after this function, we want to define our count and it will be zero.
Now, inside our reduce, we want to do exactly the same logic, but can return here that if our vowels
array includes character that we're checking, then we want to increase our count.
So here we're increasing our accumulator with +1.
In that case, we don't increase it and just return accumulator.
Let's check the small time relied in the page.
Here is the same string and we're getting three.
And actually, this code is better because first of all, we can read it line by line.
And secondly, it is fully pure and functional.