<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TechSharp Blog]]></title><description><![CDATA[I'm front-end developer and a Data analyst enthusiast. In my own time, I like to try out different technologies, write about them, and help out the developer co]]></description><link>https://techsharp.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 10:27:10 GMT</lastBuildDate><atom:link href="https://techsharp.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Arrays under the hood]]></title><description><![CDATA[Learn how arrays work in programming: indexing, searching, inserting, and deleting items efficiently. #Programming #DataStructure]]></description><link>https://techsharp.hashnode.dev/arrays-under-the-hood</link><guid isPermaLink="true">https://techsharp.hashnode.dev/arrays-under-the-hood</guid><category><![CDATA[arrays]]></category><category><![CDATA[data structures]]></category><category><![CDATA[Computer Science]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[programming languages]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Tue, 03 Oct 2023 16:31:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696350278398/1e6d72a0-400c-4e47-9d1f-79e555e0898b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have ever created a shopping list for a trip to the grocery store, you have already used an array without even realizing it. But if you haven't, try picturing it as a list of items you plan to receive for Christmas.</p>
<p>Arrays can be ordered or unordered, but that's another day's topic. The key takeaway is that arrays help developers manage lists of items efficiently.</p>
<p>An array is one of the fundamental data structures in programming. This article assumes that you are already familiar with it. To define it clearly, an array is a sequence of collections of a single data type (in statically typed languages) or various data types (for non-statically typed languages).</p>
<p>For example, if you have an e-commerce website that allows users to create a shopping list, it might resemble the below:</p>
<pre><code class="lang-python">array = [<span class="hljs-string">"milk"</span>,<span class="hljs-string">"sugar"</span>,<span class="hljs-string">"banana"</span>,<span class="hljs-string">"apple"</span>]
</code></pre>
<p>Without the knowledge of arrays, a developer will be forced to create different variables that will store each item in the list above. This will make these variables harder to maintain and keep track of changes made to each item. The importance of arrays can not be overemphasized.</p>
<p>Now you understand why this data structure, let us look at how they work under the hood each time a developer declares and initializes one.</p>
<p>Before I go further, you should note that different programming languages have their way of storing these values in memory and mutating them. I will give you the general programming concept associated with this data structure.</p>
<p>To understand the array data structure or any data structure, we need to analyze the ways our code will interact with that data structure.</p>
<h3 id="heading-data-structure-operations">Data Structure Operations</h3>
<p>Almost all data structure has common ways you can interact with them. These include:</p>
<p><strong>Read:</strong> To simply put this, you are trying to look up a value at a particular index in the array. For example, you take the above list and try to read the value "<strong>milk"</strong> which is in the first position or index 0 from it. An index is how the computer keeps track of the position of each item in memory.</p>
<p><strong>Search:</strong> Searching is an operation that refers to looking for a value within the data structure. In the case of an array, you are looking to see if a certain value is present within it, E.g. Searching to see if "sugar" exists in our example above.</p>
<p><strong>Insert:</strong> Inserting refers to updating a data structure. If we decide to update that array above and add "<strong>yogurts</strong>" we have updated or inserted it in the array.</p>
<p><strong>Delete:</strong> The name only gives you an idea. This operation refers to removing an item from our array.</p>
<h3 id="heading-how-is-an-array-saved-in-memory">How is an array saved in memory?</h3>
<p>When we declare an array, for example</p>
<pre><code class="lang-python">array = [<span class="hljs-string">"apples"</span>, <span class="hljs-string">"bananas"</span>, <span class="hljs-string">"cucumbers"</span>, <span class="hljs-string">"dates"</span>, <span class="hljs-string">"elderberries"</span>]
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696339938643/f3b936ea-f31e-4a84-a3d2-3fabc158c1f3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696340264464/12a0d10a-7821-426e-ab39-a2c1162e6e9d.png" alt class="image--center mx-auto" /></p>
<p>The above diagram is a visual simplification of computer memory, and each number inside the block represents a memory address. This is how the computer keeps track of its storage.</p>
<p>When you create an array like the one we have above, the computer will look at the number of items in the list and create a sequential memory address to store each value in each memory address. The index variable in the first image is how the computer knows the position of each item. In most programming languages, the index starts at 0. We will adopt the same concept here.</p>
<p>Each item is saved in a memory address under the hood. Try to visualize a memory address as a street number used to identify a house. The index can be visualized the same way with a bit of difference.</p>
<p>An index of an array is like a number that tells us where something is in a list. Imagine a toy box with toys inside. Each toy has its number, and when you have a number, you can find the toy you want to play with. That number is like an index for the toys in the box. The index is the high-level abstraction of the memory address.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696341058887/717340f2-84f2-49c3-b502-cd6e696b0c1a.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-read-operations-in-array">Read Operations in Array</h3>
<p>When an array is saved, the computer knows which item is in the first position (index 0) by the memory address. So when a programmer tries to get an element in a particular index, say index 2, the computer takes the index and adds it to the base memory address (1010 for this case).</p>
<p>If I want to access the element in index 2</p>
<pre><code class="lang-python"><span class="hljs-comment"># 1010 + 2 = 1012 </span>

print(array[<span class="hljs-number">2</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>cucumbers
</code></pre>
<p>You can see that when the index was added to the base address of the first item, it was easy to get the memory address that houses that particular value. This operation is so fast you won't even notice. In the computer science concept that measures the speed of operations, we can say that this operation is always constant even if the array size grows X more. So reading in an array happens in constant time ( O(1) )</p>
<h3 id="heading-search-operations-in-array">Search Operations in Array</h3>
<p>When you try to search if an item is present in an array, the computer performs two steps to find this item.</p>
<ol>
<li><p>Iteration</p>
</li>
<li><p>Comparison</p>
</li>
</ol>
<p>The computer goes over each item in the array and compares each item to see if it equals the item you are searching for. It returns true when it finds it or false when it doesn't.</p>
<p>This search and comparison always starts from the first index in the array to the last index. Say we have one million items, the program will perform a million searches and comparisons. In the worst-case scenario, the item may be the last item on the list or may not even be present.</p>
<p>While this article is not geared toward how fast our search works, you can intuitively see that our search will take a linear time to complete. It means a search operation in arrays takes longer than a read operation. There are proven efficient ways to search arrays, but that's out of the scope of the article.</p>
<h3 id="heading-insert-operations-in-array">Insert Operations in Array</h3>
<p>The insert operation involves updating our array. In some cases, we can add elements to the end. Other times, we may add a new element somewhere in the middle or at the start of the array.</p>
<p>If we intend to add an element to a specific index, say index 2, the computer performs three operations:</p>
<ol>
<li><p>Shifts</p>
</li>
<li><p>Insert</p>
</li>
<li><p>Update</p>
</li>
</ol>
<p>Under the hood, the computer goes to that particular index, if it's not empty, it shifts every element after that index to the end before inserting the item into that specific index.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696342663197/5e61eb77-8ca3-4143-8110-d1ad5d6bd4e2.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696342727320/772b6aa2-f630-4b27-be9e-6a705b7947f0.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696342782769/fc59b129-679e-45bc-85e1-00ee8c15e29b.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696342821910/15dce51a-0219-40d1-acee-4d5d41cfac6a.png" alt class="image--center mx-auto" /></p>
<p>As you can see from the images above, Under the hood, the shifts are necessary to insert the new element.</p>
<p>In a best-case scenario, the element will be inserted at the end of the array. Since we consider worst cases as developers, imagine if we want to insert the new element at the beginning. This means that all elements in the array need to be shifted before the insertion.</p>
<p>This is a simple visualization of how insertion in an array works under the hood.</p>
<h3 id="heading-delete-operations-in-array">Delete Operations in Array</h3>
<p>Deleting an item in an array is similar to insertion. When an element is deleted from the end, the computer frees up that space. However, when we delete an item like "<strong>cucumbers</strong>" from the array, consider the visual representation of what occurs.</p>
<p>Step 1: We delete the element.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696343415169/5440b918-a292-4041-9c25-b38935884694.png" alt class="image--center mx-auto" /></p>
<p>Step 2: "dates" is shifted to the left.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696343524786/f5243255-3283-4254-a4d4-d057556db09e.png" alt class="image--center mx-auto" /></p>
<p>Step 3: "elderberries" is shifted to the left.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696343575257/71482b93-bcc7-4639-8424-fbda9b5ead64.png" alt class="image--center mx-auto" /></p>
<p>As you can see above, the computer performs two operations which involve:</p>
<ol>
<li><p>The actual deletion of the elements</p>
</li>
<li><p>The shifts that occurred to close up the gap</p>
</li>
</ol>
<p>In the worst case, deleting elements from the beginning of the array will make the computer shift all remaining elements to the left.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Choosing a particular data structure to save and manipulate your data depends entirely on the use case. We just studied how the array data structure works under the hood, and now you understand how each operation works under the hood. In future articles, we will explore other data structures and go in-depth on how to use them efficiently. Kudos to getting this far. See you soon.</p>
<p><strong>Photo/screenshot credit:</strong> A common sense to data structure and algorithms</p>
]]></content:encoded></item><item><title><![CDATA[How to Grow your Technical Profile.]]></title><description><![CDATA[Go the Open Source way.]]></description><link>https://techsharp.hashnode.dev/how-to-grow-your-technical-profile</link><guid isPermaLink="true">https://techsharp.hashnode.dev/how-to-grow-your-technical-profile</guid><category><![CDATA[Open Source]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Contribution & Impact]]></category><category><![CDATA[layer5]]></category><category><![CDATA[portfolio]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Fri, 23 Sep 2022 16:22:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1663949041194/cTM1W0937.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Junior developers these days are tasked with building outstanding portfolio projects in other to stand a chance against the senior guys. While these might look so easy, note that not every project you put in your portfolio will make you stand out. Unless you are a front-end developer whose primary concern is building web applications with a beautiful interface and great user experience, you need an impactful project on your portfolio to go a long way.</p>
<p>Let's share more context on what I mean by impactful projects. These kinds of projects are projects that solve real-life problems. For example, the <a target="_blank" href="https://sdgs.un.org/goals">17 sustainable development goals</a> that was adopted by the United Nations in 2015 to bring impactful solutions to the world populace.</p>
<h3 id="heading-what-is-open-source"><strong>What is Open Source?</strong></h3>
<p>The term open-source refers to software that is available to the public. It means that the code of this software can be seen, modified, and distributed by anyone. </p>
<p>There are Organizations referred to as open-source organizations. These organizations have open-source projects that they duly maintain and manage. While anyone can contribute to these projects, The purpose of the organization is to moderate the contributions made by the public. Imagine these organizations as persons that build software and then ask the general public to help them improve it either by sharing ideas or contributing technically.</p>
<p>Their job is to filter these ideas and technical contributions to make sure it aligns with the project goals.</p>
<h3 id="heading-how-does-open-source-help-me-build-a-portfolio">How Does Open Source Help me build a portfolio?</h3>
<p><img src="https://i.pinimg.com/originals/87/dc/79/87dc799670c06e9754bccb3b37d9541d.gif" alt />
If you recall, I noted above that these open-source projects are available to the public for contributions. The best way to start is by contributing. These organizations usually have the code on a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. The most popular of these kinds of platforms are <a target="_blank" href="https://github.com/"><strong>GitHub</strong></a>. You can look through the <a target="_blank" href="https://docs.github.com/en/get-started/quickstart/hello-world">docs</a> to learn how to get started.</p>
<p>These projects call for people from different skill levels to contribute. They are usually open issues to choose from that will fit your skill set. Even if you don't find any issues you feel comfortable with, research their projects to look for issues you feel need to be attended to and then ask to be assigned.</p>
<p>While working on the issues and getting assigned to more tasks, you are growing technically as well as contributing to a large codebase that will make you stand out in the eyes of recruiters. You can talk about your contributions during interviews or even include these open-source contributions in your Resume with outlines of the impact you made.</p>
<p>Since people from different skill levels are part of the open-source community of contributors, it is an opportunity for you to network and learn from more skilled people than yourself. You also get the chance to have your code reviewed as you contribute. These people will drop constructive feedback that will shape you as a better developer and contributor.</p>
<h3 id="heading-who-can-contribute">Who can contribute?</h3>
<p><img src="https://cherrylmedia.com/wp-content/uploads/2021/04/tenor.gif" alt />
The answer is anyone. A basic understanding of the project is what is required. You can contribute through ideas or helping the community as a community manager and write technical content as a technical writer. If you can code even at the most basic level, then you are qualified to start making contributions.</p>
<h3 id="heading-how-do-i-get-started">How do I get started?</h3>
<p><img src="https://c.tenor.com/r3XdvPsAV3kAAAAC/despicable-me-minions.gif" alt />
All you need is to go to the organizational repositories of these open-source organizations on <strong>GitHub</strong> and check out what project you will be interested in. Then go through their open issues and ask to be assigned.</p>
<p>I contribute to an organization called <a target="_blank" href="https://layer5.io">Layer5</a>. It is an open-source organization that is building a service mesh. You can read more about service meshes in this elaborate article on <a target="_blank" href="https://layer5.io/resources/service-mesh/service-mesh-fundamentals">Service Mesh Fundamentals</a>. </p>
<p>I chose this community because of its uniqueness. If you are like me and like to be commended when you do a good job and to be treated like you are important, even if we are 1 million in the pool, then you should check out this community. I have to be completely honest, they are like family. They give room for anyone to grow from the ground up. You can join their <a target="_blank" href="http://slack.layer5.io">slack workspace</a> and check out their list of projects and the skills required to contribute to each <a target="_blank" href="https://layer5.io/community/handbook/repository-overview">here</a>.</p>
<h3 id="heading-list-of-open-source-organizations-to-consider">List of Open-Source Organizations to consider.</h3>
<ul>
<li><a target="_blank" href="https://layer5.io">Layer5</a>: <a target="_blank" href="https://github.com/layer5io/">GitHub</a></li>
<li><a target="_blank" href="https://thanos.io/">Thanos</a>: <a target="_blank" href="https://github.com/thanos-io">GitHub</a></li>
<li><a target="_blank" href="https://kubernetes.io/">Kubernetes</a>: <a target="_blank" href="https://github.com/kubernetes/kubernetes">GitHub</a></li>
<li><a target="_blank" href="https://karmada.io">Karmada</a>: <a target="_blank" href="https://github.com/karmada-io">GitHub</a></li>
</ul>
<p>The list above is not exhaustive. There are open-source projects that I didn't mention above. You can see more organizations in the <a target="_blank" href="https://summerofcode.withgoogle.com/programs/2022/organizations">Google Summer of Code list of open-source organizations</a> as well as the <a target="_blank" href="https://mentorship.lfx.linuxfoundation.org/#projects_all">Linux Foundation Mentorship program</a>.</p>
<p>For juniors looking for paid internships, there are open-source mentorship programs perfect for you. I already mentioned the <a target="_blank" href="https://summerofcode.withgoogle.com/programs/2022/organizations">Google Summer of Code</a> and <a target="_blank" href="https://mentorship.lfx.linuxfoundation.org/#projects_all">Linux Foundation Mentorship program.</a>. </p>
<p>I will write about how you can get into these programs in the future. For now, do your research, choose a project, and start building.</p>
<p>My advice for anyone just starting, the journey is a marathon, not a sprint. Therefore, take things easy, move at your own pace, don't stop building, and enjoy the process.</p>
<p>Feel free to add more open-source organizations or projects I missed above in the comments. Happy contributing.</p>
]]></content:encoded></item><item><title><![CDATA[Method Chaining in JavaScript Simplified]]></title><description><![CDATA[Best practices for writing clean JavaScript code]]></description><link>https://techsharp.hashnode.dev/method-chaining-in-javascript-simplified</link><guid isPermaLink="true">https://techsharp.hashnode.dev/method-chaining-in-javascript-simplified</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[best practices]]></category><category><![CDATA[clean code]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[THW Web Apps]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Sat, 07 May 2022 10:22:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1651918528738/zKsfnAF8E.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Learning programming is one thing, following best practices while coding is another thing. As a good practice, it is expected that when you write functions or methods, a method should do one specific task.</p>
<p>While you may be tempted to write a single method that performs all the tasks you want, it is recommended that the best practices should be followed.</p>
<p>Disintegrate giant function into multiple functions so that each one performs a specific action. This simplification helps you write clean and readable code.</p>
<h3 id="heading-method-chaining">Method Chaining</h3>
<p>This is a programming approach that helps you call methods on top of each other. This also helps you simplify your code.</p>
<p>With this strategy, you don't have to worry about writing one big function to perform a specific task. You can just write independent functions and chain them. Before we look at examples, let's look at what the <code>this</code> keyword is in <code>JavaScript</code>.</p>
<p><strong>this</strong> keyword references the current object in which it is called. When the <code>this</code> keyword is returned in a method, it simply returns an instance of the parent object.</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">a</span> (<span class="hljs-params"></span>) </span>{
   <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
 }

<span class="hljs-comment">// In a browser</span>
a() === <span class="hljs-built_in">window</span> <span class="hljs-comment">// true</span>

<span class="hljs-comment">// In nodeJs</span>
ab() === <span class="hljs-built_in">global</span> <span class="hljs-comment">// true</span>
</code></pre>
<p>The function above returns <code>true</code> because of its current context which is the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Window">window</a> object for the browser and <code>global</code> for <code>nodeJs</code> environments.</p>
<p>Let's look at the <code>use strict</code> <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode">mode</a> which returns <code>undefined</code> if the value of <code>this</code> is not set before entering the function.</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">a</span> (<span class="hljs-params"></span>) </span>{
<span class="hljs-meta">  'use strict'</span>; <span class="hljs-comment">// see strict mode</span>
   <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
 }

ab() === <span class="hljs-literal">undefined</span>; <span class="hljs-comment">// true</span>

<span class="hljs-comment">// In a browser</span>
a() === <span class="hljs-built_in">window</span>; <span class="hljs-comment">// false</span>

<span class="hljs-comment">// In nodeJs</span>
ab() === <span class="hljs-built_in">global</span>; <span class="hljs-comment">// false</span>
</code></pre>
<p>We have looked at the <code>this</code> in the functional context, now let's understand how <code>this</code> behaves in the JavaScript <code>class</code> context. </p>
<p>The <code>this</code> keyword behaves similarly in classes and functions since classes are like functions under the hood in <code>JavaScript</code> but there are few differences.</p>
<p>Within classes, all properties of the <code>class constructor</code> are added to the <code>this</code> context.</p>
<p><em>More examples:</em></p>
<pre><code class="lang-js"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ArithmeticClass</span> </span>{
  <span class="hljs-keyword">constructor</span>() {
    <span class="hljs-built_in">this</span>.value = <span class="hljs-number">0</span>;
  }

<span class="hljs-comment">// get value</span>
  <span class="hljs-keyword">get</span> <span class="hljs-title">getValue</span>() { 
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>.value
   };

  sum(...args) {
    <span class="hljs-built_in">this</span>.value = args.reduce(<span class="hljs-function">(<span class="hljs-params">sum, current</span>) =&gt;</span> sum + current, <span class="hljs-number">0</span>);
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
   }

  add(value) {
    <span class="hljs-built_in">this</span>.value = <span class="hljs-built_in">this</span>.value + value;
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
   }
  subtract(value) {
    <span class="hljs-built_in">this</span>.value = <span class="hljs-built_in">this</span>.value - value;
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
  }
  average(...args) {
    <span class="hljs-built_in">this</span>.value = args.length? (<span class="hljs-built_in">this</span>.sum(...args).value) / 
  args.length: <span class="hljs-literal">undefined</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;
  }
}


<span class="hljs-keyword">const</span> ArithmeticClass1= <span class="hljs-keyword">new</span> ArithmeticClass();
<span class="hljs-keyword">const</span> firstArithmeticInstance = ArithmeticClass1
  .sum(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>, <span class="hljs-number">6</span>)   <span class="hljs-comment">// =&gt; { value: 10 } </span>
  .subtract(<span class="hljs-number">3</span>)   <span class="hljs-comment">// =&gt; { value: 7 }</span>
  .add(<span class="hljs-number">4</span>)        <span class="hljs-comment">// =&gt; { value: 11 }</span>
  .getValue        <span class="hljs-comment">// =&gt; 11 </span>

<span class="hljs-built_in">console</span>.log(firstArithmeticInstance) <span class="hljs-comment">// =&gt; 11</span>
</code></pre>
<p>This clearly shows you how each method in the <code>ArithmeticClass</code> returns the instance of the class which can be chained to any other method in the class.</p>
<p>While we can write a giant function that takes in a value/values, and the type of arithmetic operation we want to perform e.g. sum, and then probably use the <code>if</code> statement to perform any of the actions we want, Writing it the way we did above simplifies our code, makes it more readable and also, makes it more scalable in the future.</p>
]]></content:encoded></item><item><title><![CDATA[Filter The Noise]]></title><description><![CDATA[Find success by defining your own path and becoming the best version of yourself.]]></description><link>https://techsharp.hashnode.dev/filter-the-noise</link><guid isPermaLink="true">https://techsharp.hashnode.dev/filter-the-noise</guid><category><![CDATA[motivation]]></category><category><![CDATA[lifestyle]]></category><category><![CDATA[life-hack]]></category><category><![CDATA[development]]></category><category><![CDATA[life]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Tue, 02 Nov 2021 15:50:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1635867989507/eJ278s8jt.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>"Success is not final; failure is not fatal: It is the courage to continue that counts."</em></p>
<p>It is never a good feeling to be considered a failure by others. But the question is, are you a failure? </p>
<p>Before we answer this, I want you to understand what defines success.  </p>
<p>Many people today compare their success with the success of others. But is that what succeeding is all about? Well, I think we all have different journeys and purposes in this life and should be focused on achieving that.</p>
<p>To get more into perspective, a person may consider owning a house as a measure of success, but that is just perception and not a characteristic of successful people. Don't get me wrong, owning a house is important, but it can only be counted as a criterion for success if it is an individual priority or meets one's personal goals. You can agree with me that Jeff Bezos doesn't count owning a house as success (He has tons).</p>
<p>According to so many sources on a simple Google search, <strong>Success is the state or condition of meeting a defined range of expectations</strong>. If this is true, then we should be looking deeper at what we call success.</p>
<p>In today's world where we have allowed society and peer pressure to influence some of our actions and decisions, it has become inherent in us to always try to live our lives as expected by others. This has done more damages to our dreams and the values we once held. </p>
<p>To be able to conquer this disease and go forward as independent self-thinking humans, we need to first decide what our goals are and map out a plan of how we want to pursue and achieve them. Else we would remain in the shackle of defining our values by what others think.</p>
<p>In this article, I will be showing you some proven habits you need to develop to help you filter 
the noise and go forward to succeed by the path you defined for yourself.</p>
<h2 id="who-are-you">Who are you?</h2>
<p>If a total stranger meets you on the road and asks you this question, can you answer it without really thinking too hard about it? The problem with so many people today is that they don't even think for themselves. They can't even define who they are, what their goals or purposes are, and why they are living. If you can't figure these things about yourself then, unfortunately, I'd say you are lost.</p>
<p>Allow me to take you on a story ride.</p>
<p>A man set out on a journey to another country to find a hidden treasure on a faraway island. To get to that island he must go across the sea with a small boat he had already built previously in preparation for that journey. </p>
<p>He had to paddle his way to the island. While on the journey, he lost his paddle, and not too long after, the sea tide came and began to move the boat in another direction. Because he has lost his paddle, he was no longer in charge of the direction the boat was going. He was lost forever and was rather taken to another island where wolves ate him.</p>
<p>If you can't define your purpose in life, you are like that man. You had good intentions from the start but allowed the noise around you to change your direction. You need to find your paddle and get back that power to decide your path.</p>
<h2 id="you-are-different">You are different.</h2>
<p>The only behavioral characteristics we share as humans are the fact we are higher animals. That is it! nothing more. You can agree with me that even identical twins don't behave the same. They don't talk the same and sure don't share the same fingerprint. </p>
<p>This shows that we were all born different from the beginning and should have different paths.</p>
<p>You need to realize this when defining your path. It is easy to be blown away by the tides of expectations if you lose your paddle. You need to stand firm on your decisions to be able to get to your desired destination.</p>
<h2 id="some-journeys-take-time">Some journeys take time.</h2>
<p>I understand that as humans, We are impatient beings by nature, and we all want quick results. But there is a phrase that says that "Patience is a virtue". It means you have to develop patience.</p>
<p>In your journey to success, there is no definite time of arrival. Some journeys take time more than others do. That doesn't mean that a journey is more important than the other. We just have different arrival periods and should be patient enough to get to our destination. </p>
<p>If you are not patient enough and decide to follow others on their journey, well you will arrive with them but only to find out that you have been on the wrong journey all this while.</p>
<h2 id="go-all-the-way">Go all the way.</h2>
<p>Have you found your path? have you decided to see it through? if your answer is <strong>Yes</strong> now this is where you need to be more cautious. </p>
<p>A lot of people start a journey but never get to their destination. The road is rough and bumpy and it is easy to have a rethink and decide to abort. But the journey of life is not for the weak. </p>
<p>You need to be aware that many challenges will make you want to discontinue your journey. You need to hold your paddle tight and never allow the tide to decide your direction. You need to go all the way to the end regardless of what others think. Getting to the end of your well-defined path. This is what I call success. </p>
<h2 id="conclusion">Conclusion</h2>
<p>Your success shouldn't be defined by others. You should be in charge of your life and define what you call success. Getting the world is important but actualizing your dreams is more important. This will make you feel more fulfilled than riding in the best yacht or cruising in a Ferrari.</p>
<p>I will leave you with my favorite quote from the movie three idiots. <strong>"Pursue excellence, and success will follow"
</strong></p>
]]></content:encoded></item><item><title><![CDATA[Everything is Learnable]]></title><description><![CDATA[A Beginner's Dream Guide to Mastery]]></description><link>https://techsharp.hashnode.dev/everything-is-learnable</link><guid isPermaLink="true">https://techsharp.hashnode.dev/everything-is-learnable</guid><category><![CDATA[motivation]]></category><category><![CDATA[Learning Journey]]></category><category><![CDATA[learn coding]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Sun, 31 Oct 2021 13:25:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1635684015194/2RNuaUopT.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever given a thought to how you can do some of the things you do in auto-pilot mode? Let me be more clear and explain further. </p>
<p>We all can agree that all human beings living on earth today were once babies (except we have alien-human living among us. Who knows?😉). </p>
<p>As babies, we had to be catered for by other people. We couldn't do so many basic things ourselves. We didn't even know how useful our hands were and the wonders they can accomplish when put to work. </p>
<p>That means that there was a point in our lives when we knew next to nothing.</p>
<p>But no one remains a baby forever. As we grew, we started learning how to talk, eat, crawl, stand, run, etc. Thinking back, you can't tell how you were able to achieve these feats, considering how difficult and risky it was to learn how to do them. But you did learn them anyways. </p>
<p>Now that you are an adult, you do these things without even thinking about it. You can talk easily and faster too, run for 100m in 9.58 seconds (If you are Usain bolt😁), and jump so high that you may nearly touch the sky. What happened? how were you able to learn these things and master them? Well, the rest of the article will help you answer that.</p>
<p>Learning something new can be daunting at first, especially when you have no prior knowledge or background that you can build on. These have made people grow cold feet and give up on their journey to become a master in whatever they previously set out to learn. </p>
<p>But these kinds of scenarios are not new. To achieve any great feat in whatever you are doing, you have to face challenges to learn. These challenges are what you will later refer to as experiences when you finally conquer them.</p>
<p>Just like the baby example above, there were so many occasions when we fell on the ground while learning how to walk, bruised our knees while learning how to run, and even spoke so many gibberish things before we could say "Mummy" but we kept on trying regardless. In the end, we were able to conquer these little setbacks and grew into experienced adults.</p>
<p>In the same light, being a beginner in the tech space or any other space can have its setbacks. Understanding these setbacks and the way to conquer them is the only way you can move forward.</p>
<p>At the end of this article, you should be able to</p>
<ol>
<li>Understand the problem</li>
<li>How to conquer the problem and move forward.</li>
</ol>
<h3 id="understanding-the-problem">Understanding the problem.</h3>
<ul>
<li>Unrealistic Expectations. </li>
<li>Unhealthy Comparison.</li>
<li>Impostor Syndrome.</li>
</ul>
<h4 id="unrealistic-expectations">Unrealistic Expectations.</h4>
<p>When I first started learning JavaScript, I was told by a friend that in six months, I will have learned enough to land me a good job. While these can be true for others, it is not generic to everyone. We all learn differently at a different pace too.</p>
<p>Most beginners start their journey with a roadmap given to them by others. I am not saying that roadmaps are bad, but some of these roadmaps have average completion time expectations attached to them. These expectations sometimes affect the self-confidence of the learner when they are not able to learn what is needed to be learned in that duration. </p>
<h4 id="unhealthy-comparison">Unhealthy Comparison</h4>
<p>Most people usually compare their success rate with that of other people. While this is not a bad thing if it helps you work hard, it sometimes affects your progress and improvement. </p>
<p>As a beginner to programming, imagine comparing your progress with a full-stack developer who has been coding for five years. This can immediately shut your eyes from seeing the little progress you have made and might even throw you into a depressing state of mind, that you even begin to question your learning abilities.</p>
<h4 id="impostor-syndrome">Impostor Syndrome</h4>
<p>This is one of the popular challenges every beginner or learner faces in their journey to mastery. I faced it and sometimes still do but what is it exactly?</p>
<p>According to <a target="_blank" href="https://en.wikipedia.org/wiki/Impostor_syndrome">Wikipedia</a>, <em>" Impostor syndrome is a psychological pattern in which an individual doubt their skills, talents, or accomplishments and has a persistent internalized fear of being exposed as a "fraud". Despite external evidence of their competence, those experiencing this phenomenon remain convinced that they are frauds and do not deserve all they have achieved"</em>. </p>
<p>This feeling can come when you are trying to accomplish a task you feel that you are supposed to already know and yet you can't figure it out yourself. Immediately, you start feeling incompetent.
What this does is that it introduces self-doubt and therefore affects your progress in your learning journey. </p>
<h3 id="how-to-conquer-the-problem-and-move-forward">How to conquer the problem and move forward.</h3>
<p>We have already spent so much time listing out some of the main problems faced by beginners, now let us see a few points on how these problems can be conquered.</p>
<ul>
<li>Set your expectations.</li>
<li>Be your competition.</li>
<li>Be consistent.</li>
<li>Believe in your abilities</li>
</ul>
<h4 id="set-your-expectations">Set your expectations.</h4>
<p>As a beginner, instead of trying to live up to other people's expectations, it is healthy to have mapped out plans of the milestones you plan to achieve. This will serve as a personal guild for you in your journey. It will also help you check if you are progressing or not and if you need to improve your pace or otherwise.</p>
<p>So for me, when I started out learning JavaScript (Programming language), I had a list of what I wanted to achieve in a month. It wasn't much, but I tried as much as can to make it as flexible as I can. It helped me to focus on my learning. In the end, I was able to achieve my expectations. That boosted my confidence and helped me progress.</p>
<h4 id="be-your-competition">Be your competition.</h4>
<p>Instead of comparing yourself with other people why not compare yourself to yourself. Ask yourself a daily question like, "What can I do today to be a better version of who I was yesterday in line with my goals"? If you can answer this question and do something to enact the change, you will learn and improve every day.</p>
<h4 id="be-consistent">Be consistent.</h4>
<p>If you have ever heard the phrase <em>"Slow and steady wins the race"</em>, then you have already met consistency. This phrase simply translates to <em>Consistent, effective effort leads to success.</em></p>
<p>Cultivating the habit of consistency will go a very long way to help you improve the skills you are learning. Consistency helps you measure success and progress easier. </p>
<p>while learning, instead of going ten hours in a day and then coming back after fours days for another round, why not break those hours in chunks daily. This will help your brain retain more as well as helps you make it a habit and stay consistent. Learning this way will make you more productive too.</p>
<h4 id="believe-in-your-abilities">Believe in your abilities</h4>
<p>We oftentimes doubt ourselves more than other people doubt us. In your journey to mastery, it is normal for you to feel this way especially when you meet a challenge that seems unsolvable or very hard. But instead of having to entertain this feeling for so long and allowing it to affect your progress, I will advise that you always see such problems as an opportunity to learn more. This way, your interest will be spiked to solve that problem. This will also change how you view and tackle the problem. </p>
<p>Every problem you solve gives you an experience that will be needed in the future when you meet a similar problem. So instead of running away or allowing a problem to demotivate you, believe in your abilities and use that as a stepping stone to progress in your learning.</p>
<h3 id="conclusion">Conclusion</h3>
<p>Gaining mastery in anything can be hard at first but always remember that no one became a master without practice, perseverance, and consistency. These three things are the keys to going forward as a beginner. So give yourself some pat on the back for every progress you make. Remember that as a baby you couldn't do a lot but now you can do so many things with ease. These things you learned took time and practice and so will everything we try to learn. So when you start feeling demotivated or having that impostor syndrome, don't forget that <strong>Everything is Learnable</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[My 2020 in review]]></title><description><![CDATA[Starting this article gave me the opportunity to reflect on the best and worst way I spent the year 2020. I had so many deep thoughts reflecting on how far…]]></description><link>https://techsharp.hashnode.dev/my-2020-in-review</link><guid isPermaLink="true">https://techsharp.hashnode.dev/my-2020-in-review</guid><category><![CDATA[motivation]]></category><category><![CDATA[internships]]></category><category><![CDATA[Certification]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Fri, 01 Jan 2021 03:03:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1609469853017/CbPYqxRfW.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Starting this article gave me the opportunity to reflect on the best and worst way I spent the year 2020. I had so many deep thoughts reflecting on how far I have come and also how much I learned in the year everyone wrote off as one of the worst years they ever experienced. </p>
<p>The year 2020 taught me a great deal and I grew so much in my personal development that when I look back, I can't help but wish there would be another 2020. </p>
<p>Now before you go off and criticize me, read this article to the end to better understand the awesome lessons 2020 taught me and how it shaped me technically and otherwise.</p>
<h3 id="the-pandemic-opportunity">The pandemic opportunity.</h3>
<p>In my home country Nigeria, the pandemic became very serious around the month of March and that was when the government declared a total lockdown of offices, shops, churches, schools amongst other places in the country that can draw a crowd. </p>
<p>To so many people it was a shutdown, a bad omen, a legit excuse to quit, blame the government for failing the people, and also a good reason to turn to fraud. It was easy to blame others and look for shortcuts to survive. In fact, no one would blame you for becoming a bad guy given the hardship in the country.</p>
<p>At that same time, I just finished my first internship with Dathappy (remote) as a junior machine learning engineer. I had so many gigs coming my way from friends but I couldn't take any. The problem was that those gigs were centered around web development and I knew next to nothing about web development at the time. Did I say I knew nothing about web development? well, I lied. </p>
<p>During my internship with Dathappy we ( me and my team) had to build a front-end for our machine learning model using the python framework Flask to abstracts away the technicalities for our clients during the beta testing. That was when I realized the importance of having a software engineering skill as a machine learning engineer especially if you are going to be working for start-ups.</p>
<p>So while others were looking for shortcuts, I was looking for a way to skill up and become a better developer. I understood that I might not have all the time to myself again once the pandemic blows over. In all the options available, I chose to grow my technical skills.</p>
<h3 id="understanding-self">Understanding self</h3>
<p>After my internship with Dathappy which ended around March, I knew the next thing on my radar was to learn front-end development. What I couldn't figure out was how I can achieve that while staying focused. </p>
<p>Being a self-taught developer I knew I could dedicate my time to learning the technologies involved and within a few months, I would be blazing hot as a web developer. Building beautiful websites and taking gigs. As easy as it was to think about the journey I was about to embark on, I knew right away that I wouldn't reach my destination without a push and so I started looking for a web development internship.</p>
<h3 id="the-genesys-opportunity">The Genesys Opportunity</h3>
<p>In the year 2019, while I was still in my 2nd year as a mechanical engineering student, I applied to become a frontend intern at a company called Genesys. It wasn't surprising that I was rejected at my first trial.</p>
<p> Even though so many factors surrounded the rejection, one I can vividly point out was my unpreparedness and also some obligations I had as a university student. But I  still didn't fail to try my luck.</p>
<p>Now with the total lockdown in place, I was presented with another opportunity to reapply as a remote frontend intern in the same company which later went on to become my one the best decision I have made so far.</p>
<p>I applied and after the rigorous interviews, I was accepted as an intern. It wasn't easy at all in grasping all the knowledge they tried to pass to us. It was even much harder because it was a remote role and therefore we had to learn a lot on our own. We built some pet projects on the go as we progressed. Some were fun while we had a lot of difficulties figuring out some. Well, no one said programming was easy.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1609470369966/jR0kLRxOZ.png" alt="Screenshot (112).png" /></p>
<p>In the space of four months down the line, I have already had hands-on experience with HTML, CSS, JAVASCRIPT, and even the frontend framework REACTJS. To top it off, I learned how to collaborate with team members. It was rather a blessing in disguise for me because if my school was in session, I wouldn't have had the time to fully participate as an intern.</p>
<h3 id="becoming-a-dsc-lead">Becoming a DSC Lead</h3>
<blockquote>
<p>Developer Student Clubs are university-based community groups for students interested in Google developer technologies. Students from all undergraduate or graduate programs with an interest in growing as a developer are welcome. By joining a DSC, students grow their knowledge in a peer-to-peer learning environment and build solutions for local businesses and their community.</p>
</blockquote>
<p>Becoming the leader of a community like this was great prestige. I applied the previous year 2019 but was rejected. I felt like I had the world on my shoulders. But the difference this time was that instead of the world, It was the reputation of my school on my shoulders. I will be building a lot of people up to make them become better individuals and also to help them become job-ready after school.</p>
<p>At first, I couldn't figure the best way to go. I knew I wouldn't go far if I wanted to push the community alone all by myself. So I formed a core team who have been supporting me through the journey as a leader.</p>
<h3 id="summary">Summary.</h3>
<p>I don't think I can put 366 days in just an article so let me quickly highlight some of my wins and losses that made my 2020.</p>
<ul>
<li>I got a Data Analyst Nanodegree from Udacity</li>
<li>I completed My Machine Learning Internship and earn my first money as a programmer</li>
<li>I started my web development journey as a frontend engineer</li>
<li>Became a mentor in Google Africa Developer Scholarship</li>
<li>I got rejected for a job at Grafana labs</li>
<li>Missed out on Google Associate Cloud EngineerIng certification for the second time in a role</li>
<li>I became the DSC lead after my first rejection</li>
<li>I became an ingressive for good (I4G) lead </li>
<li>I became a barter Ambassador</li>
</ul>
<p><strong>Note:</strong> Success and failure are measured by the goals you set for yourself so set new goals for yourself and try as much as you can to smash them.</p>
<p>In summary, it was an interesting year for me. Some days Ieft me depressed, some left me happy. But in all, I am thankful for the lessons I have learned and the awesome friends I made in 2020. We move again this year 2021. Happy new year!!!!</p>
]]></content:encoded></item><item><title><![CDATA[Understand and write JavaScript functions like a Pro]]></title><description><![CDATA[As a beginner who just started writing JavaScript, have you ever found yourself writing the same code same repeatedly to achieve the same result or declare…]]></description><link>https://techsharp.hashnode.dev/understand-and-write-javascript-functions-like-a-pro</link><guid isPermaLink="true">https://techsharp.hashnode.dev/understand-and-write-javascript-functions-like-a-pro</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[functions]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Thu, 19 Nov 2020 02:48:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1605754031854/U_a-JyM9X.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p> As a beginner who just started writing JavaScript, have you ever found yourself writing the same code same repeatedly to achieve the same result or declare so many variables in your global scope to help you achieve a task procedurally (I will elaborate more on scoping so don't think about it too much for now)?</p>
<p>Then you need to read this article meticulously because this is definitely the game-changer you need to make you a better developer who writes clean and well structured readable code using functions.</p>
<p>At the end of this article, you should already understand</p>
<ol>
<li>What is a function and how essential it is to programming</li>
<li>How to define a function using a variable and built-in function keyword</li>
<li>Types of function in JavaScript and what are the differences between them</li>
<li>Scoping and how they relate to function</li>
</ol>
<h3 id="what-is-a-function-and-how-essential-is-it-to-programming">What is a function and how essential is it to programming</h3>
<p>The function is the holy grail of programming, the way it helps us abstract away lots of code and saves it in a value is simply amazing. </p>
<p>Let me use a real-life picture to give you a better understanding of what a function is before I go forward to give you a more in-depth explanation of a function programmatically.</p>
<p>Let us take our analogy using a car, imagine the car functions and how each function is abstracted away from the other and yet works simultaneously. </p>
<p>The driver doesn't have to worry about what happens when he matches the break, he knows within himself that measures have been put in place to ensure that the break does its job. </p>
<p>I can go on and start explaining what happens under the hood when a car break is matched, but that would be me flexing my muscles in mechanical engineering. Though by now I think you already got the gist.</p>
<p>Segregating our codes into functions gives us a way to structure our larger program into smaller chunks and make sure that the variables defined within remains local to the function and doesn't interfere with other parts of our programs. </p>
<p>Functions also help also avoid code repetition and flooding our namespace with so many variables.</p>
<h3 id="how-to-define-a-function">How to define a function</h3>
<p> You now understand what a function is and how useful it is to developers, so let us now look at ways we can define one. </p>
<p>one of the ways we can define our function is by declaring a variable where the value is written as a function.</p>
<p>let's look at an example</p>
<pre><code><span class="hljs-keyword">let</span> square = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">x</span>) </span>{
  <span class="hljs-keyword">return</span> x * x;
};
<span class="hljs-built_in">console</span>.log(square(<span class="hljs-number">2</span>));
<span class="hljs-comment">// prints 4 to the console</span>
</code></pre><p>Let me explain what happened in the code above. We declared a function and saved it in a variable name we defined as a square. What it means is that whatever the function returns will be the value saved in our square variable. Our function also takes in an input which is referred to as a function parameter and multiplies that input by itself.</p>
<p>In JavaScript, a function is declared starting with the function keyword. The function body must be wrapped in curly braces and that is where the main action happens. Functions can have multiple parameters or no parameter at all. </p>
<p>Let us look at another way we can define our function with another code example</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">greet</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, World"</span>);
}

greet();<span class="hljs-comment">// prints Hello, World</span>
</code></pre><p>If you understood the first example, this wouldn't be hard to comprehend either. What I did differently here is to start my function declaration with the JavaScript function keyword before its name. </p>
<p>The greet function has no parameter and a return keyword, which brings me to another point. In fact, it was one of the things I struggled with when I was learning JavaScript functions. </p>
<p>I always found myself asking how a return keyword differs from console.log in a function and since I don't want you to pass through the same vicious circle let me elaborate. </p>
<p>Return keyword returns a value that can be saved separately in a variable and used afterward while console.log just prints out stuff and can't hold a reusable value within the function.</p>
<p>Let us look at an example with our square function</p>
<pre><code><span class="hljs-keyword">let</span> square = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">x</span>) </span>{
  <span class="hljs-keyword">return</span> x * x;
};


<span class="hljs-keyword">let</span> squareValue = square(<span class="hljs-number">2</span>)
<span class="hljs-built_in">console</span>.log(squareValue)

<span class="hljs-comment">// prints out 4 to the console</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">greet</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello, World"</span>);
}

<span class="hljs-keyword">let</span> greetValue = greet();
<span class="hljs-built_in">console</span>.log(greetValue);
<span class="hljs-comment">// return undefined</span>
</code></pre><p>I said earlier that functions can be declared with multiple parameters right so let us look at an example with an add function</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a, b</span>) </span>{
  <span class="hljs-keyword">return</span> a + b;
}

add(<span class="hljs-number">2</span>, <span class="hljs-number">5</span>);
<span class="hljs-comment">// 7</span>
</code></pre><p>If you declare a function with two-parameter and finally give it one, it will return the second parameter as undefined, alternative if you declare a function with one parameter and gives it more than one argument, it will use the first argument and ignore the rest</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a, b</span>) </span>{
  <span class="hljs-keyword">return</span> a + b;
}

add(<span class="hljs-number">2</span>, <span class="hljs-number">5</span>, <span class="hljs-number">7</span>, <span class="hljs-number">7</span>);<span class="hljs-comment">// 7</span>
</code></pre><h3 id="types-of-functions-in-javascript">Types of functions in JavaScript</h3>
<p>Apparently, we have been looking at different types of ways we can write a function above and we have been using one type which is defining a function with the function keywords but let us look at another way we can achieve the same result without the function keyword.</p>
<h4 id="arrow-function">Arrow function</h4>
<p>Arrow function was recently introduced in ES6, honestly, I don't see any major advantage of one over the other except for the fact that it deals with this problem when working with JavaScript classes (Classes will be discussed in a future article) but since it's at our disposal, we should also know how it is defined in case we want to use it anytime.</p>
<pre><code><span class="hljs-keyword">const</span> <span class="hljs-keyword">add</span> = (a, b) =&gt; a + b;
<span class="hljs-keyword">add</span>(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>);

<span class="hljs-comment">//prints 3</span>
</code></pre><p>First, we define our variable which will be the function name, and then the brackets that take in our parameters just like our normal function, and then the arrow before the return body. Don't confuse the arrow with the <code>&gt;</code> sign which means greater than. One good reason I prefer to use this function is that when my argument is one, I can omit the brackets for the parameter and also I don't have to include the return keyword.</p>
<pre><code><span class="hljs-keyword">const</span> addSelf = <span class="hljs-function">(<span class="hljs-params">a</span>) =&gt;</span> a + a;
addSelf(<span class="hljs-number">1</span>);

<span class="hljs-comment">//prints 2</span>
</code></pre><h4 id="iifes">IIFEs</h4>
<p>Immediately invoked functions as they are known is just a convenient way for us to define anonymous functions on the go. </p>
<p>Let me elucidate so you can understand what I mean. There are times you don't want to reuse a function and instead of declaring a function and keeping it in the namespace, you can just declare it and use it on the go. IIFEs gets called after it is declared.</p>
<p>let's see some example</p>
<pre><code><span class="hljs-keyword">const</span> person = <span class="hljs-function">(<span class="hljs-params">age</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (age &lt; <span class="hljs-number">21</span>) {
    (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"young"</span>);
    })();
  } <span class="hljs-keyword">else</span> {
    (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"old"</span>);
    })();
  }
  <span class="hljs-keyword">return</span> age;
};

person(<span class="hljs-number">30</span>);


<span class="hljs-comment">// old</span>
<span class="hljs-comment">//30</span>
</code></pre><h3 id="scoping-and-how-they-relate-to-functions">Scoping and how they relate to functions</h3>
<p>Now to be able to define useful functions that run without errors, you need to understand scoping and how they can affect the variables in your functions</p>
<p>They are two types of scoping in JavaScript and programming in general.</p>
<ul>
<li>Global scope</li>
<li>Local Scope</li>
</ul>
<p>All variables in the Global scope can be accessed in all parts of your program while those in your local scope can only be accessed in the scope in which they are defined.</p>
<pre><code><span class="hljs-keyword">let</span> a = <span class="hljs-number">10</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">scopeSample</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">let</span> b = <span class="hljs-number">20</span>;
  <span class="hljs-built_in">console</span>.log(a);
}

<span class="hljs-built_in">console</span>.log(b);
scopeSample();

<span class="hljs-comment">// b not visble in the global scope</span>
<span class="hljs-comment">// 10</span>
</code></pre><p>but when there is the same variable name in a different scope, the code will take the one in its innermost scope</p>
<pre><code><span class="hljs-keyword">let</span> a = <span class="hljs-number">10</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">scopeSample</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">let</span> b = <span class="hljs-number">20</span>;
  <span class="hljs-keyword">let</span> a = <span class="hljs-number">5</span>;
  <span class="hljs-built_in">console</span>.log(a);
}

<span class="hljs-built_in">console</span>.log(b);
scopeSample();
<span class="hljs-built_in">console</span>.log(a);

<span class="hljs-comment">// b not visble in the global scope</span>
<span class="hljs-comment">// 5</span>
<span class="hljs-comment">//10</span>
</code></pre><h3 id="conclusion">Conclusion</h3>
<p>By now you should understand what a function means, how useful they are, the different ways you can define them, and how you can prevent running into errors by scoping your variables the right way.</p>
<p>I can tell you that if you understood everything above, then you are on your way to becoming a better JavaScript developer and I am glad to be one of your guides through this journey.</p>
<p>Please I will appreciate your feedback and also topics you would like to write about. Also, share this article if you found it useful. See you soon.</p>
]]></content:encoded></item><item><title><![CDATA[Useful Array Methods every JavaScript developer should know and how to use them effectively.]]></title><description><![CDATA[As a developer, you work with data most of the time and it is your duty to understand how to structure that data and manipulate it when necessary. More…]]></description><link>https://techsharp.hashnode.dev/useful-array-methods-every-javascript-developer-should-know-and-how-to-use-them-effectively</link><guid isPermaLink="true">https://techsharp.hashnode.dev/useful-array-methods-every-javascript-developer-should-know-and-how-to-use-them-effectively</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[array]]></category><category><![CDATA[map]]></category><category><![CDATA[data structures]]></category><category><![CDATA[array methods]]></category><dc:creator><![CDATA[Nwobodo Ekene Leonard]]></dc:creator><pubDate>Sun, 15 Nov 2020 20:49:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1605450646923/ZhvJn6EtA.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As a developer, you work with data most of the time and it is your duty to understand how to structure that data and manipulate it when necessary. More also It is entirely dependent on you to choose the best and easy way possible to store and manipulate that data. </p>
<p>If you are a beginner and you don't understand what a data structure is and the types then click  <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures">here</a>  to get a quick intro to JavaScript data structure and types.</p>
<p>Now, this article is not focused on all the data structures and types that can be found in JavaScript. We will be looking at the array data structure and some of its most useful methods for manipulating it.</p>
<p>At the end of this article, you should already understand</p>
<ol>
<li>What a JavaScript array is</li>
<li>When to use an array</li>
<li>JavaScript array methods </li>
<li>How to manipulate an array using these methods</li>
</ol>
<h3 id="what-is-an-array">What is an Array</h3>
<p>If you have ever written a manual list of items (this could be a to-do list or a list of stuff you need to get in the shopping mall) before, then understanding what an array is should be easy for you.</p>
<p>An array is a list-like object with so many methods to perform traversal and mutation. Did you get it? haha, I don't think you did so let's make it easy.</p>
<p>Remember that above I described an array as your manual shopping list and it is inevitably logical that we should be able to take out or cancel what we don't want from our list and also be able to add more things to the list right? we can even remove our first item and replace it with another item if we intend to make our list sequential right.</p>
<p>Let us look at some examples to get the idea straight. </p>
<pre><code>How <span class="hljs-keyword">to</span> make a coffee
</code></pre><blockquote>
<ol>
<li>pour  hot water inside a cup</li>
<li>pour coffee inside the water</li>
<li>Stir for 3 second</li>
<li>coffee is ready for consumption</li>
</ol>
</blockquote>
<p>This is an example of how we write our manual list and we can decide we no longer want to stir our coffee and remove it or alternatively we may also decide we want to add milk to our coffee and therefore we go ahead and include it in our list.  </p>
<p>This is all made possible because we have a means of mutating or traversing our list. Now in JavaScript arrays, this superpower we have on our list is called a method and we have lots of them in JavaScript. </p>
<p>Before we look at the method available for us to use, let us understand when we need to use an array first.</p>
<h3 id="when-to-use-an-array">When to use an Array</h3>
<p>If you understood what an array is with our list example above, then understanding when to use one will be like understanding how to boil water on a gas cooker.</p>
<p>Working with unstructured data can be difficult. You will agree with me that knowing the best way possible to structure it and refer to it anytime you need it will go along way to help you as a developer and also help you work faster and be more productive. </p>
<p>Now let's say you want to store the names of five students in a class, we can approach it in two ways. One will make our code more readable and hasten our job while the second might make us lose our job sooner.</p>
<pre><code><span class="hljs-comment">// Names of the five students in a class</span>

<span class="hljs-keyword">let</span> student1 = <span class="hljs-string">'Jon'</span>
<span class="hljs-keyword">let</span> student2 = <span class="hljs-string">'Kay'</span>
<span class="hljs-keyword">let</span> student3 = <span class="hljs-string">'June'</span>
<span class="hljs-keyword">let</span> student4 = <span class="hljs-string">'Cally'</span>
<span class="hljs-keyword">let</span> student5 = <span class="hljs-string">'Amaka'</span>

<span class="hljs-built_in">console</span>.log(student1)
<span class="hljs-comment">// prints Jon to the console</span>
</code></pre><p>Now from the example above, let us say we want to print out all the names of the five students or probably mutate it. That would be one hell of a job and that will probably make you the worst developer to ever walk the earth. </p>
<p>Just to get the sense of what I mean look at the image below</p>
<pre><code><span class="hljs-comment">// Names of the five students in a class</span>

<span class="hljs-keyword">let</span> student1 = <span class="hljs-string">'Jon'</span>
<span class="hljs-keyword">let</span> student2 = <span class="hljs-string">'Kay'</span>
<span class="hljs-keyword">let</span> student3 = <span class="hljs-string">'June'</span>
<span class="hljs-keyword">let</span> student4 = <span class="hljs-string">'Cally'</span>
<span class="hljs-keyword">let</span> student5 = <span class="hljs-string">'Amaka'</span>

<span class="hljs-built_in">console</span>.log(student1)
<span class="hljs-built_in">console</span>.log(student2)
<span class="hljs-built_in">console</span>.log(student3)
<span class="hljs-built_in">console</span>.log(student4)
<span class="hljs-built_in">console</span>.log(student5)
<span class="hljs-comment">// prints Jon, Kay, June, Cally, Amaka to the console</span>
</code></pre><p>Now let us consider the second way which is the better way to store this kind of stuff</p>
<pre><code><span class="hljs-keyword">let</span> students = [<span class="hljs-string">'Jon'</span>,<span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Cally'</span>,<span class="hljs-string">'Amaka'</span>]
<span class="hljs-built_in">console</span>.log(students)
<span class="hljs-comment">// prints Jon, Kay, June, Cally, Amaka to the console</span>
</code></pre><p>Just with two lines of code and we achieved the same result effectively. Now, this is one of the use cases where you consider using arrays.</p>
<p>Remember that above, I spoke of some superpowers given to us by JavaScript to do somethings to our arrays right? These superpowers are referred to as array methods.</p>
<h3 id="javascript-array-methods">JavaScript array methods</h3>
<p>A method is simply a function that is a property of an object. in other words, methods allow us to get some information from objects. In our context arrays. </p>
<p>Just as we can easily tell the length of our manual list and also remove and add items to the list, we can also use array methods such as length (also be referred to as property), push and slice to perform similar operations on our array. </p>
<p>There are so many array methods to consider but since we won't be covering them in this post, you might as well get acquainted with them <a target="_blank" href="https://www.w3schools.com/jsref/jsref_obj_array.asp">here</a> </p>
<p>For this post, we will be considering ways we can do something to each item in our array separately using For Loop as well as some of the most popular methods introduced in ES6 such as Map and filter</p>
<h3 id="how-to-manipulate-arrays-with-these-methods">How to Manipulate Arrays with these methods</h3>
<p>When I started writing JavaScript, I was first introduced to For Loops as a way to iterate over things and I used this extensively on anything I wanted to iterate over, be it a string or an array, for me it was like the holy grail. 
But I later found a better and cleaner way to do some things without my almighty For Loop.</p>
<p>Let us look at a use case of using For Loop to add '!' to each name in our student array.</p>
<pre><code>Let studentNames = [<span class="hljs-string">'Jon'</span>, <span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Amaka'</span>,<span class="hljs-string">'Ebuka'</span>,<span class="hljs-string">'King'</span>]
<span class="hljs-keyword">for</span>(let i =<span class="hljs-number">0</span>; i&lt;studentNames.length; i++){
        studentNames[i] =+<span class="hljs-string">'!'</span>
}
 console.log(studentNames)
// [<span class="hljs-string">'Jon!'</span>, <span class="hljs-string">'Kay!'</span>,<span class="hljs-string">'Amaka!'</span>,<span class="hljs-string">'Ebuka!'</span>,<span class="hljs-string">'King!'</span>]
</code></pre><p>This looks pretty easy and straight forward. All we did was initialized a count </p>
<pre><code><span class="hljs-built_in">let</span> i = 0
</code></pre><p>we incremented 
<code>i</code></p>
<p>till it was the same length as our array, and for each increase in the value of <code>i</code> we used array indexing and added <code>!</code> to each element in our array but we can all agree that you need to remember a lot of steps and if we encounter the case of nested arrays in our array, then things can get a little bit complicated easily.</p>
<p>Let us look at another way can manipulate our data using the same example with another array method using our usual for loop</p>
<pre><code>let studentNames = [<span class="hljs-string">'Jon'</span>,<span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Amaka'</span>,<span class="hljs-string">'Ebere'</span>,<span class="hljs-string">'Ebuka'</span>, <span class="hljs-string">'king'</span>]

let newStudent = []
<span class="hljs-keyword">for</span> (<span class="hljs-type">name</span> <span class="hljs-keyword">of</span> studentNames){

    newStudent.push(<span class="hljs-type">name</span> + <span class="hljs-string">'!'</span>)
}

console.log(newStudent)
// [ <span class="hljs-string">'Jon!'</span>, <span class="hljs-string">'Kay!'</span>, <span class="hljs-string">'Amaka!'</span>, <span class="hljs-string">'Ebere!'</span>, <span class="hljs-string">'Ebuka!'</span>, <span class="hljs-string">'king!'</span> ]
</code></pre><p>This is easier to understand than our first example.
We started by initializing a variable <code>newStudent</code> that is an empty array and afterward iterated over our array, and for each item, in our array, we added <code>!</code> to it and finally used an array method <code>push</code> to add it to our newly created array.</p>
<p>When I started working with array I asked my friend who was a more experienced dev at the time if there was a way I could also keep track of the index of an item in an array while iterating over it and he replied in affirmation.
Let us look at it with an example for better clarification.</p>
<pre><code>let studentNames = [<span class="hljs-string">'Jon'</span>,<span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Amaka'</span>,<span class="hljs-string">'Ebere'</span>,<span class="hljs-string">'Ebuka'</span>, <span class="hljs-string">'king'</span>]

newStudent = []
<span class="hljs-keyword">for</span> (<span class="hljs-type">name</span> <span class="hljs-keyword">in</span> studentNames){
    console.log(<span class="hljs-type">name</span>, studentNames[<span class="hljs-type">name</span>])
    newStudent.push(studentNames[<span class="hljs-type">name</span>] +<span class="hljs-string">'!'</span>)
}
console.log(newStudent)

//
<span class="hljs-string">'0'</span> <span class="hljs-string">'Jon'</span>
<span class="hljs-string">'1'</span> <span class="hljs-string">'Kay'</span>
<span class="hljs-string">'2'</span> <span class="hljs-string">'Amaka'</span>
<span class="hljs-string">'3'</span> <span class="hljs-string">'Ebere'</span>
<span class="hljs-string">'4'</span> <span class="hljs-string">'Ebuka'</span>
<span class="hljs-string">'5'</span> <span class="hljs-string">'king'</span>

[ <span class="hljs-string">'Jon!'</span>, <span class="hljs-string">'Kay!'</span>, <span class="hljs-string">'Amaka!'</span>, <span class="hljs-string">'Ebere!'</span>, <span class="hljs-string">'Ebuka!'</span>, <span class="hljs-string">'king!'</span> ]
//
</code></pre><p>this is also a clear example and another you can iterate over an array while keeping track of the index. with this method, you can also traverse as well as mutate items in your array.</p>
<p>Before we look at the new way developers do it these days, let us look at one more method we could play with our array with a method known as forEach.</p>
<p>let also see some code samples</p>
<pre><code>newStudent = []
studentNames.<span class="hljs-keyword">forEach</span>(<span class="hljs-type">name</span> =&gt; {
    newStudent.push(<span class="hljs-type">name</span>+<span class="hljs-string">'!'</span>)
})

console.log(newStudent)

// [ <span class="hljs-string">'Jon!'</span>, <span class="hljs-string">'Kay!'</span>, <span class="hljs-string">'Amaka!'</span>, <span class="hljs-string">'Ebere!'</span>, <span class="hljs-string">'Ebuka!'</span>, <span class="hljs-string">'king!'</span> ]
</code></pre><p>forEach method is a very popular way to mutate or traverse over an array. This method takes in a callback function with a parameter that represents a single item in the array and then does something to that item.</p>
<p>It also comes with an additional parameter called index that helps you keep track of the index of your item while iterating over the array</p>
<pre><code>newStudent = []
studentNames.<span class="hljs-keyword">forEach</span>((<span class="hljs-type">name</span> ,<span class="hljs-keyword">index</span> ) =&gt; {
    newStudent.push(`<span class="hljs-keyword">index</span>: ${<span class="hljs-keyword">index</span>} <span class="hljs-type">name</span>: ${<span class="hljs-type">name</span> + <span class="hljs-string">'!'</span>}`)
})

console.log(newStudent)

// [
  <span class="hljs-string">'index: 0 name: Jon!'</span>,
  <span class="hljs-string">'index: 1 name: Kay!'</span>,
  <span class="hljs-string">'index: 2 name: Amaka!'</span>,
  <span class="hljs-string">'index: 3 name: Ebere!'</span>,
  <span class="hljs-string">'index: 4 name: Ebuka!'</span>,
  <span class="hljs-string">'index: 5 name: king!'</span>
]
</code></pre><p>I know you have come a long way getting to this last part of the article and you have taken in a whole lot that needs to be digested. Well, you should pat yourself on the back for getting this far. </p>
<p>Now let us look at the most useful of them. I personally use this method amongst others each time I plan to do something to each item in an array. With your understanding of other array methods, you will see this as a savior and an answer to all your array problems. </p>
<p>So if you are as impatient as me and want to dive right in with me, then let's do it. Yay!!</p>
<p>The array method Map is a holy grail and performs more optimal than the array methods we have seen so far. let us look at an example with the same data</p>
<pre><code>let studentNames = [<span class="hljs-string">'Jon'</span>,<span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Amaka'</span>,<span class="hljs-string">'Ebere'</span>,<span class="hljs-string">'Ebuka'</span>, <span class="hljs-string">'king'</span>]
newStudent = studentNames.map(studentName =&gt;studentName + <span class="hljs-string">'!)

console.log(newStudent)

// ['</span>Jon!<span class="hljs-string">','</span>Kay!<span class="hljs-string">','</span>Amaka!<span class="hljs-string">','</span>Ebere!<span class="hljs-string">','</span>Ebuka!<span class="hljs-string">', '</span>king!<span class="hljs-string">']</span>
</code></pre><p>Looking at the above code you can agree with me that this second code is more readable and easy to write than the first.</p>
<p>What we did with the code above is we mapped over the array and for each item, in the array, we did something, which is adding <code>!</code> to the end of each item. We can achieve more with this method but for the purpose of this post, we will use only the example above.</p>
<p>The map method also comes with an index parameter built-in just like we saw in our forEach method example.</p>
<p>The unique advantage of using the Map method is that unlike the other examples that are hardcoded, the map returns a new array which can be saved separated in another variable as you can see in the code snippet above, thanks to ES6 new syntaxes.</p>
<p>From the beginning of this article, we have been talking about how we can change our array or traverse over it. </p>
<p>What if there was a way we can conditionally return some part of our array instead of returning all of them or doing something to some of the items that passed specific conditions only, it will be great right?</p>
<p>Let's say we want to only add <code>!</code> to the student names that only includes the letter <code>K</code> how can we achieve this? we could start by using one of our array methods and only add <code>!</code> to an item that contains <code>k</code> and that will work for sure. But how efficient and optimal is that. I can tell you for a fact that for a small program it will run very fast, but as your program gets larger, the runtime increases.</p>
<p>Well, there is a built-in array method that can perform this task for us optimally and also abstracts away a lot of complexities.</p>
<p>Introducing to you the almighty <strong>filter method </strong> the holy sibling to the <strong> map method </strong>. Haha! that's just me being playful again</p>
<p>let us look at some example by solving the task above</p>
<pre><code><span class="hljs-keyword">let</span> studentNames = [<span class="hljs-string">'Jon'</span>,<span class="hljs-string">'Kay'</span>,<span class="hljs-string">'Amaka'</span>,<span class="hljs-string">'Ebere'</span>,<span class="hljs-string">'Ebuka'</span>, <span class="hljs-string">'king'</span>]
filteredStudent = studentNames.filter(<span class="hljs-function"><span class="hljs-params">studentName</span> =&gt;</span> studentName.toLowerCase().includes(<span class="hljs-string">'k'</span>)).map(<span class="hljs-function"><span class="hljs-params">studentName</span> =&gt;</span> studentName + <span class="hljs-string">'!'</span>)

<span class="hljs-built_in">console</span>.log(filteredStudent)

<span class="hljs-comment">// [ 'Kay!', 'Amaka!', 'Ebuka!', 'king!' ]</span>
</code></pre><p>Wow, I am always amazed by the wonders these two methods can do. We simply filtered our array with the filter method and returned only the items in our array that has the letter <code>k</code> and then mapped over each item with the map method and added <code>!</code> to each. </p>
<p>You should note that this example above are just a mere introduction to these methods because they can really be used to achieve a lot more than what I have just shown above. Some of them can be used as a Higher other function (HOC), but we will discuss that in another article after this one.</p>
<h3 id="conclusion">Conclusion:</h3>
<p>Now that you understand what an array is, how it is used, and how it can be manipulated and mutated, working with arrays will become easier for you.</p>
<p>You shouldn't stop here though, make more research, Google as much as you can and soon you will become a better JavaScript developer who writes clean and readable code.
See you again soon</p>
]]></content:encoded></item></channel></rss>