Guiding Light


Introduction

Staying Driven During a Pandemic

The COVID-19 Pandemic can feel overwhelming due to uncertainty, anxiety, fear, anger, and sadness. Here’s how I’ve managed to stay driven during the pandemic. I just graduated from coding boot camp last April and was super excited and motivated to begin my job search and new life as a Software Developer. Then came a global shutdown. All the nonessential businesses in my area and most of the world closed. I even had to close my massage business. The loss of income was incredibly stressful. On top of that, I lost three family members including my father to non-COVID related illnesses. Needless to say, my job search took a backseat as I comforted my family during the period of mourning. I needed to take care of myself as well because although it felt like it was the end of the world. It wasn’t. I worked very hard in school to graduate and be a success. However, I really missed my father and had a hard time getting motivated to find a coding job. Then I remembered a time when being in high pressured stressful situations was the norm, such as when I worked as a radiographer in shock trauma. I worked the evening shift and when I arrived at the hospital I would probably see five ambulances already there and might be two more on the way. I remembered how fearless I was backed then. As soon as I saw the requests for x-rays on the computer I’d grab a portable x-ray machine and jump in the middle of the fire. I would usually offer to relieve one of my tired co-workers who had been there all day. I was really, fearless, driven, and energetic. That’s what was going to take to find a coding job or any kind of job during the pandemic. To survive life in the shock trauma unit, I had to be fearless and a team player. I remember going to the gym five days a week for yoga, meditation, and sometimes weight-lifting class. It helped prepare me mentally and physically for life in shock trauma. After a period of mourning for my father, I decided it was time to get back on track. In addition to conditioning my body it was extremely important to focus on balancing my mind and spirit too. So, I decided to get up two hours earlier than normal, before even looking at my phone which was buzzing from messages left by clients. I took my yoga mat out of the closet and put on a 20 min yoga video from YouTube followed by a 5-minute meditation. Since it had been years since I practiced, it was tough at first, but I stuck with it. The most shocking thing was how tight my muscles were. I was very flexible five years ago. It felt like five years of stiffness as I worked through the postures. I didn’t care though. I felt so good that I followed my yoga practice with meditation. It was like eating Popeye’s spinach. The amount of energy I had was incredible. l felt so happy and energetic that I immediately rewrote my resume and continued my job search. I’ve been practicing yoga every day for a while now and it has been my driving force for positive change. I’ve also been solving tech challenges on CodeWars and honing and learning new skills on Codecademy. Life is so much better. I’ve made wonderful connections on Linkedin and look forward to having life long friends and new opportunities.


Understanding Recursion, Simply

This can be better seen on medium: https://medium.com/@lexus2424/understanding-recursion-simply-4fa57bcda5b

I think the concept of recursion can be difficult for new developers to understand and implement. As a new developer, I totally understand. So, I decided to write a blog that breaks down recursion in a way anyone can learn and understand. The point of this blog is once you learn the basics you can build on it, as you gain more experience through practice. I’ll go over what exactly recursion is and how to implement it using examples. What is recursion? Simply put, recursion is a function that calls itself inside its body until it’s stopped by a condition. Recursive functions are used to break down heavy data structures into smaller ones. Generally used in sorting and binary searches. Image for post A recursive function always has a condition to stop calling itself, otherwise, it will call itself indefinitely. I’m going to demonstrate this using an if statement. Image for post JavaScript recursive examples Suppose you need to develop a function that counts down from a specified number to 1. It’s always best to write a pseudocode before beginning to write your code. It’s a good way to keep track of your progress as you work through a problem. So, if you get stuck you can retrace your steps. To count down from 10 to 1, recursively, you can: show the number 10 call the function e.g, countDown(9) that shows the number 9 then call the countDown(8) that shows the number 8 continue until you call countDown(1) and stops at 0 create a condition that will stop the function once it reaches 0 Image for post Output: Image for post Using “null” in recursion The name of the function is a reference to the actual function object. Don’t forget functions are objects. If somewhere in the code, the function is set to null, the recursive function will stop working because we would be calling the function on an empty value. If this should happen you will get a TypeError such as this: Uncaught TypeError: countDown is not a function Here is an example of how you can use null in recursion Image for post Output: Image for post So, what I did was set function f to the variable countDown. Then towards the end of the code, I assigned countDown to the variable funCountDown, which will hold the current function object. Next, I reassigned countDown to null, so that it points to an empty value. Then I called funCountdown(10) and I received the above output. The concept here is if you assign the variable to a function so that it simply references the function object, you can later reassign the function to a new variable and set the previous one to null, so that the value is completely empty. Calculate sums using recursion Given a number 456, calculate the sum of the digits 4 +5+6 = 15. To apply the recursive technique, you can use the following steps: f(456) = 6 + f(45) f(45) = 5 + f(4) f(4) = 4 + 0 (stop here) So, f(456) = 6 + f(45) f(456) = 6 + 5 + f(4) f(456) = 6 + 5 + 4 Notice how we’re using the function object to break down the data structure to add the sum. This example shows the sum() recursive function: Image for post How this works: The num % 10 returns the remainder of the number after divided by 10, 456%10 = 6. The Math.floor(num/10) returns the whole part of the num/10, Math.Floor(456/10) = 45 The if(num === 0) is a condition that stops calling the function. Summary So the only way to understand recursion is through Practice Practice Practice! Start simply as we’ve done here then gradually work through harder problems, ensuring to write down pseudocode to give yourself a blueprint to reference. As you work with recursion remember a recursion function is a function that calls on itself until it’s stopped by a condition. If your call stack size has exceeded its limit, then it’s a sign that the function at some point was unable to stop. So make sure the function always has a condition to stop. References: Learn and Understand Recursion in JavaScript I’ll walk you through two popular JS recursion examples in 10 minutes so you can finally understand how recursion works… codeburst.io How to Use Recursion in Your JavaScript Code - dummies You can call functions from outside of the function or from within other functions with JavaScript. You can even call a… www.dummies.com A Quick Intro to Recursion in Javascript The function calls itself until someone stops it. Recursion can feel difficult to new developers. Perhaps that’s… www.freecodecamp.org



Understanding “this” in Arrow Functions

Arrow function implicitly returning an object The “this” keyword might be one of the most confusing and elusive parts of JavaScript because of its behavior in different contexts compared to other languages. This blog will explore “this” behavior in ES6 arrow functions, arrow function syntax, and implementation. Arrow functions were created to simplify function scope and make using the “this” keyword more straightforward. How “this” binds in ES5 code If the “this” keyword were inside an object’s method, a function that belongs to an object, it would reference the object. If “this” refers to the method’s inner function, it would be out of scope. It would then belong to the window object. Why does “this” bind to a window object? The answer is pretty simple, “this” always references the owner of the function it is in. When the “this” keyword is inside of an object’s method, the function’s owner is the object. Therefore, the “this” keyword is bound to the object. Yet, when it is inside of a function, either stand-alone or within another method, it will always reference the window/global object, “this” falls out of scope. Why does this happen? Developers reference it as a quirk, something that isn’t exactly straightforward, meaning it doesn’t work the way you think it should. To remedy this, developers came up with arrow functions ES6!


Ruby Cheat Sheet

Defining a Class in Ruby