<?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: Eric Saldivar</title>
    <description>The latest articles on DEV Community by Eric Saldivar (@esaldivar).</description>
    <link>https://dev.to/esaldivar</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%2F634734%2F693e6bf5-46cb-446f-817f-7faad8504774.jpg</url>
      <title>DEV Community: Eric Saldivar</title>
      <link>https://dev.to/esaldivar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/esaldivar"/>
    <language>en</language>
    <item>
      <title>How to write a README</title>
      <dc:creator>Eric Saldivar</dc:creator>
      <pubDate>Wed, 15 Sep 2021 21:45:26 +0000</pubDate>
      <link>https://dev.to/esaldivar/how-to-write-a-readme-3ge9</link>
      <guid>https://dev.to/esaldivar/how-to-write-a-readme-3ge9</guid>
      <description>&lt;p&gt;What is a README?  A README is a series of instructions, information, and/or guide which usually highlight a portion if not what an entire codebase does.  A README is written in Markdown syntax which may be different then what you are accustomed to besides HTML syntax.  &lt;/p&gt;

&lt;p&gt;So why use a README?  Well, the reason I started diving into writing READMEs and taking the time to fine tune them is simply because it makes my code accessible.  It creates a guide by which those unfamiliar with my code or tech stack can gain a quick insight into the workings of my file structure, database management/schema, etc.&lt;/p&gt;

&lt;p&gt;Now, how do you write a good README?&lt;/p&gt;

&lt;h1&gt;Title, short description, and image&lt;/h1&gt;

&lt;p&gt;Well first you need a title and I would recommend titling your README based on it's coverage.  A README that you find as soon as you open up a repository should be titled the name of the repository or product.  I would recommend h1 tags for this purpose. It also makes sense to put a short description (one sentence) of the overall purpose of the product or code here.  I also recommend a picture directly under your README that is a representation of your code/product. This could also be a logo for your product!  Maybe a picture of a key feature or a gif of your product in action.  Images are written in markdown syntax with the img tag.  An important note is that markdown syntax uses inline styling to position things, color things, size things, etc.  So for an image I typically mark its source (src) maybe its linked in the files or hyperlinked where it is stored.&lt;/p&gt;

&lt;p&gt;See an example below for one of my first title, description, and image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzmk235cl2g4z83r9nxh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzmk235cl2g4z83r9nxh.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;Table of Contents&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm85opwl154bjhrcbknhl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm85opwl154bjhrcbknhl.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you have a fancy title, a short description, and an image that gives some insight into your project/product.   I believe the next thing that sets apart other READMEs is a table of contents.  How do you create a table of contents with Markdown?  Title the Table of contents with an h2 tag then use the following format.&lt;/p&gt;

&lt;p&gt;Asterisk followed by closed square brackets that wrap the title of the content followed by parenthesis that enclose the link to the part of the README where the content is located.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eo0enp3xeah5qbi8h56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eo0enp3xeah5qbi8h56.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/handle/yourrepo/#contentarea" rel="noopener noreferrer"&gt;section 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/handle/yourrepo/#contentarea" rel="noopener noreferrer"&gt;section 2&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/handle/yourrepo/#contentarea" rel="noopener noreferrer"&gt;section 3&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;Sections&lt;/h1&gt;

&lt;p&gt;After the table of contents, the contents naturally follow.  What the contents are depends on your project/product but things that make contents easy to read are picture examples and code snippets!&lt;/p&gt;

&lt;p&gt;How do you write a code snippet and what is it?  Let's take a look!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3e8fuz1ctazl2bzhbvd.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3e8fuz1ctazl2bzhbvd.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three tick marks followed by the language and inside the tick marks you can place your code block.  After that close with three more tick marks!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So these are what I would consider the basics of a README.  I want to expand on this later.  I will also say that it has benefited me to look at professional products and study their READMEs.  I hope this has been helpful to you!  See you in the next post.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Algorithm Approach: Retrieve Depth</title>
      <dc:creator>Eric Saldivar</dc:creator>
      <pubDate>Wed, 21 Jul 2021 14:58:06 +0000</pubDate>
      <link>https://dev.to/esaldivar/algorithm-approach-retrieve-depth-48fk</link>
      <guid>https://dev.to/esaldivar/algorithm-approach-retrieve-depth-48fk</guid>
      <description>&lt;p&gt;Hey all!  This is my first algorithm approach where I utilize RECURSION!  Let's hope for the best and dive in!  So what is recursion?  &lt;em&gt;In computer science, recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem. Such problems can generally be solved by iteration, but this needs to identify and index the smaller instances at programming time.&lt;/em&gt;-- &lt;cite&gt;Epp, Susanna (1995). Discrete Mathematics with Applications&lt;/cite&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88hrt44tmmgrxi91ses6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88hrt44tmmgrxi91ses6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The simple way I think of recursion is when a function calls itself.  Usually functions return a value to be accessed outside of their scope. &lt;/p&gt;

&lt;p&gt;So the algorithm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;retrieveDepth&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Given an arbitrarily nested array of numbers and a positive integer "depth",return a new array consisting of the numbers with depth less than or equal to the provided depth, in order of appearance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The original array is considered to be at depth 1, and inner arrays are at&lt;br&gt;
greater depth.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What does it mean?  The first parameter will be an array with nested arrays, depths ranging from one level deep to many levels deep.  The second argument will be the depth you are required to go into, the depth of the inner arrays.&lt;/p&gt;

&lt;p&gt;So how can we visualize this problem?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0008lkfsvou69e971ib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0008lkfsvou69e971ib.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first layer of the array means you can access the values and they won't be arrays.  The following levels are nested.  If you are required to go deeper than the first level you will bring up the values nested into the matching depth that you dive.&lt;/p&gt;

&lt;p&gt;The approach:&lt;/p&gt;

&lt;p&gt;We need a base case which is the condition when met stops our function and returns an output. Without a base case our function would call itself endlessly and create a stack overflow, when a program attempts to use more space than is available on the call stack (that is, when it attempts to access memory beyond the call stack's bounds).  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4s38d4xm5krlymp92bu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4s38d4xm5krlymp92bu.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The base case is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we are at the depth of one, we will no longer dive and return the array but we need to filter through it.  We are applying the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="noopener noreferrer"&gt;filter method&lt;/a&gt;. We only want values that are not arrays.  We iterate through the array and if a value is an array we do not include it in the newly filtered array.  We are checking with Array.isArray(value) but we have a ! (bang operator) which when placed in front of a boolean value it will reverse the value, returning the opposite. So we will receive all values that are not arrays.  &lt;/p&gt;

&lt;p&gt;The recursive call is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;retrieveDepth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nx"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We return the function but the arguments are different.  We flatten the array with each new call and decrement the depth by 1.  We do this until we reach our base case, which is when the depth is less than or equal to 1.  Less than to catch any weird arguments that are less than 1 initially and 1 as we decrement we should eventually reach 1.  &lt;/p&gt;

&lt;p&gt;Just a quick note on what &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat" rel="noopener noreferrer"&gt;array.flat()&lt;/a&gt; does.  The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.  &lt;/p&gt;

&lt;p&gt;Our function at a final glance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;retrieveDepth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;retrieveDepth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nx"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can expect our evaluated result to be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F742smkconaz1lijy9qqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F742smkconaz1lijy9qqk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's it!  Any questions?  Reach out!  Thanks for reading and have a great day!&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Style with the Dev Tools: Part 1 - Positioning</title>
      <dc:creator>Eric Saldivar</dc:creator>
      <pubDate>Thu, 01 Jul 2021 18:49:55 +0000</pubDate>
      <link>https://dev.to/esaldivar/style-with-the-dev-tools-part-1-positioning-2ig4</link>
      <guid>https://dev.to/esaldivar/style-with-the-dev-tools-part-1-positioning-2ig4</guid>
      <description>&lt;p&gt;I don't know about you but I often hear that styling a webpage is tedious and frustrating.  I can appreciate that.  But, it doesn't have to be.  Did you know that you can style a webpage with the developer tools.  Maybe you do and that is great!  But if you don't then let me enlighten you to a couple of tips and tricks that I enjoy using.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RNecKSUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8s5a2tks0x6wiq6vrl1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RNecKSUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8s5a2tks0x6wiq6vrl1.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So one of the first challenges I find when working with a webpage is centering or positioning anything.  It's a pain in the butt!  But it can be made simpler and one of the ways to make things easier for you is to use display grid or flex.  Now I will link CSS Tricks &lt;a href="https://css-tricks.com/snippets/css/complete-guide-grid/"&gt;Grid here&lt;/a&gt; and &lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"&gt;flex here&lt;/a&gt;.  I have linked basic pictures of the helpful images you can find on CSS tricks.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--900NjeWH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czd2ymo6g78xuv7v956c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--900NjeWH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czd2ymo6g78xuv7v956c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3bLzdjwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr2p38jkvr14lb9wg89a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3bLzdjwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr2p38jkvr14lb9wg89a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let's talk how to help with the dev tools.  If you inspect the page and you have display grid or display grid on any of your containers/divs you can actually see a button on the elements tab in the dev tools that says either grid or flex depending on your choice.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7M-p6HDa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v01zwaq04wm2wnosm17.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7M-p6HDa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v01zwaq04wm2wnosm17.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking this button you will be able to manipulate the styles window to the right which has another small button. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kao3hFwT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/csykpozxig36texcj4jd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kao3hFwT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/csykpozxig36texcj4jd.png" alt="Alt Text"&gt;&lt;/a&gt; If you click this you will then have access to all of the manipulation for grid and flex.  This is powerful and I urge you to play around with this.  You can move components on your browser window and find that position and layout that works for you.  Want to bring these positions in your code?  Copy and paste the CSS and bring it into yours.  This might require some finesse if you are using Sass, Styled Components, Material Ui, etc...  &lt;/p&gt;

&lt;p&gt;I want to make a small series about styling especially with the dev tools so I will end this article here.  If you need any help please reach out!  I hope that you enjoy styling a little bit more and good luck with your coding!&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Algorithm Approach: Bubble Sort</title>
      <dc:creator>Eric Saldivar</dc:creator>
      <pubDate>Wed, 02 Jun 2021 20:10:25 +0000</pubDate>
      <link>https://dev.to/esaldivar/algorithm-approach-bubble-sort-13oi</link>
      <guid>https://dev.to/esaldivar/algorithm-approach-bubble-sort-13oi</guid>
      <description>&lt;p&gt;Today I want to talk about the first sort that I have learned, bubble sort.  Approaches to sorting arrays are named in such a way that they illustrate what they are doing.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--07TG7Rsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7x1uezowvjtihtftd1r.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--07TG7Rsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7x1uezowvjtihtftd1r.gif" alt="Alt Text" width="277" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bubble sort takes a look at the current value and the next value in the array as you iterate through it.  If during your iteration you find that you have a current value greater than your next value you must swap those values.  &lt;/p&gt;

&lt;p&gt;Not swapping is not enough because we need to create something called a &lt;a href="https://en.wikipedia.org/wiki/Sentinel_value#:~:text=In%20computer%20programming%2C%20a%20sentinel,a%20loop%20or%20recursive%20algorithm."&gt;sentinel value&lt;/a&gt;.  What a sentinel value does is it acts like a gate keeper.  It controls the flow of your loop such that you need to continue looping while it is true or not true, depending on how you coded your sort.&lt;/p&gt;

&lt;p&gt;So lets look at the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YuPM_yeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9cmu4f9a17rfmebg0p8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YuPM_yeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9cmu4f9a17rfmebg0p8o.png" alt="Alt Text" width="466" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Going through each line of the code the first thing we notice is that the function takes an array as a parameter.  Duh!  &lt;/p&gt;

&lt;p&gt;The next thing we have declared in our function is a value labeled &lt;strong&gt;trade&lt;/strong&gt; which is our sentinel value.  We initialize this variable as false meaning that no trades (swaps) have occurred.  Next we are going to declare a variable labeled &lt;strong&gt;count&lt;/strong&gt; which is simply going to track how many times we have iterated through the array.  This is especially important and it took me awhile to understand that we will use this to decrease the length of the array as we iterate through it again.  Why do we do this...I will explain this shortly.&lt;/p&gt;

&lt;p&gt;Now the for the actual iteration.  The iteration through the array will be nested in a while loop.  While loops run until the parameter set within their parenthesis is no longer true.&lt;/p&gt;

&lt;p&gt;Inside the while loop our condition is our sentinel value.  We are stating that while trade is false or when no values have been traded, we can continue our while loop.  Nesting a for loop inside a while loop will give us a time complexity of O(n&lt;sup&gt;2&lt;/sup&gt;).  We have a space complexity of O(1) though as we are not requiring any more space to sort.&lt;/p&gt;

&lt;p&gt;Now it might seem weird to immediately reassign the trade value but the reason we do this is that in the case we iterate and we make no swaps, the true value will allow us to escape our while loop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yxww17xD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ask68gj6u41f7gf87lu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yxww17xD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ask68gj6u41f7gf87lu.gif" alt="Alt Text" width="480" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we iterate through our array, declaring i as 0 to start at the index of the array, the stopping condition is if we reach 1 less than the length of the array but wait... minus the count?  I mentioned this earlier and the reason we do this is that if we are sorting and taking the larger values to the end then we can expect that we don't need to iterate through the full length of the array each time as we would end up iterating over the large values at the end which are already sorted.  Again, this took me a second or twenty to understand.  Finally, i++ because simply we are going through the indexes of the array one at a time.&lt;/p&gt;

&lt;p&gt;Our conditional check!  If the current value is greater than the next value it is time to make a trade!  Create a variable and assign it the value of the current value.  Why?  We do this because we are about to lose access to that value so we must store it.   Alright, reassign then current value to be next value in the array.  Now, assign the next value in the array to be the current we declared just moments ago. We assign trade to the value of false to continue to stay in the scope of our while loop.  Now  we can continue to iterate and swap where necessary. When we finish one iteration of our array we increment the count by one which will allow us to reduce the length of the array we need to iterate through.  &lt;/p&gt;

&lt;p&gt;If and when we iterate through the array and no values have been traded we will break out of our while loop.  That was quite the journey but don't forget to return the array to complete this algorithm!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Algorithm Approach : Palindrome</title>
      <dc:creator>Eric Saldivar</dc:creator>
      <pubDate>Sat, 22 May 2021 03:00:45 +0000</pubDate>
      <link>https://dev.to/esaldivar/algorithm-approach-palindrome-41i3</link>
      <guid>https://dev.to/esaldivar/algorithm-approach-palindrome-41i3</guid>
      <description>&lt;p&gt;Welcome to my first post in a series of post I hope to make once a week or at least once every other week.  I want to approach popular algorithms and explain my approach to solving them.  I hope you find this helpful, feel free to reply/comment about anything I did right, wrong, or what you may have done differently.&lt;/p&gt;

&lt;p&gt;So let's get to it!  First, the prompt:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39d14s5k4m2q2dupoqof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39d14s5k4m2q2dupoqof.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Things we know:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The parameter is a string.&lt;/li&gt;
&lt;li&gt;It will contain at least one character as it will be non-empty.&lt;/li&gt;
&lt;li&gt;We must return either true or false.  True if the string is a palindrome and false if it is not.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr67mmfxiluo5dxefxoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnr67mmfxiluo5dxefxoh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's start with a case that we can immediately return as true.  If the length of the string is 1 then we will return true as a string of 'a' for example will be 'a' as it really doesn't have a reverse order to read.&lt;/p&gt;

&lt;p&gt;Now what do we do in the case where a string has a length greater than one?&lt;/p&gt;

&lt;p&gt;I chose to declare a variable with the label of revStr (reversed string) which splits the string, reverses the order, and joins the string back together.&lt;/p&gt;

&lt;p&gt;Let's break that down further.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The split method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split" rel="noopener noreferrer"&gt;string.split()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use this string method to separate the characters of a string and make them values in an array.  We pass in a parameter of '' to split every character.  If we passed in ' ' we would separate every word.  Look at the MDN docs linked above to understand the split method further.&lt;/p&gt;

&lt;p&gt;Now if we had the string racecar we would have ['r','a', 'c', 'e', 'c', 'a', 'r']&lt;/p&gt;

&lt;p&gt;We can use this because we are going to apply array methods now!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The reverse method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse" rel="noopener noreferrer"&gt;array.reverse()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have reversed the array.  No parameters, we just want all values in the array in reverse order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The join method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join" rel="noopener noreferrer"&gt;array.join()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This methods connects all values in an array together.  If a string parameter is passed in then the characters are joined together with the string between each value.  We passed in '' so we join the values with no space or characters between them as a string.&lt;/p&gt;

&lt;p&gt;So we chained all those methods and what do we have now?&lt;/p&gt;

&lt;p&gt;We have the original string reversed!&lt;/p&gt;

&lt;p&gt;Ex. original string = apple, reversed string = elppa&lt;/p&gt;

&lt;p&gt;The last thing we do is return the boolean value of checking if the original string is exactly equal to the reverse string.  If they are the same we return true if not then we return false. &lt;/p&gt;

&lt;p&gt;And that is it!  Thanks for hanging in there, I will try to be concise but I want to provide links to methods and my reasoning for doing things in as clear a way as possible!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
