<?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[WebDevNote.io]]></title><description><![CDATA[WebDevNote.io]]></description><link>https://webdevnote.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 06:23:20 GMT</lastBuildDate><atom:link href="https://webdevnote.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding Break VS Continue in For loop.]]></title><description><![CDATA[These are concepts in JavaScript that can be easily intertwined. Just like anything I have written about in the past, you don't have to have it stick to…]]></description><link>https://webdevnote.hashnode.dev/understanding-break-vs-continue-in-for-loop</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/understanding-break-vs-continue-in-for-loop</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Tue, 01 Mar 2022 20:27:59 GMT</pubDate><content:encoded><![CDATA[<p>These are concepts in JavaScript that can be easily intertwined. Just like anything I have written about in the past, you don't have to have it stick to your head, you however just need to be able to differentiate the differences, and use cases, then when the need arise to use it in your code, you have Google or your notepad or references like this page to give a refresher on the topics so you're not stuck or confused in your code.</p>
<p>Here's an example and use case for Continue;</p>
<p>I want to print to the console output of even numbers from 0 to 30, but I want to ensure the numbers divisible by 5 or 12 are "skipped", here's how I would use the continue syntax.</p>
<pre><code><span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> <span class="hljs-number">30</span>; i <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-number">2</span> ){
    <span class="hljs-keyword">if</span>(i <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">11</span> <span class="hljs-operator">|</span><span class="hljs-operator">|</span> i <span class="hljs-operator">%</span> <span class="hljs-number">5</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>){
        <span class="hljs-keyword">continue</span>;
    }
    console.log(i)
}

<span class="hljs-comment">//Output would be 2 through 28, but it would "skip" the number 12</span>
<span class="hljs-comment">// and any other number divisible by 5. </span>
<span class="hljs-comment">// Think of Continue as "skip" the presently set condition but complete the loop.</span>
</code></pre><p>Break on the other hand would "break" or end the loop once the set condition is met.</p>
<p>example;
I want to print to the console output of odd numbers from 0 to 30, but I want to ensure that once I reach the number 7, I want to end the loop. Here's how I would use the break syntax.</p>
<pre><code><span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> <span class="hljs-number">30</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span> ){
    <span class="hljs-keyword">if</span>(i <span class="hljs-operator">%</span> <span class="hljs-number">2</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>){
         <span class="hljs-keyword">continue</span>;
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(i <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">7</span>){
        console.log(i); <span class="hljs-comment">//Comment out this line to see the result.</span>
        <span class="hljs-keyword">break</span>;
    }
    console.log(i)
}

<span class="hljs-comment">//Output would be 1, 3, 5, and 7.</span>
</code></pre><p>Like and share if you learned something today. Learn JavaScript one topic every day.</p>
]]></content:encoded></item><item><title><![CDATA[GIT Common WorkFlow for the everyday developer.]]></title><description><![CDATA[General Procedures for Git for everyday use for Software Developers; It’s always a good practice to create a branch for the desired feature. Whenever you…]]></description><link>https://webdevnote.hashnode.dev/git-common-workflow-for-the-everyday-developer</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/git-common-workflow-for-the-everyday-developer</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[code]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Tue, 02 Feb 2021 22:57:06 GMT</pubDate><content:encoded><![CDATA[<p>General Procedures for Git for everyday use for Software Developers;</p>
<ol>
<li>git branch nameOfTheChanges: This would create a new branch with the name “nameOfTheChanges”. The nameOfTheChanges in this context would refer to the name that’s closely related to the changes you want to make in your code. This helps to keep the version control organized both locally and on the Server, like on GitHub.</li>
<li>git checkout nameOfTheChanges: This would make you switch to the branch you created for the purpose of the changes prior to starting to work on the changes. (Now you can head over to make the changes to your code as required and in line with the proposed branch).</li>
<li>git add . or git add *: to add all the changes you’ve made to the branch. This would make a record not only on your local machine like it has already been before, but this time, on the staging area.</li>
<li>git commit -m “A One line Note on Your Changes specific to the branch”: This would help you commit the branch and this time, it is now served and prepared to be pushed to the master origin.(Server).</li>
<li>git status: This helps you know the status of your file version controls both locally and internationally.</li>
<li>git pull origin master: This helps to ensure you pull in the most current changes before pushing the changes you have made yourself locally. A lot of developers who’s never really worked in a team of developers often forget this option because they are used to working alone. It’s a crucial step that helps to ensure that you don’t just push changes to the server that you haven’t registered and merged with the current files you have running locally on your machine.</li>
<li>git push -u origin nameOfTheChanges: This would push the committed changes from the branch that’s just been worked on to the remote repository.</li>
<li>git checkout master: Now that all the necessary previous steps have been taking, it’s time to switch to our master branch.</li>
<li>REPEAT the pull process::: git pull origin master:  to ensure every change that’s made without our notice is pulled, and that our working directory is current with what’s on the Server.</li>
<li>git merge nameOfTheChanges: This would merge the branch we have worked on and add this to the master.</li>
<li>git push origin master: This would now push all the changes and everything would be as organized as possible.</li>
<li>git branch -d nameOfTheChanges: This would delete the branch locally. You can do this if the branch is not needed anymore after it has been merged with the master branch on the remote repository.</li>
<li>git push origin -d nameOfTheChanges: This would delete the branch on the remote repository, and help you keep things cleaned out and well structured and organized.</li>
</ol>
<p>It’s always a good practice to create a branch for the desired feature. Whenever you have a new feature or function to add to your code, create a branch for it in Git before embarking on the changes, This is a process of many seasoned developers, and you too can become one by applying best practices.</p>
<p>Other Useful Git Syntax:</p>
<ol>
<li>git diff: This helps you see the differences you’ve made in a snapshot on your git CLI just so, you can see the changes.</li>
<li>git branch or git branch -a: This would generate the list of the branches you have locally on your system.</li>
<li>git branch —merged: This would list all the merged branches. If you don’t find your branch listed here, this means you haven't merged it yet.</li>
<li>Fill in the missing space in the comment section below if I left any that's also really frequently used.</li>
</ol>
<p>Don’t forget to Pull, before your Merge, and then Push. With this workflow, you would always be concise and always never ruin things on the remote repo.</p>
<p>Good luck and keep coding.</p>
]]></content:encoded></item><item><title><![CDATA[Destructuring Array, Objects, and Function Params in JavaScript]]></title><description><![CDATA[Destructing is a method of extracting some data from an Array, Object or function Parameters Below is an example of how an Array can be destructured. By…]]></description><link>https://webdevnote.hashnode.dev/destructuring-array-objects-and-function-params-in-javascript</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/destructuring-array-objects-and-function-params-in-javascript</guid><category><![CDATA[#codenewbies]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[basics]]></category><category><![CDATA[learn coding]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Fri, 29 Jan 2021 02:42:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611888115799/5jFjz6Uo2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Destructing is a method of extracting some data from an Array, Object or function Parameters 
Below is an example of how an Array can be destructured.</p>
<pre><code><span class="hljs-keyword">const</span> names = [<span class="hljs-string">'Victor'</span>, <span class="hljs-string">'Jade'</span>, <span class="hljs-string">'Edidiong'</span>, <span class="hljs-string">'Tina'</span>];
</code></pre><p>By design, we know that each element of an array has an index identifier starting from 0 to the end of the array. Arrays are also ordered list of element, so the order matters also while destructuring.</p>
<pre><code>const [Winner, second, ...everyoneElse] = names;

// if we <span class="hljs-keyword">call</span> the <span class="hljs-keyword">variable</span> Winner, it stores the <span class="hljs-keyword">first</span> <span class="hljs-keyword">element</span> <span class="hljs-keyword">of</span> the <span class="hljs-built_in">array</span> <span class="hljs-string">'Victor'</span>.
// Winner
// <span class="hljs-keyword">OutPut</span>: <span class="hljs-string">"Victor"</span>
// <span class="hljs-keyword">second</span>
// <span class="hljs-keyword">OutPut</span>: <span class="hljs-string">"Jade"</span>
// everyoneElse
// <span class="hljs-keyword">OutPut</span>: [<span class="hljs-string">"Edidiong"</span>, <span class="hljs-string">"Tina"</span>]
</code></pre><p>The names Array is not tampered with in any way, we have only created a list of variables for the elements found in the names Array.</p>
<p>As seen in the code above, we used the Rest operator (...everyoneElse) to categorize the remaining elements in the name array.
This makes us get the remaining elements as a new array in the variable name everyoneElse.</p>
<p>Destructuring of Arrays isn't really common in programming, what's more, common is destructuring of Objects.</p>
<p>Below we would learn how to destructure an Object and its common use.</p>
<pre><code><span class="hljs-string">const</span> <span class="hljs-string">subjectScores</span> <span class="hljs-string">=</span> {
    <span class="hljs-attr">english:</span> <span class="hljs-number">98</span>,
    <span class="hljs-attr">math:</span> <span class="hljs-number">90</span>,
    <span class="hljs-attr">socialStudies:</span> <span class="hljs-number">95</span>,
    <span class="hljs-attr">elective:</span> <span class="hljs-number">60</span>
}<span class="hljs-string">;</span>
</code></pre><p>If we had to access each element before, we would do the following;</p>
<pre><code>const english = subjectScores.english;

// Now <span class="hljs-keyword">if</span> we <span class="hljs-keyword">called</span> english, would <span class="hljs-keyword">get</span> <span class="hljs-number">98.</span>
</code></pre><p>If we had way more data to pull out and use for a specific purpose, it would be crazy to have to repeat this pattern, for this sake, we can use destructuring.</p>
<pre><code><span class="hljs-keyword">const</span> {math, elective, ...allOthers } = subjectScores;
</code></pre><p>just like we did with arrays, it's easy to also destructure an Object, and the same would apply this case.</p>
<p>How do we rename any of the key in the subjectScores Object?</p>
<p>To do this, find the key that we want to rename and then, assign a new name to it. This would nake the previous name unusable.</p>
<pre><code><span class="hljs-keyword">const</span> {elective: electiveStudies, english} = subjectScores;
</code></pre><p>Now that we have renamed the key "elective" to "electiveStudies", if we call elective, we would get the following error "Uncaught ReferenceError: elective is not defined".</p>
<p>But if we call english, we would still get the output 98, and if we call the new name electiveStudies, OutPut: 60.</p>
<p>Another very common use case is to use default params with Destructuring.</p>
<pre><code>const arry = {
    // <span class="hljs-type">name</span>: <span class="hljs-string">'James'</span>,
    occupation: <span class="hljs-string">'Programmer'</span>,
    bankSum: <span class="hljs-number">700</span>,
    taxPaid(num){
        <span class="hljs-keyword">return</span> <span class="hljs-number">700</span> * num / <span class="hljs-number">100</span>;
    },

};
// <span class="hljs-keyword">If</span> we <span class="hljs-keyword">called</span> arry.name we would <span class="hljs-keyword">get</span> <span class="hljs-string">'James'</span>
</code></pre><p>But if we destructure like we did below and assigned a default Param to name like seen below;</p>
<pre><code>const {<span class="hljs-type">name</span>: named = <span class="hljs-string">'Goblin'</span> } = arry;
</code></pre><p>The name still remains 'James' because we have it assigned already in the array and that takes precedence. </p>
<p>But If we remove the name Property and then destructure again with the same example, we will access the property using the new name property.</p>
<p>Example;</p>
<pre><code><span class="hljs-keyword">const</span> arrys = {
    <span class="hljs-attr">occupation</span>: <span class="hljs-string">'Programmer'</span>,
    <span class="hljs-attr">bankSum</span>: <span class="hljs-number">700</span>,
    taxPaid(num){
        <span class="hljs-keyword">return</span> <span class="hljs-number">700</span> * num / <span class="hljs-number">100</span>;
    },

};

<span class="hljs-keyword">const</span> {<span class="hljs-attr">name</span>: namedd = <span class="hljs-string">'Shawl'</span> } = arrys;

<span class="hljs-keyword">const</span> fullName = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">{occupation, bankSum}</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">`<span class="hljs-subst">${occupation}</span>, <span class="hljs-subst">${bankSum}</span>`</span>;
};
</code></pre><p>Now, namedd will OutPut 'Shawl' as expected.</p>
<p>Destructuring Params in Functions</p>
<p>Let's create an Object for example;</p>
<pre><code><span class="hljs-string">const</span> <span class="hljs-string">users</span> <span class="hljs-string">=</span> {
    <span class="hljs-attr">name:</span> <span class="hljs-string">'Victor'</span>,
    <span class="hljs-attr">isAdmin:</span> <span class="hljs-literal">false</span>,
    <span class="hljs-attr">email:</span> <span class="hljs-string">'myEmail@gmail.com'</span>,
    <span class="hljs-attr">dob:</span> <span class="hljs-string">'20/01,1901'</span>,
    <span class="hljs-attr">ethnicity:</span> <span class="hljs-string">'Black'</span>
}<span class="hljs-string">;</span>
</code></pre><p>Now, we would create a Function that takes in the arguments or properties of the Object Above.</p>
<pre><code><span class="hljs-keyword">const</span> callUsersDet = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">{email, dob, isAdmin}</span>)</span>{
<span class="hljs-keyword">return</span> <span class="hljs-string">`Users email is: <span class="hljs-subst">${email}</span>, born on the: <span class="hljs-subst">${dob}</span>, and is Admin privilege is <span class="hljs-subst">${isAdmin}</span>.`</span>;
};
</code></pre><p>Whenever we call the callUsersDetails function, it is expecting us to pass in Object that has all these properties that are housed in the users Object, to do this, we would say; callUsersDetails(users);</p>
<p>This would call return the following output; 
"Users email is: myEmail@gmail.com, born on the: 20/01,1901, and is Admin privilege is false."</p>
<p>I hope this helps clarify what is going on.</p>
<p>Destructuring really is very simple if understood its use cases, I hope I've been able to clarify a little about the Topic.</p>
<p>If you found this write up helpful, pls share it with any friend learning JavaScript Basics to help them also get ahead.</p>
<p>Share, like, and follow for more exciting writeups.</p>
]]></content:encoded></item><item><title><![CDATA[Default Params in JavaScript]]></title><description><![CDATA[Default Params (Parameter for short) are arguments or parameters that have been assigned a default value, either to avoid NaN, null or undefined. Example…]]></description><link>https://webdevnote.hashnode.dev/default-params-in-javascript</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/default-params-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[code]]></category><category><![CDATA[best practices]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Mon, 25 Jan 2021 22:20:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611613238942/FAkq848h3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Default Params (Parameter for short) are arguments or parameters that have been assigned a default value, either to avoid NaN, null or undefined.</p>
<p>Example, We would create a rollDie function that would by default accept a num;</p>
<p>Each time the number is called, the function would produce a range of numbers from the number entered to 1;</p>
<pre><code><span class="hljs-keyword">const</span> rollDie = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">num</span>)</span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * num ) + <span class="hljs-number">1</span>;
};

rollDie(<span class="hljs-number">5</span>); <span class="hljs-comment">// This would produce numbers from 1 to 5 randomly.</span>
</code></pre><p>One problem however is that each time we call rollDie() without a number, it would return NaN, which means, Not a Number.</p>
<p>To eliminate this, default Param would do the trick for us.</p>
<p>Example;</p>
<pre><code><span class="hljs-keyword">const</span> rollDie2 = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">num = <span class="hljs-number">6</span></span>)</span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * num ) + <span class="hljs-number">1</span>;
};
</code></pre><p>This way, when rollDie2() is called, without any argument, it would return random numbers between 1 and 6, because 6 has been assigned as the default parameter.</p>
<p>The Default Param also works in left to right precedence. 
This means that when there are two parameters and only one is defined, 
it has to be at the edge of the closing bracket to the right. </p>
<p>Example;</p>
<pre><code>const rollDie3 = <span class="hljs-keyword">function</span>(num2, num = <span class="hljs-number">6</span>){
    console.log(`Num <span class="hljs-number">2</span>: ${num2 * <span class="hljs-number">2</span>} <span class="hljs-keyword">is</span> the number <span class="hljs-keyword">without</span> <span class="hljs-keyword">default</span> Param, <span class="hljs-keyword">while</span> Num: ${num} <span class="hljs-keyword">is</span> the number <span class="hljs-keyword">with</span> Param`);
    // <span class="hljs-keyword">return</span> Math.floor(Math.random() * num ) + <span class="hljs-number">1</span>;
};
</code></pre><p>Ex 1: When rollDie3() is called without any argument, it would print the following
OUTPUT: Num 2: NaN is the number without default Param, while Num: 6 is the number with Param</p>
<p>Ex 2: When rollDie3(20) is called with only one argument, it would print the following
OUTPUT: Num 2: 6 is the number without default Param, while Num: 6 is the number with Param</p>
<p>As seen in Ex 2: because only one parameter was passed, 
the default param takes precedence and is output in place of the empty param</p>
<p>Ex 3: When rollDie3(3,9) is called with two arguments as expected, it would print the following
OUTPUT: Num 2: 6 is the number without default Param, while Num: 9 is the number with Param</p>
<p>As seen in Ex 3: even with two parameters passed as expected, 
the default param takes precedence and is output first before the param without default params.</p>
<p>If we switch places of the arguments as followed</p>
<pre><code>const rollDie4 = <span class="hljs-keyword">function</span>(num2, num = <span class="hljs-number">6</span>){
    console.log(`Num <span class="hljs-number">2</span>: ${num * <span class="hljs-number">2</span>} <span class="hljs-keyword">is</span> the number <span class="hljs-keyword">without</span> <span class="hljs-keyword">default</span> Param, <span class="hljs-keyword">while</span> Num: ${num2} <span class="hljs-keyword">is</span> the number <span class="hljs-keyword">with</span> Param`);
};
</code></pre><p>If we call the function rollDie4(), we would get the following Output;
OUTPUT: Num 2: 12 is the number without default Param, while Num: undefined is the number with Param</p>
<p>If we call the function rollDie4(3), with one parameter, we would get the following Output;
OUTPUT: Num 2: 12 is the number without default Param, while Num: 3 is the number with Param</p>
<p>But if we call the function rollDie4(3, 20), with two parameters as expected, we would get the following Output;
OUTPUT: Num 2: 40 is the number without default Param, while Num: 3 is the number with Param</p>
<p>Default Params are quite easy to grasp, so play with it and try to eliminate those null, NaN, or undefined returns of value, if possible, assigned a value by default, and remain happy.</p>
<p>Happy Coding, Hope this clarifies the Topic Default Param;</p>
]]></content:encoded></item><item><title><![CDATA[Reduce callback function in JavaScript]]></title><description><![CDATA[Reduce is a very vast and powerful callback function that can be used for array in many different ways. Hope this helps.]]></description><link>https://webdevnote.hashnode.dev/reduce-callback-function-in-javascript</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/reduce-callback-function-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[code]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Mon, 25 Jan 2021 13:50:04 GMT</pubDate><content:encoded><![CDATA[<p>Reduce is a very vast and powerful callback function that can be used for array in many different ways.</p>
<pre><code><span class="hljs-keyword">const</span> pep = [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">7</span>,<span class="hljs-number">8</span>];

<span class="hljs-keyword">const</span> sums = pep.reduce((ini, curr) =&gt; ini + curr);


<span class="hljs-comment">// The variable sums now hold the total from the reduce callback function of the value 35.</span>

<span class="hljs-comment">// Here's an assignment someone posted on Slack sometime ago and was asking a way to solve the challenge</span>

<span class="hljs-comment">/**
* <span class="hljs-doctag">@tutorial</span> https://www.codewars.com/kata/5715eaedb436cf5606000381/train/javascript
* <span class="hljs-doctag">@description</span> - You get an array of numbers, return the sum of all of the positives ones.
* <span class="hljs-doctag">@function</span> positiveSum
* <span class="hljs-doctag">@param</span> {array} arr - an array of numbers
* <span class="hljs-doctag">@returns</span> {integer} - the sum of all the positive numbers
*/</span>

<span class="hljs-comment">// There are many ways to solve the problem, </span>
<span class="hljs-comment">// but we would see how the reduce callback function makes it really simple to work with.</span>

<span class="hljs-comment">// Here's one way to solve it.</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">positiveSum</span>(<span class="hljs-params">arr</span>)</span>{
    let total = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span>(let i of arr){
        <span class="hljs-keyword">if</span> (i &gt; <span class="hljs-number">0</span>){
            total += i;
        }
    }
    <span class="hljs-keyword">return</span> total;
}

<span class="hljs-comment">// This would return the total in the array and sum them.</span>

<span class="hljs-comment">//With Reduce, it is much simpler and easy to work with.</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">positiveSum</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">return</span> arr.reduce((prevNum, currNum) =&gt; prevNum + currNum);
}

<span class="hljs-comment">// Reduce can be used to do a whole lot more than just sum all numbers in an array.</span>
</code></pre><p>Hope this helps.</p>
]]></content:encoded></item><item><title><![CDATA[Defining JavaScript Methods]]></title><description><![CDATA[JavaScript Methods are simply functions used as properties within an Object. Here's an example; We have written the functions using the shorthand style We…]]></description><link>https://webdevnote.hashnode.dev/defining-javascript-methods</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/defining-javascript-methods</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[learn coding]]></category><category><![CDATA[Objects]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Sat, 23 Jan 2021 15:14:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611414871869/jJkd_r4f5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>JavaScript Methods are simply functions used as properties within an Object.</p>
<p>Here's an example;</p>
<pre><code><span class="hljs-keyword">const</span> calcObject = {
    add(<span class="hljs-built_in">num</span>,num2){
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">num</span> + num2
    },
    sub(<span class="hljs-built_in">num</span>,num2){
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">num</span> - num2
    },
    squ(<span class="hljs-built_in">num</span>){
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">num</span> * <span class="hljs-built_in">num</span>
    },
    div(<span class="hljs-built_in">num</span>, num2){
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">num</span> / num2
    }
}
<span class="hljs-comment">// OUTPUTS examples</span>

calcObject.add(<span class="hljs-number">8</span>,<span class="hljs-number">9</span>)
<span class="hljs-number">17</span>
calcObject.sub(<span class="hljs-number">18</span>,<span class="hljs-number">9</span>)
<span class="hljs-number">9</span>
calcObject.squ(<span class="hljs-number">4</span>)
<span class="hljs-number">16</span>
calcObject.div(<span class="hljs-number">14</span>,<span class="hljs-number">2</span>)
<span class="hljs-number">7</span>
</code></pre><p>We have written the functions using the shorthand style</p>
<p>We could also write it like this;</p>
<pre><code><span class="hljs-keyword">const</span> calcObject = {
    add: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">num,num2</span>)</span>{
        <span class="hljs-keyword">return</span> num + num2
    },
    sub: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">num,num2</span>)</span>{
        <span class="hljs-keyword">return</span> num - num2
    },
    squ: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">num</span>)</span>{
        <span class="hljs-keyword">return</span> num * num
    },
    div: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">num, num2</span>)</span>{
        <span class="hljs-keyword">return</span> num / num2
    }
}

<span class="hljs-comment">//OUTPUT will be the same as the previous code, if called with the same parameters in the example.</span>
calcObject.add(<span class="hljs-number">8</span>,<span class="hljs-number">9</span>)
<span class="hljs-number">17</span>
calcObject.sub(<span class="hljs-number">18</span>,<span class="hljs-number">9</span>)
<span class="hljs-number">9</span>
calcObject.squ(<span class="hljs-number">4</span>)
<span class="hljs-number">16</span>
calcObject.div(<span class="hljs-number">14</span>,<span class="hljs-number">2</span>)
<span class="hljs-number">7</span>
</code></pre><p>This is method in JavaScript.</p>
<p>It's very simple. You learn to swim by watching people swim and most importantly, trying it out yourself, you learn to code by practicing coding also. Goodluck.</p>
]]></content:encoded></item><item><title><![CDATA[Are JavaScript Objects Iterable?]]></title><description><![CDATA[The answer to this is yes, it is possible to iterate Objects, but Objects are generally non-iterable by fashion. Side Note: Technology continues to evolve…]]></description><link>https://webdevnote.hashnode.dev/are-javascript-objects-iterable</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/are-javascript-objects-iterable</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Objects]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[code]]></category><category><![CDATA[code review]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Thu, 21 Jan 2021 16:48:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611247679463/stFPGZ7ZJ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The answer to this is yes, it is possible to iterate Objects, but Objects are generally non-iterable by fashion.</p>
<p>Side Note: Technology continues to evolve and things get improved over time. JavaScript has evolved over the years and trying to keep up can be hard, but the basics are really what matters, and staying unformed help us get ahead.</p>
<p>Definining an object, we use the mustache or the curly brackets {//Properties of the Object goes in here..} e.g:</p>
<pre><code><span class="hljs-keyword">const</span> class5 = {
    className: <span class="hljs-string">"Class 5"</span>,
    ageGroup: <span class="hljs-string">"5 to 10"</span>,
    color: <span class="hljs-string">"green"</span>,
    breakfast: <span class="hljs-literal">true</span>,
    lunch: <span class="hljs-literal">false</span>,
    dinner: <span class="hljs-literal">false</span>,
};

<span class="hljs-comment">// The above Object serves as a container for the student Object.</span>

<span class="hljs-comment">// Using the ES6 "For of" statement</span>

<span class="hljs-comment">// If you run the code below, you would get an error;</span>

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> student <span class="hljs-keyword">of</span> class5){
    Do something...
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`All students in <span class="hljs-subst">${class5.className}</span> are of the agegroup of <span class="hljs-subst">${class5.ageGroup}</span>`</span>);
}

<span class="hljs-comment">// The "for of" code gives you the following error </span>
<span class="hljs-comment">//  "Uncaught TypeError: class5 is not iterable at ..."</span>
</code></pre><p>As correct as the code may seem, 
    it just won't work because an Object is non-iterable.</p>
<p> /<em>  To make this work, we must either find a way to make an array from the Object using the "for in" loop or use the special Object.values() or Object.keys() method to be able to work with the Object data.
</em>/</p>
<pre><code><span class="hljs-comment">// Using the for in method to loop through.</span>

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> student <span class="hljs-keyword">in</span> class5){
    <span class="hljs-comment">// Do something...</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`All Class 5 have the following: \n<span class="hljs-subst">${student}</span> = <span class="hljs-subst">${class5[student]}</span>`</span>);
    <span class="hljs-comment">// console.log(`All students in ${class5.className} are of the agegroup of ${class5.ageGroup}`);</span>
}
</code></pre><p>The "for in" loop code would run 6 times 
    because we have 6 object elements and we are console.logging with the "for in" syntax.
    We are referencing the values of the object with the .notation which would then reference the value of the key called.</p>
<p>The Second method would be to use the Object.value(Objectname) or Object.keys(Objectname) syntax.
    The following can be used...</p>
<ul>
<li><p>Object.values() =&gt; returns the value into a new array.</p>
</li>
<li><p>Object.keys() =&gt; returns the keys into a new array.</p>
</li>
<li><p>Object.entries() =&gt; returns the keys and values into individual arrays.</p>
</li>
</ul>
<pre><code><span class="hljs-keyword">for</span> (let eachStudent <span class="hljs-keyword">in</span> class5){
    console.log(`<span class="hljs-keyword">Class</span> <span class="hljs-number">5</span> has the <span class="hljs-keyword">following</span> Keys: ${<span class="hljs-keyword">Object</span>.keys(class5[eachStudent])}`);
    console.log(`<span class="hljs-keyword">Class</span> <span class="hljs-number">5</span> has the <span class="hljs-keyword">following</span> <span class="hljs-keyword">Values</span>: ${<span class="hljs-keyword">Object</span>.<span class="hljs-keyword">values</span>(class5)}`);
}
</code></pre><p>The code above would run the console.log command 6 times each, 
    making a total of 12. </p>
<p>Now that we have made an array of the Object using the Object method, we can now perform logic on the data the way we would normally do like when accessing an array.</p>
<pre><code><span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>;
<span class="hljs-keyword">let</span> ourClass = <span class="hljs-built_in">Object</span>.values(class5);
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> eachP <span class="hljs-keyword">of</span> ourClass) {
    count++;
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`This is line <span class="hljs-subst">${count}</span> and the length of our class Object now is <span class="hljs-subst">${ourClass.length}</span>`</span>);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${eachP}</span>`</span>);
}
</code></pre><p>This is all there is to Objects in JavaScript, or at least, the very basics.</p>
<p>Learning to program is not magical, you make the experience magical when you accept that you offcourse can remember everything, nor know everything, but you can at least, understand how things work and can explain what a code does to a 10 years old and help them understand the concepts. That's where the magic starts and it intensifies when it's been practiced until everything then seems magical.</p>
<p>Like, share, Upvote, and give your honest feedback to help me create better content for you.</p>
<p>You can also support me as a developer so I can spend more quality time providing you with awesome content that would help you become a better developer.</p>
<p>You can now buy me a coffee: buymeacoffee.com/WebtekMasters</p>
]]></content:encoded></item><item><title><![CDATA[Some & Every Method in JavaScript.]]></title><description><![CDATA[Some & Every is a type of method that returns a Boolean value and allows to work on an Array. Some respond to one or more properties of an Array while the…]]></description><link>https://webdevnote.hashnode.dev/some-and-every-method-in-javascript</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/some-and-every-method-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[array methods]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[array]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Mon, 18 Jan 2021 14:35:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610980541709/r4FetS-uB.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Some &amp; Every is a type of method that returns a Boolean value and allows to work on an Array.</p>
<p>Some respond to one or more properties of an Array while the Every responds to all properties of an Array.</p>
<p>Example.</p>
<pre><code><span class="hljs-keyword">const</span> students = [
    {
        name: <span class="hljs-string">"Victor"</span>,
        <span class="hljs-keyword">class</span>: <span class="hljs-number">5</span>,
        subjects: [<span class="hljs-string">"Math"</span>, <span class="hljs-string">"English"</span>, <span class="hljs-string">"Science"</span>],
        pass: <span class="hljs-literal">true</span>
    },
    {
        name: <span class="hljs-string">"Segun"</span>,
        <span class="hljs-keyword">class</span>: <span class="hljs-number">9</span>,
        subjects: [<span class="hljs-string">"Chemistry"</span>, <span class="hljs-string">"Math"</span>, <span class="hljs-string">"Computer Studies"</span>],
        pass: <span class="hljs-literal">false</span>
    },
    {
        name: <span class="hljs-string">"Faith"</span>,
        <span class="hljs-keyword">class</span>: <span class="hljs-number">3</span>,
        subjects: [<span class="hljs-string">"Social Studies"</span>, <span class="hljs-string">"Medicine"</span>, <span class="hljs-string">"CRK"</span>],
        pass: <span class="hljs-literal">true</span>
    },
    {
        name: <span class="hljs-string">"Tracy"</span>,
        <span class="hljs-keyword">class</span>: <span class="hljs-number">5</span>,
        subjects: [<span class="hljs-string">"Biology"</span>, <span class="hljs-string">"Agriculture"</span>, <span class="hljs-string">"Literature"</span>],
        pass: <span class="hljs-literal">false</span>
    }

];

<span class="hljs-comment">// We have defined an array above</span>


<span class="hljs-keyword">const</span> subjectTaken = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
    <span class="hljs-keyword">return</span> students.every(<span class="hljs-function"><span class="hljs-params">eStudents</span> =&gt;</span> eStudents.subjects);
};

subjectTaken(); <span class="hljs-comment">//Output would return "true" because every students took a subject.</span>

<span class="hljs-keyword">const</span> subjectTaken2 = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
    <span class="hljs-keyword">return</span> students.some(<span class="hljs-function"><span class="hljs-params">eStudents</span> =&gt;</span> eStudents.subjects);
};

subjectTaken2(); <span class="hljs-comment">//Output would return "true" because some students took a subject.</span>

<span class="hljs-comment">// If we however defined the function with an additional condition like the following (using implicit return with arrow function);</span>

<span class="hljs-keyword">const</span> passed = <span class="hljs-function">() =&gt;</span> students.some(<span class="hljs-function"><span class="hljs-params">students</span> =&gt;</span> students.pass === <span class="hljs-literal">true</span>);

<span class="hljs-comment">// Output: true</span>

<span class="hljs-keyword">const</span> passed2 = <span class="hljs-function">() =&gt;</span> students.every(<span class="hljs-function"><span class="hljs-params">students</span> =&gt;</span> students.pass === <span class="hljs-literal">true</span>);

<span class="hljs-comment">// Output: false Because not every student actually passed.</span>
</code></pre><p>I hope this input helps clarify the topic for those learning JavaScript methods and needs a clearer explanation.</p>
]]></content:encoded></item><item><title><![CDATA[Working With Git. (Learn Your Mistakes before you make them)]]></title><description><![CDATA[Git is a powerful feature to help you keep version control of your files. As a developer, just as with everything, you want to make sure you get adequate…]]></description><link>https://webdevnote.hashnode.dev/working-with-git-learn-your-mistakes-before-you-make-them</link><guid isPermaLink="true">https://webdevnote.hashnode.dev/working-with-git-learn-your-mistakes-before-you-make-them</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[repository]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Victor Adeshile]]></dc:creator><pubDate>Sat, 16 Jan 2021 02:04:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610762506577/gQ6j_Wv8X.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Git is a powerful feature to help you keep version control of your files. </p>
<p>As a developer, just as with everything, you want to make sure you get adequate information regarding a command before using it.</p>
<p>So, my experience using git on VSCode brought about this writeup. </p>
<p>Inasmuch as I was able to rectify the issue, this is one mistake I don't want to make with a gigantic codebase containing thousands of files. It can cause nightmares to be honest.</p>
<p>So, I had been writing codes and pushing them to my repo on GitHub, then, I had the need to rename some of the files, this caused me to keep getting some errors on my git CLI each time I ran the command </p>
<pre><code><span class="hljs-attribute">git</span> status
</code></pre><p>I felt the need to sync all changes with my origin(git Repo).</p>
<p><strong>Roadblock 1:</strong> I was able to use <code>git rm file1.js</code> and this worked fine, but I had a file named try&amp;catch.js which I couldn't remove because git treated the &amp; in the name differently.</p>
<p><strong>Roadblock 2:</strong> In the course of only trying to remove the file which I wanted to be deleted, I did <code>git rm *</code> and this removed all my files from my VSCode.</p>
<p>I was in shock as I didn't know what to do next.</p>
<p><strong>The solution to Roadblock1:</strong> As you may have guessed that I changed the naming convention to something else, well that would have worked also, but I didn't do that. </p>
<p>What I did was implemented the escape syntax before the &amp; sign in the name so My git code was <code>git rm try\&amp;catch.js</code> and this worked awesomely!</p>
<p><strong>The solution to Roadblock2:</strong> I used <code>git reset</code> and then <code>git ls-files -d -z | xargs -0 git checkout --</code> and this restored back all my files for me.</p>
<p>I have never been more disturbed with the tremendous work and documentations I have been pushing all this while to my repo only to have it wiped out with a single mistake.</p>
<p>I hope you learn from my experience. I would share more of my coding journey and how I am able to master JavaScript by practicing, teaching, and most importantly pushing my codes and writeups to my GitHub using the GitHub commands.</p>
<p>These are the things you would be doing the most as a developer.</p>
<p>Like, share, Upvote, and give your honest feedback to help me create better content for you.</p>
<p>You can also support me as a developer so I can spend more quality time providing you with awesome content that would help you become a better developer.</p>
<p>You can now buy me a coffee: https://www.buymeacoffee.com/WebtekMasters</p>
]]></content:encoded></item></channel></rss>