- Write a function that takes a string and returns the number of vowels in the string.
- countVowels('hello') -> 2
- countVowels('world') -> 1
- countVowels('aeiou') -> 5
- countVowels('bcdfg') -> 0
- countVowels('') -> 0
- Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
- isPalindrome('madonna') -> false
- isPalindrome('madam') -> true
- isPalindrome('racecar') -> true
- isPalindrome('hello') -> false
- isPalindrome('') -> true
- Write a function that takes a string and returns the string reversed.
- reverseString('hello') -> olleh
- reverseString('world') -> dlrow
- reverseString('') -> ``
- reverseString('a') -> a
- reverseString('abcd') -> dcba
- Write a function that takes two strings and returns true if they are anagrams of each other, and false otherwise.
- isAnagram('listen', 'silent') -> true
- isAnagram('hello', 'world') -> false
- isAnagram('evil', 'vile') -> true
- isAnagram('fluster', 'restful') -> true
- isAnagram('example', 'sample') -> false
- Write a function that takes a string and returns the string with the first letter of each word capitalized.
- capitalizeWords('hello world') -> Hello World
- capitalizeWords('javascript is fun') -> Javascript Is Fun
- capitalizeWords('') -> ``
- capitalizeWords('a quick brown fox') -> A Quick Brown Fox
- capitalizeWords('capitalize') -> Capitalize
- Write a function that takes a string and returns the length of the longest substring without repeating characters.
- lengthOfLongestSubstring('abcabcbb') -> 3
- lengthOfLongestSubstring('bbbbb') -> 1
- lengthOfLongestSubstring('pwwkew') -> 3
- lengthOfLongestSubstring('') -> 0
- lengthOfLongestSubstring('aab') -> 2
- Write a function that takes a string and returns a compressed version (e.g., "aabcccccaaa" to "a2b1c5a3").
- compressString('aabcccccaaa') -> a2b1c5a3
- compressString('abc') -> abc
- compressString('aaaaa') -> a5
- compressString('aabbcc') -> a2b2c2
- compressString('') -> ``
- Write a function that takes a string and returns the longest palindromic substring.
- longestPalindrome('babad') -> bab or aba
- longestPalindrome('cbbd') -> bb
- longestPalindrome('a') -> a
- longestPalindrome('ac') -> a or c
- longestPalindrome('racecar') -> racecar
- Write a function that takes a string and a pattern (with ? and * wildcards) and returns true if the string matches the pattern.
- wildcardMatch('aa', 'a') -> false
- wildcardMatch('aa', '*') -> true
- wildcardMatch('cb', '?a') -> false
- wildcardMatch('adceb', 'ab') -> true
- wildcardMatch('acdcb', 'a*c?b') -> false
- Write a function that takes a string and a regex pattern and returns whether the string matches the pattern.
- regexParser('abc', '^a.c$') -> true
- regexParser('abc', '^a.d$') -> false
- regexParser('hello', 'h.llo') -> true
- regexParser('hello', 'h.*o') -> true
- regexParser('hello', '^h.*d$') -> false