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 Capitalize First Letter in Every Word Problem

In this problem, I am taking in a string and capitalizing the first letter of every word.  Here I use a for…of loop.  First I use the split() method to convert the string into an array and take the first letter of every word and capitalize it.  Then I use the slice() method to add […]

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 Anagram Problem

This is the anagram problem I reviewed using Stephen Grider’s interview prep on Udemy. Amagram: a word, phrase or name formed by rearranging the letters of another, such as cinema from iceman (Google Dictionary). The challenge is to compare two sets of words or phrases to see if they contain the same number of each letter. Option 1 – […]

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 […]