# JavaScript and Decimal Places, A Shortcut to Insanity

Uhhhh, who invited Gottfried to the Party?

So after spending a couple of days trying to work through the freeCodeCamp algorithm script Exact Change I came across a rather unexpected issue.

In JavaScript (0.1 + 0.2 === 0.3) is false.

After running around in circles crying foul and threatening my laptop with a number of things that would break the Geneva Convention I had a look around the internet to see if anyone else had experienced the same problem.

It turns out that my anger was misdirected at my laptop (apologies); in fact it should have been aimed at a young man by the name of Gottfried Lebiniz, the inventor of binary.

The problem is that computers speak in the language called binary (a sequence of Zeros and Ones) meaning that numbers have to be stored in a format called “binary floating point”. This format is designed in such a way that it is unable to actually represent the true value of some decimal places.

In JavaScript 0.1 + 0.2 actually equals 0.3000000000000004.

Confused? Yeah me too, until I chanced across this video, it’s about 30 mins long but if you can get through it, you’ll no longer be preparing to hang your computer’s toes over some burning coals, but quickly googling good old Gottfried in order to put a curse upon him (he died in 1716 just fyi, I guess someone else got to him first). Also you might just learn a thing or two about how binary floating point works.

If you’d like some more information on the floating point format I’d recommend the website http://floating-point-gui.de.

As for the freeCodeCamp’s Exact Change … move over Ben Affleck, Math.round() has just become my new best friend.

# pain in the… back

me yesterday

So for my current day job I sit at a desk for 7-8 hours a day, and when I get home from that and hit the coding books, I’m back at another desk for 1-2 hours. This ongoing routine of sitting awkwardly has resulted in my back becoming stiffer than a 2×4 plank of wood.

Recently some kind soul who’s name I cannot for the life of me remember now (forgive me mystery angel) passed me a link to this video and it’s been a real boon to both my spine and sanity.

So I thought I would pass on the favour.

I might suggest that you try and find a quiet, discrete spot to perform these exercises, as you may get a funny look or two when flapping your arms up and down or climbing an imaginary ladder.

Good luck and keep climbing!

# I Built This!

See the Pen Free Code Camp Weather App by Luke (@escrew7) on CodePen.

This is my version of the Free Code Camp Weather App written up on Codepen. I’m pretty happy with how it has turned out. A couple of things I am particularly stoked about are the toggle on the degrees <div> where you can click to change from Farenheight to Celsius; and the minimal design of the app, which I think is suited to its purpose.

Free Code Camp along with Khan Academy have, to me, been two of the better free web development learning platforms. Both boast strong challenges along with great support networks for when you run into coding problems. Free Code Camp has really pushed me to my limits with JavaScript and on more than one occasion I’ve stormed off complaining about how the site is cheating me, only to realise that I’ve spelt “function” wrong.

One feature I’ve really enjoyed about Free Code Camp is that you can enter into a “contract” with the Camp, where each month you donate a sum of money to a choice of charities until you finish your selected certificate. It’s really rewarding knowing that you are achieving your goals of learning code whilst also giving others less fortunate a leg up in achieving their own dreams. I decided to donate monthly to the http://www.blackgirlscode.com/ school and have been 9 months.

freeCodeCamp is no walk in the park by any means, but if you really push yourself, the rewards that come from completing algorithms and projects is legit.

https://www.freecodecamp.com/

Give it a shot.

# Like Riding a Bike?

I recently took a little bit of time off of studying JavaScript to attempt the construction of some actual websites. So now that I had a couple of sites under my belt I decided to dive back into the Free Code Camp Front End Certificate.

Have you ever left a video game for a couple of months and then come back with absolutely zero idea of what is going on? Because that’s exactly what happened to me, I had no idea how to create a function, looping was lost on me and I couldn’t even remember the difference between an array and an object. Studying JavaScript is just like riding a bike… if that bike had no wheels and a cat for a seat.

But complete and utter despair at my lack of ability isn’t something that gets me down for (too) long and after a couple of weeks of persevering I was running through the intermediate problems with increasing confidence. As intimidating as stuff like this can be when you first look at it, once you have a basic grasp of the fundamentals, the world is your oyster.

I hate that saying… I don’t even like oysters.

The world is your oyster deep fried mars bar.

Fixed.

# week.length = x;

A weekly update of what I’m currently reading, watching and listening to.

Freakonomics – Steven Levitt and Stephen J. Dubner

This book is a really interesting read that gives you a different perspective on the world and what’s going around you. Their answer to the reasons behind the drop in crime in the USA still feels ridiculous to me.

x = listening

Tourist – U

This seems to by my go to music when trying to figure out JavaScript. Tourist is music that manages to relax and invigorate you at the same time.

x = watching

Bloodline

Defines the term ‘slow burn’, but crazy good acting and a super gritty storyline keeps you on-board and clamouring for answers. Ben Mendleson is the GOAT.

x = podcasting

Doughboys

Two comedians that review fast food restaurants in the USA. Thanks to these guys I’m this close to selling everything I own, moving to the USA and living the short, yet enjoyable dream of hyper-obesity.

# Critisism

Et Tu Grande?

So I’ve just finished creating a business site for a client and it has been a serious lesson in:

1. Not taking criticism to heart; and
2. Acknowledging that your own vision for a project may not match your clients.

After proudly showing the site off, there seemed to be quite a few questions of why I put certain things in places and why certain functions were needed. I believe I may have taken somewhat personally as I then proceeded to spend the next couple of hours brooding over a tub of café grande.

To be honest though, the criticism wasn’t actually that bad, in fact a lot of it was probably rather warranted. After looking over the site, comparing it to a number of others and skimming through a couple of design books, I realised that I needed to get back to the drawing board.

The revised site now looks and performs 100% better and my client is much happier.

The problem was not that the customer had decided to point out a couple of flaws; it was that I had invested so much of myself into the site that any small criticism felt like a stab in the back. If I want to reach the goal of actually turning this hobby into to any sort of career, that is not a position to put myself in.

What I now understand (and didn’t back then) was that I wasn’t just creating a piece of art for myself. I was solving a client’s problem by designing a web page to promote their business.

If they aren’t satisfied with the outcome, then I definitely can’t be.

Side Note:  whilst a litre tub of café grande may be great for the soul, your stomach may have a couple of counterpoints on the subject.

# A Full Plate

So I’ve got a lot to learn… literally.

My current to do list:

• Become compliant with languages html, css and javascript;
• Look into how SASS can improve a website;
• Learn how to utilise WordPress as a CMS for builds;
• Improve on my knowledge of graphic design and writing copy;
• Build a social network presence;
• Finish the 5 books I’m reading right now, 3 of which are related to work web design;
• Update this blog;
• And finally I have to squeeze in my actual day job somewhere.

Just writing all that out makes me want to crawl into a ball with a big mac, a whopper; some kfc fries, and a bakers dozen of krispy kreams (the doughboys podcast might have something to do with that too).

Even meditation is stressing me out (now I have to find 15 more minutes in the day just for that!).

First world problems yo.

Luke

# I think I’m missing something…

After stumbling around learning code for the last year and a half I realised that something was wrong. I could finally put together a website, but the site resembled something that had been put into an empty tyre and rolled down a hill.  Soon enough I understood, to become an effective website developer you must have decent knowledge of both relevant coding languages and basic design principles.

Truth be told, this realisation came along just after building a web page of my own, proudly showing it off to my friends and family, their expressions told truth, even if they wouldn’t, it was ugly. Eventually one of them was nice enough to pull me aside and ask if I had had any graphic design experience, after telling him no, he suggested I go and get some.

He was right, if my main goal was to sell my services to customers, then I had to learn how to sell theirs too.

Because I’m not really confident enough to show off my stuff just yet, I’ve had a look around and thanks to the website http://www.webpagesthatsuck.com/ I’ve included a couple of screenshots of websites that probably could do with a makeover or two… or five.

So I’ve spent the last month or two going through a bunch of design books, (gumtree, ebay and the good sammies are fantastic places to find cheap reads) and picked up my game. Now I have an understanding of how principles such as balance, contrast and repetition are applied, through proper use of design theory I can (hopefully) effectively communicate the message that I am attempting to convey.

Some of the books that I have gone through so far that have helped are:

They were all useful in different ways and I would recommend them all, I’ll probably get into specific reviews a little down the road.

Now to properly utilise this knowledge and build a website that doesn’t look like day old pizza!

Luke

# Whats Next?

About a year ago I experienced a “beacon of light” moment when my girlfriend wanted to create a blog, she asked if I knew anyone who could build one so I contacted a friend who owned a web design business and was quoted a number that sounded crazy. “This is ridiculous” I thought, “I can do that”.

And there it was.

I could do that! If I put my mind to it, worked hard, said my prayers and ate my vitamins I just knew that I could learn how to design and create half decent web sites, even more importantly, I now had a chance to make something of myself.

My name is Luke Rees and this blog will be a dairy of my (hopeful) progression as a front end web developer, along the way I’ll be talking about projects I’m working on, books I’m reading, topics I’m studying and generally just a bunch of other junk that’s happening in my life (which at the moment is house of cards and only house of cards).

It will also map my growth as a blogger, because from the looks of it; we’re starting off from a very low base.

So to anyone out there actually reading this, thanks for your time, feedback and tips are always appreciated and i’ll be back.