I wrote a log post some time ago when I had just learned about map. Excited with my new found knowledge I decided to share it with the world! Looking back I realize that I really did not understand map very well, or at least not well enough to explain it.

There is a big part of me that wants to delete that post. What if a potential employer sees it! They will see how not smart I am :( This digital trail is a terrible thing… Wait, digital trail?

If all I leave are the most accurate representations of my current knowledge - wherever that may be - no one will ever see how I grow and learn. As an employee it is vital that I be able to grow in whatever position I have. As an employer it is vital that my coworkers are also able and willing to grow.

Therefore I will not delete the cringeworthy indecipherable “explanation” of map that I wrote some time ago. Instead, in an effort to showcase the elasticity of my brain I will add to it the latest neat new thing I have learned.

Curry!

Much like how the current iteration of who I am today is the amalgamation of all the iterations that came before and to fully understand the who I am today requires that you know who I was yesterday and all the days before… This analogy - much like my attempt to explain map - is going no where. To the code!

Did you know you can create a function that returns another function that returns another function that returns… …until we have finally built our turtle!

function turtle(name) {
  return function(part1) {
    return function(part2) {
      return function(part3) {
        return `My turtle's name is ${name}. It has a ${part1}, ${part2}, and a ${part3}.`;
      }
    }
  }
}

const myTurtle = turtle('Tom')('head')('feet')('shell')
console.log(myTurtle) // My turtle's name is Tom. It has a head, feet, and a shell.

Crazy right?

But how about in some 1337 es6?

let turtle = name => part1 => part2 => part3 =>
    `My turtle's name is ${name}. It has a ${part1}, ${part2}, and a ${part3}.`

const curriedTurtle = turtle('Tom')('head')('feet')('shell')
console.log(curriedTurtle) // My turtle's name is Tom. It has a head, feet, and a shell.

TRY IT!