Your Work Matters, Right Now
Photo by Sherman Yang on Unsplash

Your Work Matters, Right Now

“I feel like I had all of this potential and I just wasted it.” – 27 year old me. Ten years ago I shared this sentiment with a mentor and friend over coffee at a Panera. I was working in retail and in a role that garnered little respect or admiration. Throughout my education I had reason to believe I was going to do something important with my life, something of value and instead I was five years into a career I was embarrassed of and I was unable to provide financially for my family without outside help. I was specialized at things no other company needed and I had no idea what kind of career to pursue. Right now…

Continue Reading
Keep Your Composure: Monads
Photo by joey graham on Unsplash

Keep Your Composure: Monads

This is the fifth article in a series on function composure in JavaScript. If you haven’t read the first four yet, I would encourage you to do so before reading this post, as the concepts discussed build on one another. Pt. 1: Pure Functions Pt. 2: Function Composure Pt. 3: Curry Pt. 4: Functors Over the last four articles I’ve illustrated how you can combine functions together into larger functions, and how Functors provide a means for continuing to combine functions together in a way that can help you cleanly address uncertain data, like the kind you might receive from the user or from an API call. The value is safely kept within the Functor and the method “map” allows…

Continue Reading
Keep Your Composure: Functors
Photo by Guillaume Bolduc on Unsplash

Keep Your Composure: Functors

This is the fourth article in a series on function composure in JavaScript. If you haven’t read the first three yet, I would encourage you to do so before reading this post, as the concepts discussed build on one another. Pt. 1: Pure Functions Pt. 2: Function Composure Pt. 3: Curry Function composition has proven to be a useful concept for transforming data through a series of smaller functions composed together into one single function. It gives you the flexibility to reuse the same smaller functions elsewhere and to change previously composed functions on the fly. However there are a few issues that come up when you start composing functions together. The first was the problem of multi-parameter functions, and…

Continue Reading
Keep Your Composure: Curry
Photo by Calum Lewis on Unsplash

Keep Your Composure: Curry

This is the third article in a series on function composure in JavaScript. If you haven’t read the first two yet, I would encourage you to do so before reading this post, as the concepts discussed build on one another. Pt. 1: Pure Functions Pt. 2: Function Composure Function composure is a powerful tool in and of itself. Combining several smaller functions into any number and variety of larger functions produces code that is easy to refactor and easy to read. However there is one glaring drawback to the type of function composure I’ve illustrated so far, and that is the fact that all of our functions can only have one parameter. A function will always return a single value…

Continue Reading
Keep Your Composure: Function Composure
Photo by Iker Urteaga on Unsplash

Keep Your Composure: Function Composure

If you are new to functional programming or programming in general, you may want to read the first article in this series on pure functions and then come back to this post. Now that you understand the general shape of a function that can be composed with other functions— a pure function with one input and with an output value type that matches the input expected by the next function— it is time to look at the syntax. const R = require("ramda"); const addTwo = x => x + 2; const multiplyThree = x => x * 3; const msg = x => `The answer is ${x}`; const doSomeMath = R.compose( msg, multiplyThree, addTwo ); console.log(doSomeMath(3)); // "The answer is…

Continue Reading
Keep Your Composure: Pure Functions
Photo by Robin Schreiner on Unsplash

Keep Your Composure: Pure Functions

One of the greatest tools in the functional programmer’s tool belt is this notion of composure. It’s a pattern that allows you to take two things and combine them, like LEGO pieces or the segmented tracks of a train set, and join them together in a myriad of ways with different structures or pathways each time. Combined with a few other functional programming tools working with it, you can use composure to do some pretty cool things, like passing data down a long pipeline of connected functions that check data types and only transforming valid input without ever causing the program to crash or throw an error. However before digging in to the fancy stuff, I'm going to start small.…

Continue Reading

Goals for 2019

2018 was the year I discovered software development. During the last half of the year I learned the fundamentals of JavaScript, Node, React, and Elm. I participated in my first hackathon, went to two different meetups monthly, and wrote my first 15 posts for this blog. I also completed several side projects and a portfolio website. It was a great year for new discoveries, new challenges, and a whole new trajectory for my career. It was a good year for building a foundation for future opportunities in software development. So where do I plan to go from here in 2019? Code for Nerds Blog Articles on this blog have been a little all over the place topically as I’ve been…

Continue Reading

React Component Testing with Enzyme and Jest: The Setup

Testing allows you to make changes to your code with confidence. If something breaks, you’ll know it. Using Jest to test functions in your code is relatively straight forward—you provide a function, input, and the expected output, and your test will confirm if everything is working as intended. This works great for when you want to test your reducers and selectors for Redux, but how do you test whether or not a component is rendering correctly? That’s where Enzyme comes in. Enyzme is a library created by Airbnb for the purpose of testing the render output of a React component. For the purposes of this article, I’m going to explain how you can get started with Enzyme to test your…

Continue Reading
Map, Filter, and Reduce: Using the Index Parameter
Photo by Holger Link on Unsplash

Map, Filter, and Reduce: Using the Index Parameter

This article requires some prior experience with map, filter, and reduce. For more information on reduce you can read my article on the subject, or if you are a beginner to all three, the documentation at MDN (Mozilla Developer Network) is an excellent place to start. If Dorothy had gone through a forest surrounded by map and filter and reduce (oh my!) she would have said “Kansas? What’s that?” and stayed in Oz. These three functions are incredibly powerful and can completely change the way you write JavaScript. They have quickly become the first tool I reach for when faced with a difficult coding problem. Now I’m not saying they are the silver bullet for every situation, just that I’m…

Continue Reading

Functional Fun with “FizzBuzz”

FizzBuzz is a classic coding challenge for the JavaScript beginner. It requires the programmer to print to the console a list of integers from 1 to 100 in which all multiples of three are replaced by the string “Fizz,” all multiples of five are replaced by the string “Buzz,” and all multiples of both three and five are replaced with the string “FizzBuzz.” The classic solution uses a “for” loop to iterate through the numbers and to determine what should be printed to the console. function classicFizzBuzz() { for (let i = 1; i <= 100; i++) { if (i % 15 === 0) { console.log("FizzBuzz"); } else if (i % 3 === 0) { console.log("Fizz"); } else if (i…

Continue Reading