<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joseph Guillory</title>
    <description>The latest articles on DEV Community by Joseph Guillory (@virgomoon).</description>
    <link>https://dev.to/virgomoon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F843806%2F10835706-d4be-4bff-b4bf-8ad14df3ba6d.png</url>
      <title>DEV Community: Joseph Guillory</title>
      <link>https://dev.to/virgomoon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/virgomoon"/>
    <language>en</language>
    <item>
      <title>Learning Regular Expressions</title>
      <dc:creator>Joseph Guillory</dc:creator>
      <pubDate>Sun, 07 Aug 2022 05:18:12 +0000</pubDate>
      <link>https://dev.to/virgomoon/learning-regular-expressions-45p3</link>
      <guid>https://dev.to/virgomoon/learning-regular-expressions-45p3</guid>
      <description>&lt;h3&gt;
  
  
  ReGex
&lt;/h3&gt;

&lt;p&gt;One concept I find particularly difficult to grasp is that of regular expressions or regex. &lt;/p&gt;

&lt;p&gt;What is a regular expression exactly? Well lets turn to Wikipedia for a definition:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JdXPr2Kx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ytap30ljz1sb52854hs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JdXPr2Kx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ytap30ljz1sb52854hs.png" alt="Image description" width="880" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. Regular expression techniques are developed in theoretical computer science and formal language theory."&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Well said Wikipedia, well said.&lt;/p&gt;

&lt;p&gt;So regex is useful for checking if certain characters are in a string. You can then replace or extract those matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing RegEx
&lt;/h3&gt;

&lt;p&gt;So how do we write out a regular expression? Well I'll be using JavaScript to do this but several programming languages support regex. &lt;/p&gt;

&lt;p&gt;Simply use regular expression literals. Two forward slashes. Put the characters you're looking for in between the literals:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---LBr0GIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbl0bak05v1cfwlya01y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---LBr0GIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbl0bak05v1cfwlya01y.png" alt="Image description" width="308" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here I've created a basic regex and saved it to a variable. Now I'll test my regex to see if it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dVJumI7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25x1u08wwrlmwtgj7t91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dVJumI7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25x1u08wwrlmwtgj7t91.png" alt="Image description" width="295" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These 3 strings came back a true because they all had matches for the string 'lie'. Let's see what a fail looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V9JN6eG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjgbzuixmg6fojvc17y9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V9JN6eG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjgbzuixmg6fojvc17y9.png" alt="Image description" width="241" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These came back as false. notice that even strings that contain all 3 characters from our expression came back as false if they were not in the right order or only had partial matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start and End of line
&lt;/h3&gt;

&lt;p&gt;Pretty cool so far, but what if I want to match the beginning or end of a string? &lt;/p&gt;

&lt;p&gt;You would use ^ for the start and $ for the end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z8Da0ADA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aydlf9vmfutpa7ougi1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z8Da0ADA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aydlf9vmfutpa7ougi1d.png" alt="Image description" width="280" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ANWAog4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0a6safsqdhkytfadol2c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ANWAog4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0a6safsqdhkytfadol2c.png" alt="Image description" width="320" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uj2kH3oe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ht1id3kyzjv2l1yjd39l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uj2kH3oe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ht1id3kyzjv2l1yjd39l.png" alt="Image description" width="281" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vx8szcT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/faubqtm17wytuez4jn2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vx8szcT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/faubqtm17wytuez4jn2o.png" alt="Image description" width="397" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm starting to get the hang of this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ranges
&lt;/h3&gt;

&lt;p&gt;In order to make or regex more dynamic we can set ranges to check for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[a-z] checks for any lowercase letter from a to z.&lt;/li&gt;
&lt;li&gt;[A-Z] checks for capital letters.&lt;/li&gt;
&lt;li&gt;[0-9] checks for numbers between 0 and 9.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can combine ranges as well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[A-Za-z]&lt;/li&gt;
&lt;li&gt;[a-z0-9]&lt;/li&gt;
&lt;li&gt;[A-Za-z0-9]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's so much more to learn when it comes to writing regular expressions. Way more than I plan to cover here. But I would like to leave off with a practical example. validating and email address.&lt;/p&gt;

&lt;p&gt;If our goal is to check to see if an email is valid or not, we first need to define what makes an email.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alpha numeric &lt;/li&gt;
&lt;li&gt;Case insensitive &lt;/li&gt;
&lt;li&gt;Has @ before the domain&lt;/li&gt;
&lt;li&gt;Domain must contain a period&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list is not extensive but will serve our purposes for now.&lt;/p&gt;

&lt;p&gt;So we want our local part (the part before @) to be alpha numeric and case insensitive. let's start with ^ and pick a range.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9]"&lt;/p&gt;

&lt;p&gt;We can also add on any other characters that are valid in the local part of an email address. "+._-" are all valid in this part of the address so we'll add them here.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]"&lt;/p&gt;

&lt;p&gt;adding a "+" lets any of these characters repeat. Without it our regex would be looking for just one character in this range, but who ever heard of an email address with only one letter? Now it can be any number of characters long.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+"&lt;/p&gt;

&lt;p&gt;next we'll add the @. It should only appear once and it divides the address into two parts. We'll indicate that like this.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@"&lt;/p&gt;

&lt;p&gt;So far this code is looking for a range of undefined length which can repeat characters, followed by a single @.&lt;/p&gt;

&lt;p&gt;The domain comes next. We'll set another range of characters that are valid to appear in a domain.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@[A-Za-z0-9.-]"&lt;/p&gt;

&lt;p&gt;Note there are slightly fewer valid characters in the domain. Lets add a "+" to let our regex know it's alright for these characters to repeat.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@[A-Za-z0-9.-]+" &lt;/p&gt;

&lt;p&gt;But our domain must contain one period. followed by an extension (.com, .net, .co, .org, .cvvc, etc.). First we need to add the "." but "." is a special character. It has properties attached to it in regex, so in order to process it as a plain old period we have to prepend it with a backslash.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@[A-Za-z0-9.-]+."&lt;/p&gt;

&lt;p&gt;Now to add our extension. They are usually lowercase and 2 - 4 characters long. How do we write this?&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@[A-Za-z0-9.-]+.[a-z]{2,4}"&lt;/p&gt;

&lt;p&gt;Here we said that after the "." there should be a range of lowercase letters. The same way putting a + at the end of a range signified any character from our range can be repeated any number of times, we can limit the number of times a character can in a range can be used. &lt;/p&gt;

&lt;p&gt;inside the brackets we set a minimum of 2 and maximum of 4. this allows us to use 2 char. extensions (.co, .io), 3 char. (.com, .org, .net), and even 4 char. (.cvcv, .cvvc).&lt;/p&gt;

&lt;p&gt;Top it all off with a $ to indicate it should end with the extension.&lt;/p&gt;

&lt;p&gt;"^[A-Za-z0-9+._-]+@[A-Za-z0-9.-]+.[a-z]{2,4}$"&lt;/p&gt;

&lt;p&gt;Let's try it out:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2MExzvLc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vuz56wo8b8ukagwdqhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2MExzvLc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vuz56wo8b8ukagwdqhz.png" alt="Image description" width="727" height="73"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yaxm1Qwn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah0vhcaaeq9lst8w26ca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yaxm1Qwn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah0vhcaaeq9lst8w26ca.png" alt="Image description" width="448" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6MA8lrik--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qd3p6psn386dhqq0u96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6MA8lrik--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qd3p6psn386dhqq0u96.png" alt="Image description" width="363" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the regex I came up with to check for email addresses. It is by no means the only way to do this. But having gone through this process I feel a lot more confident in my ability to use Regular Expressions. I hope you do to.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>regex</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Flex plus Grid equals CSS success</title>
      <dc:creator>Joseph Guillory</dc:creator>
      <pubDate>Sun, 03 Jul 2022 05:34:43 +0000</pubDate>
      <link>https://dev.to/virgomoon/flex-plus-grid-equals-css-success-1ka2</link>
      <guid>https://dev.to/virgomoon/flex-plus-grid-equals-css-success-1ka2</guid>
      <description>&lt;h3&gt;
  
  
  My CSS journey
&lt;/h3&gt;

&lt;p&gt;CSS has been a constant thorn in my side. In the past I've gotten by with the "Throw everything at the wall and see what sticks" method. Although it's served it's purpose in the past, I feel I have reached the limits of what this technique has to offer.&lt;/p&gt;

&lt;p&gt;Now I plan to conquer CSS one step at a time. In my research I've come up with a simple strategy for teaching myself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Practice styling a react app.&lt;/li&gt;
&lt;li&gt;Style the components with flex.&lt;/li&gt;
&lt;li&gt;Style the App page with grid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've concluded that this work flow will serve me best. My next step was to experiment with flex and Grid. I'll walk through what I did to style my practice App. Maybe as I show my process, you can learn something too.&lt;/p&gt;

&lt;p&gt;First thing I did after creating a new react app, and naming it CSS_react_sandbox, was to create five components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DkuLiBHq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/997bjp91vb6o8vr965fv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DkuLiBHq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/997bjp91vb6o8vr965fv.png" alt="Image description" width="482" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each component was set up with an outer parent div, and 3 inner child divs. I gave them respective class names and each child a unique id.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ij7Xt0Fj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lowyzjhkp2ymuaxn06i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ij7Xt0Fj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lowyzjhkp2ymuaxn06i.png" alt="Image description" width="558" height="356"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I decided that my first component would serve as my header. I styled the div accordingly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fXlEeX1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7g8guehkfpydol7m6pp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fXlEeX1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7g8guehkfpydol7m6pp.png" alt="Image description" width="422" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I chose a display of flex with flex-direction row. My thinking here was that as a header/nav component, this component should be sprawled across the top of the page. The 3 child divs represent, from left to right: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The space allocated for the navigation.&lt;/li&gt;
&lt;li&gt;A personalized welcome message.&lt;/li&gt;
&lt;li&gt;A log out button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NYsSqIIB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/noj6uiqlfpj7b8t8s2ob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NYsSqIIB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/noj6uiqlfpj7b8t8s2ob.png" alt="Image description" width="880" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I changed the size of each child element according to the amount of space I wanted each to take up. Using the flex-grow property I was able to determine how much space I wanted each element to take up. By imagining the div divided into 8 parts I allocated 6 parts to the largest element and the remaining two one part each.&lt;/p&gt;

&lt;p&gt;Next I did similar styling for the other four components. I designated that the second and fourth would be asides, the third would be the main content, and the fifth would be the footer.&lt;/p&gt;

&lt;p&gt;Left aside:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aE8eeKIz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wm2mn8df0gi3qypb5hj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aE8eeKIz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wm2mn8df0gi3qypb5hj.png" alt="Image description" width="415" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTjNkVgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/haid9o0tqj0hqqryabza.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTjNkVgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/haid9o0tqj0hqqryabza.png" alt="Image description" width="285" height="657"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right aside:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GbdiUoeE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltopwguz26wcsm0rk7tj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GbdiUoeE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltopwguz26wcsm0rk7tj.png" alt="Image description" width="315" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bbfHYcdJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ewzflz6nbisx73a8xu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bbfHYcdJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ewzflz6nbisx73a8xu6.png" alt="Image description" width="283" height="658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Footer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oit4HZud--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u3luv8mbfmltw0ms5x5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oit4HZud--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u3luv8mbfmltw0ms5x5.png" alt="Image description" width="300" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z8lQyvsc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtif7krki8scfma24raf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z8lQyvsc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtif7krki8scfma24raf.png" alt="Image description" width="880" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the Main:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NUY_SEZa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpo7ktqk5u1c6myazl0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NUY_SEZa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpo7ktqk5u1c6myazl0h.png" alt="Image description" width="362" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sVHk2GnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p53uy76fn9ww7q41exis.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sVHk2GnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p53uy76fn9ww7q41exis.png" alt="Image description" width="880" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that I have all my components, it's time to move over to App.css and add grid.&lt;/p&gt;

&lt;p&gt;First I set the display to grid and the height to 100vh. Since I want the app component to cover the whole screen. &lt;/p&gt;

&lt;p&gt;Next I set up my grid parameters with grid-template-columns, and grid-template-rows. &lt;/p&gt;

&lt;p&gt;With the columns I start from the left side of the screen. This will be my first columns edge, I label it "first". I label the right edge of the column line2. I want the first aside to take up 20% of the available space so I insert that between the first and second lines. The two remaining lines will be labeled line3 and end. Between line3 and end I set the percent to 20 once again. Then the space between line 2 and 3 is set to auto.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ICNDTIxd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns78futpmllyruo31kxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ICNDTIxd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns78futpmllyruo31kxp.png" alt="Image description" width="843" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the rows my four lines are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;row1-start&lt;/li&gt;
&lt;li&gt;row1-end&lt;/li&gt;
&lt;li&gt;footer-start&lt;/li&gt;
&lt;li&gt;footer-end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Labeling it this way helps me remember what each line represents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MYzNK9-p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cuojfzkg1nsutqt2ycud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MYzNK9-p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cuojfzkg1nsutqt2ycud.png" alt="Image description" width="865" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I need to set the grid-columns and grid-rows for the components. This tells them where on the page they should be.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XVwwJw8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lr6mp0nos4oymg7nidf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XVwwJw8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lr6mp0nos4oymg7nidf.png" alt="Image description" width="397" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The final result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FHyY-Ndf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/promcxn5nb3dr0xbvo4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FHyY-Ndf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/promcxn5nb3dr0xbvo4x.png" alt="Image description" width="880" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is by no means an exhaustive exploration of what can be accomplished with Grid or Flex. But I certainly learned a few things that I can build upon. I hope you did as well.&lt;/p&gt;

&lt;p&gt;Until next time.&lt;/p&gt;

</description>
      <category>css</category>
      <category>react</category>
      <category>programming</category>
      <category>design</category>
    </item>
    <item>
      <title>The Reduce Method</title>
      <dc:creator>Joseph Guillory</dc:creator>
      <pubDate>Sat, 07 May 2022 15:08:41 +0000</pubDate>
      <link>https://dev.to/virgomoon/the-reduce-method-16pl</link>
      <guid>https://dev.to/virgomoon/the-reduce-method-16pl</guid>
      <description>&lt;p&gt;In my quest to collect all the coding infinity stones in my JavaScript gauntlet, I decided to tackle the methods that perplex me. Case in point, the reduce method. Wrapping my head around how this method works was challenging for me, so what better way to master it than to write a blog post about it? As they say, if you really want to learn something, teach it.&lt;/p&gt;

&lt;p&gt;For starters, what exactly is the reduce method? My understanding of it is, it’s a way to iterate over an array and reduce it into a single value. &lt;/p&gt;

&lt;p&gt;The syntax is simple enough:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VR1JuvIQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1o60j20601k6lvo6fyp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VR1JuvIQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1o60j20601k6lvo6fyp.png" alt="Image description" width="300" height="82"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;You run the reduce method on an array using dot notation.&lt;br&gt;
Then you call a function you want to use on each item in the array. This function takes in a minimum of two values. The first is the total value, the second is the current value. Represented above by “init”, for initial value.&lt;/p&gt;

&lt;p&gt;You can have up to four parameters plus an initial value, but that’s a little more advanced, for today we’ll keep it simple.&lt;br&gt;
Now that we have our syntax, how do we apply it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1gyPmVRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvkwfmlmodvjigs3tb0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1gyPmVRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvkwfmlmodvjigs3tb0w.png" alt="Image description" width="368" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above we start out with our array called numbers. Inside are 4 integers. Here we are trying to subtract each number in the array from the number proceeding it.&lt;/p&gt;

&lt;p&gt;In order to accomplish this task, we create our callback function, called subFunc (subtract function). We give it two parameters. The total, this amount will accumulate the results of our function being called on each array item. The second parameter is the current value, here represented as num (number).&lt;/p&gt;

&lt;p&gt;Now that we have our array and our callback, we’ll run reduce on the numbers array using dot notation. Inside of the function call for reduce we place our callback, subFunc. Now let’s see what happens when we set our initial value to 0. We get a return value of:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CdQ0T8xG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2h5ugqajh5aizb22iitw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CdQ0T8xG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2h5ugqajh5aizb22iitw.png" alt="Image description" width="58" height="30"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hmmm… that doesn’t look quite right, what happened here? Let’s console log each step of the iteration. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HRwSV7dL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n94percb8d5zu7qq3u9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HRwSV7dL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n94percb8d5zu7qq3u9t.png" alt="Image description" width="107" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ahh… So, our initial number we added, zero, was inserted as our total to start from. Then the first item in our array, 250, was subtracted from zero. Giving us -250. The next item, 45 was then subtracted from that. The loop continued until we end up with our final result, -370.&lt;/p&gt;

&lt;p&gt;What would happen if we left out the initial value when calling reduce?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GhOBgPzy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idbz69ufovghoox39pvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GhOBgPzy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idbz69ufovghoox39pvh.png" alt="Image description" width="355" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p0gQjqRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qp0odddble9az8x7tslq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p0gQjqRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qp0odddble9az8x7tslq.png" alt="Image description" width="47" height="27"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now this looks like what we were expecting. Let’s console log to see what happened behind the scenes.&lt;/p&gt;

&lt;p&gt;This time the first item in our array was used as the initial amount. The second item was then subtracted from that number and the result becomes the new total that is used in the next loop.&lt;br&gt;
When the method is finished it will return the final accumulated result. In this case 130.&lt;/p&gt;

&lt;p&gt;Now instead of an array of integers, how about an array of doubles? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vO4ypfqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osod0bfxzuqgs9ri113f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vO4ypfqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osod0bfxzuqgs9ri113f.png" alt="Image description" width="456" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have an array called moreNumbers, that holds an array of float/doubles. Next, we create a callback called sumFunc (sum function), which rounds up/down each number to an integer then adds it to the accumulated total. &lt;br&gt;
Our result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OfoVuyjx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu7ijuzbfea0h0e5n36s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OfoVuyjx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu7ijuzbfea0h0e5n36s.png" alt="Image description" width="63" height="28"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But wait, shouldn’t the final number be an integer if we’re rounding each number? Why has our function returned a double?&lt;br&gt;
Let’s get to the bottom of this with a console log.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CqY1ozbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6i29bdwaiupbmp0bypgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CqY1ozbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6i29bdwaiupbmp0bypgv.png" alt="Image description" width="125" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aha! Since we didn’t set an initial value, it took the first index of our array and used that instead. The call back used in a reduce method doesn’t run the calculations on the initial number, so the first item in the array was not rounded up. Therefore, it remained a double no matter how many integers we added to it.&lt;/p&gt;

&lt;p&gt;When we add an initial value of 0, we get a different result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--krAUOHsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzvkmlmtsrm1q5pws015.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--krAUOHsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzvkmlmtsrm1q5pws015.png" alt="Image description" width="462" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the reduce method plugs 0 into the total position of the equation, it can then apply the math in sumFunc to every item in the entire array. Numbers are rounded into whole numbers and added all together. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NTY0htjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axv4xjqjna4abgmw80r6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NTY0htjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axv4xjqjna4abgmw80r6.png" alt="Image description" width="88" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s an example of what it will look like if we have an initial value of 95.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NQJ6uzHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by6waryht1yr3ohfsoj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NQJ6uzHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by6waryht1yr3ohfsoj4.png" alt="Image description" width="447" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dgheTKhK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23m5iipkdwhm6xgej1p2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dgheTKhK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23m5iipkdwhm6xgej1p2.png" alt="Image description" width="106" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reduce method is not limited to array’s of numbers however.&lt;br&gt;
You can reduce an array of strings into a single string.&lt;/p&gt;

&lt;p&gt;Here we have an array of strings. We name the string words.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jdhZrJpC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tho12dmd7h2a0ppct0jj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jdhZrJpC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tho12dmd7h2a0ppct0jj.png" alt="Image description" width="540" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We build a callback function called makeSentence. It will have no initial value, so the first word will be the “sentence” when we begin. It then concatenates an empty space and the next word to our sentence.&lt;/p&gt;

&lt;p&gt;When it’s done it will return the finished sentence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T7JuodNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8s8x6zu2ch2y6y8jxgb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T7JuodNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8s8x6zu2ch2y6y8jxgb3.png" alt="Image description" width="242" height="36"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One last example of our method.&lt;/p&gt;

&lt;p&gt;Let’s say I want to keep track of how many tools a shop has sold. Every time the shop sells a tool The name of the tool is added to an array. We’ll call this array tools.&lt;/p&gt;

&lt;p&gt;Next, we write a callback function we’ll call reduceTools.&lt;br&gt;
This function starts off with an empty object. This is our total. It then checks to see if the ‘item’ parameter is a key in the object. If it is or if it isn’t, it will update the value of the key by one. If the key’s value is 0, meaning the key doesn’t exist it will add it to the object (add to the total).&lt;/p&gt;

&lt;p&gt;Every time it comes across a key that exists it increases that keys value by 1. When it encounters a key that doesn’t exist it will add that key with an updated value of 1 to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nKDFoJ8x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxb9enzj4d5i51yf5im8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nKDFoJ8x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxb9enzj4d5i51yf5im8.png" alt="Image description" width="586" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is what the process will look like if we console log it: &lt;br&gt;
{} hammer&lt;br&gt;
1&lt;br&gt;
{ hammer: 1 }&lt;br&gt;
{ hammer: 1 } nails&lt;br&gt;
1&lt;br&gt;
{ hammer: 1, nails: 1 }&lt;br&gt;
{ hammer: 1, nails: 1 } screwdriver&lt;br&gt;
1&lt;br&gt;
{ hammer: 1, nails: 1, screwdriver: 1 }&lt;br&gt;
{ hammer: 1, nails: 1, screwdriver: 1 } hammer&lt;br&gt;
2&lt;br&gt;
{ hammer: 2, nails: 1, screwdriver: 1 }&lt;br&gt;
{ hammer: 2, nails: 1, screwdriver: 1 } hammer&lt;br&gt;
3&lt;br&gt;
{ hammer: 3, nails: 1, screwdriver: 1 }&lt;br&gt;
{ hammer: 3, nails: 1, screwdriver: 1 } screwdriver&lt;br&gt;
2&lt;br&gt;
{ hammer: 3, nails: 1, screwdriver: 2 }&lt;br&gt;
{ hammer: 3, nails: 1, screwdriver: 2 } nails&lt;br&gt;
2&lt;br&gt;
{ hammer: 3, nails: 2, screwdriver: 2 }&lt;br&gt;
{ hammer: 3, nails: 2, screwdriver: 2 } hammer&lt;br&gt;
4&lt;br&gt;
{ hammer: 4, nails: 2, screwdriver: 2 }&lt;br&gt;
{ hammer: 4, nails: 2, screwdriver: 2 } hammer&lt;br&gt;
5&lt;br&gt;
{ hammer: 5, nails: 2, screwdriver: 2 }&lt;br&gt;
{ hammer: 5, nails: 2, screwdriver: 2 } nails&lt;br&gt;
3&lt;br&gt;
{ hammer: 5, nails: 3, screwdriver: 2 }&lt;br&gt;
{ hammer: 5, nails: 3, screwdriver: 2 } saw&lt;br&gt;
1&lt;br&gt;
{ hammer: 5, nails: 3, screwdriver: 2, saw: 1 }&lt;br&gt;
So after all that the result is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JxuFoa0Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7nitfv46iyg7or6r1nx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JxuFoa0Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7nitfv46iyg7or6r1nx.png" alt="Image description" width="481" height="31"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now have a single object with our tools as keys and the number sold as their values.&lt;/p&gt;

&lt;p&gt;Awesome! We mastered the basics of the reduce method. What other ways can this method be used I wonder? &lt;/p&gt;

&lt;p&gt;Have fun experimenting with it and see what you can types of data you can reduce.&lt;/p&gt;

&lt;p&gt;Thanks for coming along with me on my journey of reduce method self-discovery. &lt;/p&gt;

&lt;p&gt;I hope you learned something. I know I did.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reduce</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why I Choose To Pursue Software Development</title>
      <dc:creator>Joseph Guillory</dc:creator>
      <pubDate>Fri, 08 Apr 2022 17:00:11 +0000</pubDate>
      <link>https://dev.to/virgomoon/why-i-choose-to-pursue-software-development-2bg2</link>
      <guid>https://dev.to/virgomoon/why-i-choose-to-pursue-software-development-2bg2</guid>
      <description>&lt;p&gt;On Monday, March 16, 2020, I was going about my regular day. Shuffling passengers back and forth to their destinations. I had just completed a drop off at SFO airport and had my next passenger in tow. We engaged in idle chit chat about a certain “bug” that was going around. He asked if business had been affected by it, and I told him so far it hadn’t. Then the voice of London Breed, the mayor of San Francisco came onto the radio as if on queue. She announced a stay-at-home order, I believe the first in the nation. My passenger and I shared a laugh at the seeming coincidence and parted ways. At that point I decided to turn off my app and call it a day. I checked my earnings, nearly $200 for just under 8 hours of driving. Not bad. My work week was off to a good start.&lt;/p&gt;

&lt;p&gt;Then came Tuesday, March 17, 2020, I woke up the same time as the day before. Took my same route I always took. Drove the same number of hours as I always drove. By the end of the day, I had made a whopping $17… In 8 hours. Now the ride share business always had fluctuations in the amount of money you would make in a day. On a good day I could make as much as $260.  On the slower days I’d make around $120 in 8 hours (I know some drivers who averaged a lot more, but I could never replicate their success). But the contrast between my Monday earnings and Tuesday earnings was enough to shake me out of my comfort zone. I needed something more stable, and I needed it now!&lt;/p&gt;

&lt;p&gt;My plan was simple, just two steps. Step 1, find something immediately to replace the money I was losing. Step 2 was to find a long-term income replacement. The first step was simple enough. I was able to secure part time work at an Amazon warehouse. It had been five years since I’d worked in manual labor, so it was an adjustment, but it at least it was a steady check. Next, I had to decide what my long-term working goal would be. I decided to teach myself how to code. It seemed like the perfect fit for me. I loved the idea of remote work. It was what initially attracted me to ride share. The ability to turn on my app and make money anywhere with my car would become the ability to turn on my laptop from anywhere and make money.&lt;/p&gt;

&lt;p&gt;Programming was a skill I could take with me anywhere. So, I spent months teaching myself how to code in my spare time. I was highly motivated when I first began so it was easy to spend hours practicing my new craft. Then by the end of summer I was beginning to burn out. The more I learned it seemed like there was even more I didn’t know how to do. I became overwhelmed trying to learn everything I possibly could so I would be ready for absolutely any situation. I wasn’t sure what I needed to know to be employable. I also had no idea how to network or make an appealing resume. So, my motivation slowly died down, and the procrastination began to kick in. I made less and less time to code, and I was getting used to my routine at Amazon. Before I knew it, I had stopped studying coding altogether and quietly accepted the idea of Amazon being my permanent job.&lt;/p&gt;

&lt;p&gt;Everything changed when Amazon switched my shift from mornings to nights. I found my new shift to be a bad fit for my lifestyle. Suddenly I began to think about other options again. So, I became an interim driver trainer. For 4 months I was temporarily taken from the night shift and placed back on days for my new role. I tried to become permanent in the driver trainer position, but my all attempts had fallen through. I was on a ticking clock; it was only a matter of time before I would once again have to go back to the night shift which I did not want. So, I again began to look for alternatives. I had seen the flyers for Amazon’s career choice program hanging in the bathroom before and ignored them, but now I an incentive to pay attention. Although I had forgotten everything, I taught myself by this time, I was sure it would come back to me. I felt like this time would be different because I would be forming a connection with an actual teacher and other students. So, I went for it.&lt;/p&gt;

&lt;p&gt;And then as if it was all preordained everything fell into place. The new Driver trainer they hired quit within his first week, and now they were ready to give me an interview. I became a full-time Driver Trainer at the same time I was accepted into the career choice program. So even if I don’t find a job writing code, at least I don’t have to go back to the dreaded night shift. I’m not sure what the future will be, but from where I’m standing it looks bright.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>writing</category>
      <category>motivation</category>
    </item>
  </channel>
</rss>
