containsVowels

Easy · String Manipulations · 2 test cases

Given a string, return true if it contains any vowels, otherwise false.

Examples

containsVowels('hello') → true
containsVowels('rhythm') → false

Starter code

function containsVowels(str) {

}

Complexity of the optimal solution

Time O(n), space O(1). The regex `test` method needs to scan the string for a match. In the worst case, it will check every character, resulting in a time complexity proportional to the string's length (n). Space is constant.

Solve containsVowels in the browser