Javascript Problem – Find Vowels in String

The purpose of this exercise is to count the number of vowels in a string.  This is actually pretty easy using a regex expression.  I use the match() method to pick out the vowels [aeiou].  The “g” in “/gi” tells the expression to match all occurrences, not just the first one.  The “i” tells it […]

Javascript Regular Expressions (regexp)

Javascript regular expressions (regexp) are very useful methods for string manipulation — match, replace, search and split.  I also find them pretty confusing.  In the previous post on the Javascript anagram problem, I used the following regexp to remove all punctuation, etc. from a string: str.replace(/[^\w]/g,”).  What does this actually mean?  It’s hard to decipher a […]

Javascript Chunking Problem

I worked this problem a couple of ways from both Stephen Grider’s Udemy Course and Traversy Media’s YouTube course. Below is solution 1.  I use a for…of loop.  First I determine what position the last element of the array would be (const last = chunked[chunked.length-1]).  I have to use chunked.length-1, because length counts the number […]

Javascript Reversed Integer Problem

Doing the Javascript reversed integer problem is pretty straightforward after doing the reversed string problem.  The only extra steps are to convert the number into a string “.toString()”, then an array “.split(”) and “.reverse()” to reverse it.  Finally, I need to use “.join(”) to convert it from an array back into a string, and “parseInt()” to […]