Skip to content
Advertisement

How to get indexes of char in the string

I want to find vowels positions in the string. How can I make shorter this code?

I tried contains and indexOf method but couldn’t do it.

JavaScript

Advertisement

Answer

I assume you want to get m2rh5b7 from your input string Merhaba based on your code, then the below works fine,

JavaScript

Or if you want just position of the vowels position only, the below is fine,

JavaScript

you can use regex also, please refer the above from Alias.

Advertisement