Have you ever used a map, filter, or reduce function without thinking about it? Many of us who’ve been coding for a while have and we take it’s built in functionality for granted. I know I have. This is an appreciation blog for the wonderful functionality and components built into a coding language that I didn’t have build.

So one cool functionality I discovered built into the higher level functions of several JavaScript functions is the inherent index argument. Pulling the syntax for first three enumerable functions I learned from mozilla…

let newArray = arr.map(callback(currentValue[, index[, array]]) {

Two thirds of the way through this saga we have an avatar that moves around a screen, bumps into the edges of the screen, and has a single object that it “knows” is there and bumps into.

The last part of this is the most epic! For those of you who’ve stayed with me it’s been worth the wait. Remember in part 2 where I said ignore the forEach and objectArray part? Ignore them no longer. …

Alright, so abstraction is an incredibly powerful tool we all should respect what does that look like in code.

Well I had one point of origin I was using for my avatar the bottom left corner, why? :shrugs: Had to start somewhere. So my movement code looked like this.

function moveavatarDown() {  let bottomNumbers = avatar.style.bottom.replace("px", "")  let bottom = parseInt(bottomNumbers, 10)  if (bottom > 0) {  avatar.style.bottom = `${bottom -4}px`  }}function moveavatarLeft() {  let leftNumbers = avatar.style.left.replace("px", "")  let left = parseInt(leftNumbers, 10)  if (left > 0) {  avatar.style.left = `${left -4}px`  }}

You can imagine…

During my journey into coding, I’ve felt like a small child handed a rubiks cube, given a cursory explanation of what the box is and what the colors are, and the objective is to make the colors of each side the same. Sure I “know” everything now, but can I solve the puzzle?

The project I wanted to create was an arcade where I could continue to create games for my own entertainment and edification. To do that I needed to create an avatar that could walk around the arcade. I knew how to do that create an HTML element…

Allen Lea

A software engineer living in lonely world! He took the midnight train going anywhere.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store