Day 41: Functional Programming with splice, concat, and push

Photo by Tim De Pauw on Unsplash

Day 41: Functional Programming with splice, concat, and push

#100DaysOfCode Challenge

Today's Progress:

I completed a few more challenges on freeCodeCamp's JavaScript Algorithms and Data Structures course. I'm currently 58% done with the Functional Programming section.

Quotes & Key Ideas:

  • The splice method is used to remove elements from an array. It takes two arguments: the first is the index of where to start removing items and the second is the number of items to remove (if the second isn't provided, then default is to remove items to the end). NOTE: splice mutates the original array
  • The concat method is used to join items end to end. For arrays, it will not mutate the original arrays but return a new array with the combined items.
  • "Functional programming is all about creating and using non-mutating functions."
  • concat vs. push: concat does not mutate the original array while push does. This means if we want to add elements to an array without mutating it concat is a better choice

Thoughts:

I only made it a through a few challenges today, but I'm happy I made a little bit of progress especially considering it was my first day back at work after being sick. Today's challenges weren't too difficult. I had seen some of these methods in previous challenges, but in a different context. I'm enjoying being able to see the different use cases - I think it's helping me gain a better understanding of them.

freecodecamp.org/ananfito

You can read my full journal for #100DaysOfCode on GitHub