Part I of the series “Code Makeover”
There are many reasons to refactor your code. It might be for better performance, more readability, improved maintenance and scalability, you name it. So, ready to check one of the easiest ways to start refactoring?
Today we’ll focus on what I’m calling the Chanel principle.
Before you leave the house, look in the mirror and take one thing off.
— Coco Chanel
There are lots of trinkets that make our code hard to read. …
Sometimes your code needs an array to run. No matter how long or empty the array is, you just need to keep running.
So far so good.
But let’s suppose your array comes from an external server and you have no control over it. Furthermore, both Malala and Abiy are busy on a Nobel laureate meetup and can’t come to see you. What will happen to your code?
undefined. And if other functions depend on
whoIsComing, your code breaks.
Failed with exception: TypeError: Cannot read property 'XXX' of undefined
How can you fix this, so your code keeps running anyway? …
Part III of “ Weird questions from my first month of coding”
Here I assume you know how to use each iterator. …
Part II of “ Weird questions from my first month of coding”
You might know by now that methods are functions in disguise. Some methods like filter require another function to run. So when you use filter, you are actually using a function inside another function (a callback). In terms as broad as the Amazon Forest, a callback is a function inside another function. More precisely, though, a callback is a function that is passed as an argument, but this precise definition was way above my rookie understanding.
Well, read the documentation, duh. Yeah, good idea:
But things don’t need to be that difficult. Let’s translate this to the real…
Part I of “ Weird questions from my first month of coding”
You finally got your webpage looking exactly the way you want. But… you know people have different devices, right? I mean, your site will look great in any screen size, RIGHT?
TLDR; Section 1 explains how it works, Section 2 explains the syntax and Section 3 shows the code.
If your answer is anything other than a resounding yes, you’re in the right place. Learn more about media queries, a neat and easy way to make your website look precisely as you want for any screen size of your choice.
This is what we’ll create together in this example: as the screen changes sizes, the layout changes too. …