JavaScript30 — Day 17

Clare Eisentrout
2 min readMar 11, 2021

Using the Array.sort() method to alphabetize array elements, excluding their articles!

Bits

  • Regular expressions are used in JS to perform text search and replace functions. In other words, you can use a regular expression to isolate parts of a string and remove them, returning only the pieces that you want. We do exactly this in the “strip” function we wrote for today’s project. The basic syntax of a regular expression is “/pattern to search for/modifications to the pattern” — AKA, enclosed between forward slashes. This post is helpful in terms of why we use a caret in the regex. Never forget this resource for using regex!
  • There seems to be a different way of “creating a DOM element” in JS — imagine that! (I am sure there are many, many ways.) Today, we mapped over an array, then used a template literal including HTML tags, the changing JS variable, and set it all to an existing DOM element’s innerHTML. Pictured below.

Blindspots

  • In general, I don’t feel a sense of understanding about when and when not to use the “return” keyword. I’ve started slapping it all over the place, often, I believe, in places it is not necessary.
  • I could be clearer on the .map() method. I think this one trips me up simply because I haven’t made the connection between what the method is named (map) and what it does. The functionality doesn’t feel very “map-like” to me at present.

Breakdown

Spent the morning with my dog at the vet, so today’s breakdown is going to be the planting of a seed to grow at a later date! I found some good resources for familiarizing myself with the unfamiliar ES6 syntax from yesterday, and I have a feeling this cheatsheet will be super helpful.

Commented code from today’s project is, as ever, here!

--

--

Clare Eisentrout

Creative person using her brain to learn how to code.