<?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>Forem: Cristal </title>
    <description>The latest articles on Forem by Cristal  (@cristalcodes).</description>
    <link>https://forem.com/cristalcodes</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%2F277931%2Faf78b06c-44f1-4831-8125-ace24a84f617.jpeg</url>
      <title>Forem: Cristal </title>
      <link>https://forem.com/cristalcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cristalcodes"/>
    <language>en</language>
    <item>
      <title>Responsive Web Design</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 20 Jul 2020 05:07:43 +0000</pubDate>
      <link>https://forem.com/cristalcodes/responsive-web-design-13a1</link>
      <guid>https://forem.com/cristalcodes/responsive-web-design-13a1</guid>
      <description>&lt;p&gt;Hi friends! I'm back! It's been a little busy with my internship but I'm happy to report that I AM still working on my Front End Developer Blueprint from Skillcrush. &lt;/p&gt;

&lt;p&gt;I covered a little bit of Flexbox today and got some good labs in. I learned a few technical things, of course, but also realized that while rote memorization is impractical, rote &lt;em&gt;practice&lt;/em&gt;  is totally helpful. Both of today's labs involved doing the same thing- the first time totally guided and the second unguided. I feel like I'll be more likely to remember how to do what I learned just because I did it twice in a row. &lt;/p&gt;

&lt;p&gt;Anyway, you may just be here to learn with me, so let's get to business. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Flexbox?
&lt;/h2&gt;

&lt;p&gt;Flexbox is a collection of CSS properties that is designed around the idea of having two planes- one vertical and the other horizontal. Think x and y axes! &lt;/p&gt;

&lt;p&gt;(I know you're having an "Oh, &lt;em&gt;this&lt;/em&gt; is when I'd use geometry in real life" moment.)&lt;/p&gt;

&lt;h2&gt;
  
  
  What does Flexbox allow us to do?
&lt;/h2&gt;

&lt;p&gt;Flexbox allows us position not only the content within a tag, but tags themselves. It allows us to arrange our elements as we'd like! &lt;/p&gt;

&lt;h2&gt;
  
  
  How do I turn it on?
&lt;/h2&gt;

&lt;p&gt;Give your HTML the following property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;display&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;flex&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and BAM! It's ready for use. &lt;/p&gt;

&lt;h2&gt;
  
  
  What properties do I need to use Flexbox?
&lt;/h2&gt;

&lt;p&gt;Well...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;flex-direction&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;column&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/*this property will create a vertical axis*/&lt;/span&gt;
  &lt;span class="nt"&gt;flex-direction&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;row&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/* creates a horizontal axis */&lt;/span&gt;
  &lt;span class="nt"&gt;justify-content&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
    &lt;span class="c"&gt;/* tells the content where it should be aligned on *main* axis */&lt;/span&gt;
    &lt;span class="c"&gt;/* possible values:*/&lt;/span&gt;
      &lt;span class="nt"&gt;flex-start&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="c"&gt;/* aligns things on the left if horizontally aligned or at the top if vertically aligned.*/&lt;/span&gt;
      &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* centers, of course */&lt;/span&gt;
      &lt;span class="nt"&gt;flex-end&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c"&gt;/*aligns an element on the right of the page if horizontally aligned, or the bottom of the page if vertically aligned*/&lt;/span&gt;
      &lt;span class="nt"&gt;space-between&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/*items aligned across the container with an even amount of space in between each one*/&lt;/span&gt;
      &lt;span class="nt"&gt;space-around&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/*elements have an event amount of space before, between, and after each element*/&lt;/span&gt;
      &lt;span class="nt"&gt;initial&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/*uses whatever the default value is*/&lt;/span&gt;
      &lt;span class="nt"&gt;inherit&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/*takes on the position of the parent element*/&lt;/span&gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then there are the ones you'll use for the cross-axis!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;align-items&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="c"&gt;/*same as justify-content except on a different axis*/&lt;/span&gt;
    &lt;span class="c"&gt;/*Possible values: */&lt;/span&gt;
      &lt;span class="nt"&gt;flex-start&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="nt"&gt;flex-end&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="nt"&gt;center&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="nt"&gt;initial&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="nt"&gt;inherit&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="c"&gt;/* ...and add */&lt;/span&gt;
      &lt;span class="nt"&gt;baseline&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* positions items at the container's baseline*/&lt;/span&gt;
      &lt;span class="nt"&gt;stretch&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="c"&gt;/* stretched an element vertically to fit the container */&lt;/span&gt;

  &lt;span class="nt"&gt;align-content&lt;/span&gt; &lt;span class="c"&gt;/* has the same effect as justify-content, but only if that content is wrapped. Will have no effect otherwise! */&lt;/span&gt;

  &lt;span class="nt"&gt;flex-wrap&lt;/span&gt; &lt;span class="c"&gt;/* dictates if elements should wrap or not */&lt;/span&gt;
    &lt;span class="c"&gt;/* Possible values: */&lt;/span&gt;
      &lt;span class="nt"&gt;wrap&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* tells items to wrap */&lt;/span&gt;
      &lt;span class="nt"&gt;nowrap&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* the opposite of the above */&lt;/span&gt;
      &lt;span class="nt"&gt;wrap-reverse&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* wraps items in a reverse order */&lt;/span&gt;
      &lt;span class="nt"&gt;inherit&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nt"&gt;initial&lt;/span&gt; &lt;span class="c"&gt;/* same as before! */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&amp;amp;&amp;amp; that's all for today on the TL;DR version of what I'm learning. If you care to see it in action, you can take a look at my last two labs &lt;a href="https://github.com/cristalcodes/flexbox-starter"&gt;here&lt;/a&gt; &amp;amp; &lt;a href="https://github.com/cristalcodes/customized-flexbox-starter"&gt;here&lt;/a&gt;. I've been committing every step as I walk through these labs, so you can actually see what happened when and what effect it had. &lt;/p&gt;

&lt;p&gt;Happy Coding! &lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Responsive Websites: Typography!</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Sun, 12 Jul 2020 06:36:36 +0000</pubDate>
      <link>https://forem.com/cristalcodes/responsive-websites-typography-3o94</link>
      <guid>https://forem.com/cristalcodes/responsive-websites-typography-3o94</guid>
      <description>&lt;p&gt;Hey friends! &lt;/p&gt;

&lt;p&gt;So I was heading over to write something up on responsive typography when I realized that my writing style is totally TL;DR. &lt;/p&gt;

&lt;p&gt;I'm not here to pretend I'm an expert. I am, like many of you, blogging to learn and share those learnings. Thus, I'll leave the big kahuna explanations to the pros and no doubt the plethora of existing resources. &lt;/p&gt;

&lt;p&gt;Full disclosure: I'm currently learning about front-end web development through Skillcrush's Front-End Developer Blueprint and most of these learnings come from their fab course! &lt;/p&gt;

&lt;p&gt;Now without further ado...&lt;/p&gt;

&lt;h2&gt;&lt;u&gt;Font basics:&lt;/u&gt;&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Make sure your text is easy to read- never size anything smaller than 16px. Didn't define the font size in your stylesheets? Most browsers will have a default size of 16px!&lt;/li&gt;
&lt;li&gt;Keep the line length between 45-75 characters in length.&lt;/li&gt;
&lt;li&gt;Use black text on white backgrounds, or even dark grey, for better readability. &lt;/li&gt;
&lt;li&gt;Keep fancy fonts to a minimum! &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;&lt;u&gt;Pixels, ems, and rems, oh my!&lt;/u&gt;&lt;/h2&gt;

&lt;p&gt;Now, if you're like me, you probably had no idea that there was any other way to define your font sizes besides pixels. It turns out there are SO many more, but for now we'll only cover the most common three. &lt;/p&gt;

&lt;h3&gt;1. The Pixel&lt;/h3&gt;

&lt;p&gt;A pixel is fixed and does not scale. It's computed value is the same regardless of the context in which it occurs. In other words, it's pretty static. Not exactly what we want for a responsive site.&lt;/p&gt;

&lt;h3&gt;2. The em&lt;/h3&gt;

&lt;p&gt;Em's are pretty neat because they are &lt;em&gt;scaled&lt;/em&gt; units of measure. &lt;/p&gt;

&lt;p&gt;1em is the equivalent of the font-size set on the parent element of the current element. &lt;/p&gt;

&lt;p&gt;So if your site's base font-size is 16px:&lt;br&gt;
1em = 16px&lt;br&gt;
2em = 32px&lt;br&gt;
3em = 48px&lt;/p&gt;

&lt;p&gt;This means that if you know you want your h1 to be 2, 3, 4 times bigger than your paragraph fonts, for example, you would just set H1 elements to 2, 3, 4 ems. &lt;/p&gt;

&lt;p&gt;BUT WATCH OUT! Nesting elements can have an unexpected effect on your sizes. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;  &lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"greeting"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello World!&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you can see I've nested an h1 within a div with a class of greeting. So what happens when I do this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nc"&gt;.greeting&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3em&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;You might expect everything in our greeting div to be 32px in size, with the exception of our h1s, which would be 48px in size. &lt;/p&gt;

&lt;p&gt;Instead, our h1s are actually 96px in size! WHAT?!?&lt;/p&gt;

&lt;p&gt;Well, em's are based on the &lt;em&gt;parent&lt;/em&gt; element. Because our h1's parent is the div with the class, "greeting", it's 1em was actually 32px. &lt;/p&gt;

&lt;p&gt;32px * 3= 96px&lt;/p&gt;

&lt;p&gt;You get it, right? So, handy, but can sometimes be problematic. &lt;/p&gt;

&lt;p&gt;Which brings us to...&lt;/p&gt;

&lt;h3&gt;3. The rem&lt;/h3&gt;

&lt;p&gt;Okay, the rem is pretty neat, but before I tell you about how great it is, know that it's not supported on Internet Explorer 8 or below. &lt;/p&gt;

&lt;p&gt;With that out of the way, let me tell you why the rem is great. &lt;/p&gt;

&lt;p&gt;While em's are based on the font-size of the parent container, an rem is based on the &lt;em&gt;root&lt;/em&gt; element of the document and its size. &lt;/p&gt;

&lt;p&gt;So in our example above, we could skip the headache by just changing ems to rems. &lt;/p&gt;

&lt;h2&gt;&lt;u&gt;That's all, folks&lt;/u&gt;&lt;/h2&gt;

&lt;p&gt;I hope this was just the right length to be informative but not pedantic! If you have any questions, comments, suggestions, please reach out to me any ol' time :)&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Responsive Websites: Media Queries </title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 06 Jul 2020 02:32:49 +0000</pubDate>
      <link>https://forem.com/cristalcodes/responsive-websites-media-queries-37ph</link>
      <guid>https://forem.com/cristalcodes/responsive-websites-media-queries-37ph</guid>
      <description>&lt;p&gt;Hi friends! &lt;/p&gt;

&lt;p&gt;Today I want to tell you a little bit about media queries! Let's keep it short and simple as usual, yes?&lt;/p&gt;

&lt;h1&gt;
  
  
  What is a media query?
&lt;/h1&gt;

&lt;p&gt;THIS is a media query:&lt;br&gt;
&lt;/p&gt;
&lt;center&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lMZ9xx9U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mjtdge24ki2ss685a6hg.png" alt="Alt Text"&gt;&lt;/center&gt;

&lt;p&gt;Simple looking, right? &lt;/p&gt;

&lt;p&gt;Our media queries specify what css to display in a browser given a device's specific dimensions. It gives our browser information about the device a user is on, the width of that device, and the orientation of the device, amongst other things. &lt;/p&gt;

&lt;p&gt;Without specifying a type of media like say, "print" or "screen", the query will default to "All". Read about more media query types &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries"&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;h1&gt;
  
  
  What goes in a media query?
&lt;/h1&gt;


&lt;center&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ka8WT3qA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/m09ff75ogjgrdkic7xae.png" alt="Alt Text"&gt;&lt;/center&gt;

&lt;p&gt;As you can see, we create the @media rule, add the query type, and then specify widths. Not all media queries will include both a min and max width, but notice that you can specify different conditions using logical operators. &lt;/p&gt;
&lt;h1&gt;
  
  
  What does this mean for mobile-first design?
&lt;/h1&gt;

&lt;p&gt;Well, this means that you should design websites mobile-first, and then use media queries to size up your sites, not down. &lt;/p&gt;

&lt;p&gt;*tablets: use a min-width of 768px. &lt;br&gt;
*desktops: use a min-width of 1200px&lt;/p&gt;

&lt;p&gt;These are pretty good standards according to Skillcrush. &lt;/p&gt;
&lt;h1&gt;
  
  
  DON'T FORGET
&lt;/h1&gt;

&lt;p&gt;Don't forget to include the following line of code in the head tag of your html!&lt;/p&gt;


&lt;center&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XQxfBxO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w6qa7b4h9acmjem1boq8.png" alt="Alt Text"&gt;&lt;/center&gt;

&lt;p&gt;It is the HTML5 method that allows us to control the size of the viewport, or the user's visible screen, and gives it instructions for the width and scale. Read more about it &lt;a href="https://www.w3schools.com/css/css_rwd_viewport.asp"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Care to see an example of media queries in action? &lt;/p&gt;

&lt;p&gt;Tada!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Gotham&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Helvetica&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Arial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#7b7d70&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#4eafb8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ff8641&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;




&lt;span class="c"&gt;/***** TABLETS *****/&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#02cbd2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fcc02a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#7b8f8e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="c"&gt;/***** DESKTOPS *****/&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1200px&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#6e4b61&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#cabd61&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#c19e74&lt;/span&gt;&lt;span class="p"&gt;;&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;This CSS is written mobile first, which is why we don't specify the widths for viewport widths smaller than 768px. Then, we create a note in our CSS to separate sections for tablets and desktops. Notice the min widths, as well as the lack of a media query type.&lt;/p&gt;

&lt;h1&gt;
  
  
  That's all, folks!
&lt;/h1&gt;

&lt;p&gt;As always, feel free to comment, critique, and make suggestions! Happy coding!&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>design</category>
    </item>
    <item>
      <title>Learning About: Building Responsive Websites</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 29 Jun 2020 01:47:24 +0000</pubDate>
      <link>https://forem.com/cristalcodes/learning-about-building-responsive-websites-53lm</link>
      <guid>https://forem.com/cristalcodes/learning-about-building-responsive-websites-53lm</guid>
      <description>&lt;p&gt;I'm currently learning about designing and coding responsive websites. &lt;/p&gt;

&lt;p&gt;To get a good understanding of what a responsive website is, it's pretty important to understand what a responsive website &lt;em&gt;isn't&lt;/em&gt;. Or, in other words, it's important to understand what &lt;em&gt;other&lt;/em&gt; types of websites exist and that we interact with. &lt;/p&gt;

&lt;h2&gt;
  
  
  3 types of non-responsive websites:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Static: &lt;br&gt;
These websites are designed for desktops and desktops only, and are built with a fixed width. We want to avoid building these as much as possible!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fluid: &lt;br&gt;
These websites are, well, fluid. All websites are fluid if you don't specify a width, actually. Fluid sites work on all devices and if widths are specified, they are done so in percentages as opposed to pixels. The thing to note here is that the layout never changes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adaptive: &lt;br&gt;
Adaptive sites, you guessed it, adapt to the width of their device. The hitch? Widths have to be specified for EVERY. SINGLE. DEVICE. Which means that you need different stylesheets for EVERY. SINGLE. DEVICE. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Responsive Websites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Are a fabulous combination of easily maintained fluid websites with user optimized adaptive websites. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine the ability to specify widths in percentages and also declare minimum widths in pixels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use media queries to specify sizes, and can coexist in the same stylesheet. SCORE! &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next up: Media Queries &lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>A Dev Newbie Refocuses</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Sun, 28 Jun 2020 23:50:26 +0000</pubDate>
      <link>https://forem.com/cristalcodes/a-dev-newbie-refocuses-3ie7</link>
      <guid>https://forem.com/cristalcodes/a-dev-newbie-refocuses-3ie7</guid>
      <description>&lt;h1&gt;
  
  
  Hi Reader,
&lt;/h1&gt;

&lt;p&gt;I've been thinking a lot lately about who I want to be and what I envision making of my life as a developer. When I decided to switch gears from the world of nutrition and health research I only knew one thing: I wanted to code. &lt;/p&gt;

&lt;p&gt;So I went to a bootcamp, put in the hours, graduated, and just recently emerged onto the job market. &lt;/p&gt;

&lt;p&gt;I thought the the quickest and most effective way to land a job fast would be to deepen my skills in Ruby and Rails given that those were the focus of my software engineering immersive. I gathered the best resources I could find and took off to the races. &lt;/p&gt;

&lt;h2&gt;Here's what actually happened:&lt;/h2&gt;

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

&lt;p&gt;As you can see, I had a pretty steady cadence going on between October of 2019 and March of 2020. There are a few gaps during the holidays, but on the whole I held pretty steady in github contributions. &lt;/p&gt;

&lt;p&gt;It was in late March that I decided to focus on Ruby and Rails, and as you can see I didn't make a whole lot of progress. Why?&lt;/p&gt;

&lt;h2&gt;
  
  
  I wasn't interested
&lt;/h2&gt;

&lt;p&gt;Did I love the challenge of back-end programming? Absolutely. Solving logic-based problems provided me with hits of adrenaline... But I learned from my time in the program that I didn't want to be an algorithm master. And yet, here I was trying to force myself to love it and consequently getting nowhere. &lt;/p&gt;

&lt;p&gt;Have you ever done things you knew you hated and were against your own best interest but for some reason you persevered after them because your brain said you had to? That was me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then a tweet saved my life.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RuVVURiK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/64qn1f21aershiadvzu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RuVVURiK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/64qn1f21aershiadvzu8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seriously, this tweet was the best thing that could have happened for me. I read it and found myself giving myself permission to just do what I want. I gave myself permission to go out and seek out joy and not just employment. &lt;/p&gt;

&lt;p&gt;I won't say it wasn't difficult. Having committed to an income share agreement for my 15k tuition at my coding bootcamp, I carried a lot of guilt about my decision to not pursue a job in the technical skills I had learned during my program. I wallowed in my &lt;a href="https://www.behavioraleconomics.com/resources/mini-encyclopedia-of-be/sunk-cost-fallacy/"&gt;sunk cost fallacy &lt;/a&gt; for a little while, even. &lt;/p&gt;

&lt;h2&gt;
  
  
  But unemployment can't go on forever.
&lt;/h2&gt;

&lt;p&gt;Having been out of the workforce for a while, I felt time clipping away at my heels. I had to do something, but I was back at square one it seemed. How does one become a front-end developer without proficiency in HTML, CSS, and JS? You can't. &lt;/p&gt;

&lt;p&gt;So I pulled out the Skillcrush Front-End Developer course I bought SIX MONTHS prior to starting my bootcamp and got to work. I'm currently learning about responsive web design, and I couldn't be any happier. &lt;/p&gt;

&lt;p&gt;I also started looking into internships that didn't require any experience so that I could start doing on the job learning. I'm lucky enough to have found one, and I'm excited to see where it goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  And that's where I am now.
&lt;/h2&gt;

&lt;p&gt;There's so much I need to learn and a whole lot more to grow as a developer. I try not to beat myself up about it- I've only been coding for 10 months, and only just three weeks ago gave myself permission to follow the beat of my own drum instead of following what everyone else says is best for me. &lt;/p&gt;

&lt;p&gt;It's going to be worth it. &lt;/p&gt;

&lt;h2&gt;
  
  
  So expect front-end content content from me moving forward.
&lt;/h2&gt;

&lt;p&gt;I'll definitely be going back to my Ruby course at some point to make sure I hold on to the technical skills I do already have, but that's not where the bulk of my energy will be going. &lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;br&gt;
-Cristal&lt;/p&gt;

&lt;p&gt;Up next: Responsive Web Design&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>html</category>
    </item>
    <item>
      <title>Hosting on Github Pages: A Quick and Short How To</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Thu, 18 Jun 2020 22:43:28 +0000</pubDate>
      <link>https://forem.com/cristalcodes/hosting-on-github-pages-a-quick-and-short-how-to-3cgj</link>
      <guid>https://forem.com/cristalcodes/hosting-on-github-pages-a-quick-and-short-how-to-3cgj</guid>
      <description>&lt;p&gt;So you have a website that only uses HTML, CSS, &amp;amp; JS? What an exciting time to be alive, you can host your site straight to Github without spending a dime! &lt;/p&gt;

&lt;p&gt;The main benefit is that you don't have to worry about buying a domain name and setting up your hosting site. If you've pushed your project up to Github, you've already done the bulk of the work! &lt;/p&gt;

&lt;p&gt;Ready to see how easy this is? &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a new branch
&lt;/h2&gt;

&lt;p&gt;In your terminal (command line), cd your way into your project directory (folder). Once there, create a new branch by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; gh-pages 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You &lt;em&gt;must&lt;/em&gt; name your branch gh-pages in order for this to work correctly. &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Push to origin
&lt;/h2&gt;

&lt;p&gt;Next, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin gh-pages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Verify it worked!
&lt;/h2&gt;

&lt;p&gt;Go to your repo on Github and click on the 'Branch' dropdown. You should see gh-pages there now! &lt;/p&gt;

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

&lt;h2&gt;
  
  
  4. Visit your site
&lt;/h2&gt;

&lt;p&gt;In your browser, head over to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;your-user-name.github.io/repo-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Et voila! Your site! &lt;/p&gt;

&lt;p&gt;Happy Coding! &lt;/p&gt;

</description>
      <category>github</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Ruby Gotcha #1</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Wed, 10 Jun 2020 23:14:27 +0000</pubDate>
      <link>https://forem.com/cristalcodes/ruby-gotcha-1-4p09</link>
      <guid>https://forem.com/cristalcodes/ruby-gotcha-1-4p09</guid>
      <description>&lt;p&gt;Hi dev friend! &lt;/p&gt;

&lt;p&gt;Today I want to tell you about how I recently started The Complete Ruby on Rails Developer Course on Udemy, by Mashrur Hossain and Rob Percival. I'm aiming to deepen my the knowledge I obtained at Flatiron School, and strengthen the concepts that I feel comfortable with. &lt;/p&gt;

&lt;p&gt;If you're looking to do the same, I'm happy to report that I will be taking notes as I progress through the course, and plan to upload them to Github. What I want to do right now, though, is share that first Ruby Gotcha! I've run into. &lt;/p&gt;

&lt;h2&gt;
  
  
  Ruby Gotcha #1: The difference between pass-by-reference and pass-by-value
&lt;/h2&gt;

&lt;p&gt;In general, according to the instructor: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"In Ruby, if a variable is pointing to another variable, it's actually pointing the location in memory the variable is pointing to." &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--odgFDxjx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zc714t1s9wt68oo44w2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--odgFDxjx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zc714t1s9wt68oo44w2m.png" alt='Image of code snippet that shows a variable "name" assigned to the string "Cristal", a new variable "new-name" assigned to the variable "name", and a reassignment of the variable "name"'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you weren't aware of this gotcha, you might think that the variable "new_name" now points to "Joe". Here's what happens instead: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JFcAZ86Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/81dlfr6wgw0qyr1c10q3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JFcAZ86Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/81dlfr6wgw0qyr1c10q3.png" alt='Image of code snippet that shows name evaluating to "Joe" and new_name evaluating to "Cristal"'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The new_name variable is still pointing to that location in memory that holds the string "Cristal". Is your mind blown? Mine was! &lt;/p&gt;

&lt;h3&gt;
  
  
  It starts to get tricky once you actually start passing that variable around into methods. Let's take a look at that!
&lt;/h3&gt;

&lt;h4&gt;
  
  
  pass-by-reference
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;In Ruby, dynamic variables that can change in size are passed-by-reference, as in the location in memory. This means strings, arrays, and hashes. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By passing these variables around to methods using their reference, we are able to mutate them. &lt;/p&gt;


&lt;center&gt;!!!IMPORTANT NOTE!!!&lt;/center&gt;
&lt;br&gt;
Remember that mutation is different from reassignment! &lt;br&gt;
Here's what happens if you pass in a &lt;em&gt;mutable&lt;/em&gt; variable to a method and then reassign it: 

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

&lt;p&gt;As you can see, name is still pointing to "Cristal" in memory. &lt;/p&gt;

&lt;p&gt;But if we &lt;em&gt;mutate&lt;/em&gt; the string, here's what happens:&lt;/p&gt;

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

&lt;p&gt;"name" is pointing that spot in memory, but because we mutated the string, it is now permanently "Cristal Moz"&lt;/p&gt;

&lt;h3&gt;
  
  
  pass-by-value
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Static variables- meaning that they don't change in size and are immutable- can be passed around as the actual value, instead of their reference. These include integers, fixnum, floats, and booleans. So let's look at an example...&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1vkAGdoD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydz9a0ufs8nfjp9eprvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1vkAGdoD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydz9a0ufs8nfjp9eprvh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, when we pass previous_age to the birthday method, it returns what we expect, &lt;em&gt;but the value of previous age does not change&lt;/em&gt;. We cannot mutate an integer, fixnum, float, or boolean so that space in memory will always and forever point to that value. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pretty neat and pretty confusing, right?
&lt;/h2&gt;

&lt;p&gt;Maybe you're feeling like I did- you're thinking "WHAT?" In some of these scenarios, I thought the variable would be the same and then in others I thought it would be different. It helps to open up your terminal, get IRB going, and practice! Try passing different variable types around and seeing what happens! &lt;/p&gt;

&lt;h2&gt;
  
  
  Have a comment, question, suggestion?
&lt;/h2&gt;

&lt;p&gt;Please reach out, I don't bite! &lt;/p&gt;

</description>
      <category>ruby</category>
    </item>
    <item>
      <title>OOP Fundamentals: What is an Object ? </title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 08 Jun 2020 05:23:22 +0000</pubDate>
      <link>https://forem.com/cristalcodes/oop-fundamentals-what-is-an-object-429g</link>
      <guid>https://forem.com/cristalcodes/oop-fundamentals-what-is-an-object-429g</guid>
      <description>&lt;p&gt;Hello again, reader and fellow Dev. If you've been here before, you know I've been a Flatiron School student for the last few months. It's been some time since I wrote a piece here on dev.to, but I'm back at it now, writing blogs as an alumn! &lt;/p&gt;

&lt;p&gt;I'm actively job hunting at the moment and so it's a great time to review some foundational concepts that will certainly be asked about during the interview process. &lt;/p&gt;

&lt;p&gt;Today, we'll start at the beginning... &lt;/p&gt;

&lt;h1&gt;
  
  
  Why objects?
&lt;/h1&gt;

&lt;p&gt;Objects, as you might guess, are incredibly important in Object Oriented Programming, otherwise known as OOP. They're important because by creating objects we eliminate the need to write redundant and repetitive code. When we create an object it can be called from anywhere within a program instead of having to be recreated every time it is needed. &lt;/p&gt;

&lt;h3&gt;
  
  
  What are objects, and what do objects have?
&lt;/h3&gt;

&lt;p&gt;Objects are the basic units of object-oriented programs and have two basic things- state and behaviors. &lt;/p&gt;

&lt;p&gt;The state reflects that objects current state, which is stored in variables. The behaviors associated with that object are typically called methods, and can be called on that object. &lt;/p&gt;

&lt;p&gt;A simple example would be your car. As an object, it has a current state- it can be on, running, or off. Some methods you might be able to call on your car object would be things like:&lt;br&gt;
turnOn(); drive(); reverse(); and so on.&lt;/p&gt;

&lt;p&gt;The most important thing about objects is that they are little packages of information. An object knows its own properties and carries its methods with it. Unlike procedural programming, where a variable is declared and a function is written separately from it, in object-oriented programming we are able to call methods on the object itself. Additionally, having objects makes it possible for objects to interact with &lt;em&gt;other&lt;/em&gt; objects. &lt;/p&gt;

&lt;h3&gt;
  
  
  Next up: Classes. See you soon!
&lt;/h3&gt;

</description>
      <category>oop</category>
    </item>
    <item>
      <title>A CLI Project Built With Love </title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Sat, 04 Apr 2020 06:46:53 +0000</pubDate>
      <link>https://forem.com/cristalcodes/title-4c07</link>
      <guid>https://forem.com/cristalcodes/title-4c07</guid>
      <description>&lt;h6&gt;
  
  
  This post was imported from my Medium account, which I will be taking down shortly!
&lt;/h6&gt;

&lt;p&gt;I know what you're thinking- "the title says "CLI Data Project… where's the code"?&lt;br&gt;
I promise we will get there, but every story starts at the beginning.&lt;br&gt;
You're looking at Duchess. She's been up for adoption for the last 43 weeks and no one knows why. I've been following her on Instagram for months now, and every single day that passes is another day I wish that I could take her in.&lt;br&gt;
I often spend my time thinking about her, half hoping no one has adopted her so I can adopt her myself, half hoping her picture will stop appearing in my timeline, signifying that she's found a new home.&lt;br&gt;
This project is dedicated to her.&lt;br&gt;
If code is supposed to solve real world problems, maybe this small work of love will get Duchess into a home where she can love and be loved.&lt;br&gt;
If you'd like to learn more about Duchess and her canine pals, and/or learn about how Paws4Life K9 Rescue also saves lives by helping prison inmates receive sentence commutations, please visit &lt;a href="https://pawsforlifek9.org/"&gt;https://pawsforlifek9.org/&lt;/a&gt;&lt;br&gt;
And now to our scheduled program.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;The Setup:
Getting my local environment ready for the project was ground zero. Many students have used the Bundler gem to create a project repository, but I found it produced many unnecessary files for my project's purpose. I chose to configure my files manually.
My project folder includes a bin folder that houses my executable file(dogs), and the config folder, which houses environment file.The environment file is home to all of the program's required files and gems. The gems must be downloaded onto the computer on which the program will run. From the command line (your terminal), you need only type:
gem install 
If you come across an error message that states that you do not have write permissions to install the gems (as I did), it is possible to solve the issue by instead typing the following into the terminal:
sudo gem install 
Lastly, I established a lib folder that holds each class in a separate file. It is important to separate them based on class responsibility. The CLI class handles the logic, the Dog class instantiates Dog objects, and the Scraper class scrapes the data that is handed to Dog objects to give them attributes.
Note: the initial setup involved only an executable file and the three class files. Once the word on those files was done, an environment file was added, and file dependencies were moved into their appropriate places.&lt;/li&gt;
&lt;li&gt;The Dog Class:
I started the project in the most logical place- creating dog objects. If the whole program is about showing what dogs are up for adoption, and giving the user information about them, it makes sense that we want to create them first, and then think about how to give them attributes.
Creating this model was pretty standard. Defined the class, gave it the ability to set and get (or write and read) attributes for each dog object (or instance), and provided a class variable @@all set to an array- so that the class can hold all of its dog objects. Each dog object saves itself to the array upon initialization, as defined by the initialize method. The class method self.all returns all of the dog objects with all of their attributes.
We will need to access the dog objects in our other classes.&lt;/li&gt;
&lt;li&gt;The Scraper Class
Our Scraper class "scrapes" the desired webpage to acquire the information that is necessary to the application. Recall that both the Nokogiri gem and Open-Uri gems are part of our program's requirements. Open-Uri allows the program to open the url as if it were a file, while Nokogiri grants the ability to parse HTML and XML. Without these, our program is unable to obtain the information that we need for our program!
As you can see, I have set the variable 'doc' to a url that is being opened as a file by open-uri and parsed with nokogiri. Now we can get to selecting what we need by using css selector methods. But how do we do that?
If you right click on a webpage and select "Inspect Element" in the drop down menu, you're given a set of developer tools to play with within the browser. There are two ways to approach the task of finding our selectors. The first is to press the cursor-in-box button at the top left hand corner of the developer tools pane, then using our cursor to float over the elements on the page. Our job is hard enough, so make your life easier by using the elements inspector in the developer tools pane. By moving the cursor over the element's css code, the element itself is highlighted on the page!
In the example above you can see how the first class "fl-post-grid" denotes the container for all of our dogs, and each dog is contained in the class "fl-post-column". So what can we do with this information? We can iterate.
The syntax:
What next? Let's make some dogs to pass the information to!
Line 7 makes a new dog object.
Line 8 gives our dog a name based on the information obtained from our scrape, while line 9 gets a short description, and 10 gets the profile url.
Neat! Those attributes were set. Is our dog holding on to those? You bet! Think back to our Dog class:
Our attr_accessors are both readers and writers. When we write:
doggo.name= dog.css('a').text.strip
.name isn't something magical that just gave the dog it's name.
It's a method! The attr_accessor :name is doing two things:
Setting/writing the name instance variable from the name variable that is being passed into the method:
def name=(name)
@name=name
end 
&amp;amp; getting/reading the name instance variable:
def name
@name 
end 
Magical, but not quite magic. The other attr_accessors function in this same way, setting instance variables in setting and getting methods that can be called upon in other parts of our program.
The rest of the scraper class follows the same process for gathering data passed to the dog object. We'll come back to the second method later, however, to demonstrate how the dog object that already existed is passed into it to set other object attributes.&lt;/li&gt;
&lt;li&gt;The CLI Controller
The CLI controller is responsible for controlling the program's logic, taking in user inputs, and presenting program outputs. The CLI controller does NOT scrape data, and does NOT give our dog objects any attributes.
Looking at this code (which will be refactored at some later point in time), it's obvious that it is styling that the end user sees.
sleep(x) produces a short delay so that not all output appears at all at once.
Series of underscores and dashes provide division to make it easier for the user to see and understand the information presented.
Scraper is called within the run method to get the information needed for the next method, list_dogs (which is established in the lower portion of this image).
The program outputs some instructions, and then takes an input, stripping it of whitespace- leading and trailing- and downcasing it (strange, but remember, our user is allowed to input strings as well as integers).
The while loop is established and given an If-Elsif statement to handle different input cases. Validations are put into place so that our program runs properly even if given an erroneous input (negative numbers, numbers that exceed the range, random strings).
As you can see, nothing is set by our CLI class, it merely calls upon other methods to run.
If you look closely enough, you might think- but what about the second scrape, Scraper.dog_details ? Aren't you setting something there?
Well… no. Here's what's happening:
Our program gets an input, and if that input converts to an integer between 1 and the length of our @@all dogs array (from our Dog class), it sets a local variable dog to Dog(the class).all(the dogs)[at the index which equals our users input, converted to an integer minus one(because arrays start at index 0)].
Then it scrapes dog details. Our program switches tasks and jumps from our CLI class, to our Scraper class.That dog variable (which, remember, is an object that was previously created), is handed to the Scraper class method dog_details . The urls are passed in as files, the html is parsed using nokogiri, and our passed in dog object is given it's attributes using attr_accessors. Magic? Magical.
The program executes this code, and jumps back to the CLI class, and continues to execute the rest of the program.
It's important to note that scraping a few times is fine, but excessive scraping can lead a website to block you. Make sure to scrape only once. Easy way to do this is to make sure that you are not including the scrape as part of a loop (as with the first scrape) or including a validation. Our scrape below only happens IF it hasn't happened once before.
Final Touches
The 'colorize' gem was installed and required by our program environment. Colorize gave the program a nice pop of color that makes the terminal less dull.
The config folder was created, and dependencies were moved to their appropriate places.
Here is the final product!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A special thank you to Nancy Noyes, our cohort lead for the Flatiron School Full-Time Online Software Engineering Program, for her extensive help, and to the Flatiron school for an incredible first module in the curriculum.&lt;br&gt;
Other honorable mentions: Stefanie Davis, Victoria Hale, and Huda Usif for their enduring support and willingness to critique, guide, and help as I moved through the process of building this project.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>oop</category>
    </item>
    <item>
      <title>Performance Review: React/Redux</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 30 Mar 2020 06:22:48 +0000</pubDate>
      <link>https://forem.com/cristalcodes/performance-review-react-redux-59ni</link>
      <guid>https://forem.com/cristalcodes/performance-review-react-redux-59ni</guid>
      <description>&lt;h1&gt;
  
  
  What's this about?
&lt;/h1&gt;

&lt;p&gt;I had my "final" project assessment, which covered React and Redux, this past Friday. I ran over the 45 minute timeframe, and will need to complete the remainder of the assessment early in the upcoming week.&lt;/p&gt;

&lt;p&gt;Rather than be upset about it, I thought I'd do the next best thing: analyze it. Here I'll be covering both the bright spots and the pain points, as well as giving the major highlights in the hopes that they might be helpful for you, fellow dev.&lt;/p&gt;

&lt;h1&gt;
  
  
  Lesson Learned #1
&lt;/h1&gt;

&lt;h4&gt;
  
  
  Demonstrate your understanding without becoming verbose.
&lt;/h4&gt;

&lt;p&gt;During my assessment, I was asked a simple question: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Why is dispatch so important in redux?&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;A simple question deserved a simple answer, something short and elegant: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;The dispatch function sends an action to the reducer.&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;If I wanted to get fancy, adding &lt;/p&gt;

&lt;p&gt;&lt;code&gt;it is the only way to trigger a state change,&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;would have been perfectly acceptable as well. Boom, done. That would have been a total of perhaps 10 seconds. My answer took much longer, and I found myself giving the snake legs, invariably turning it into a lizard when the assessor asked for a snake. &lt;/p&gt;

&lt;p&gt;Simply put, while I understood what dispatch did, I spoke so much that not only did it seem like I was speaking in the hopes that the right answer was somewhere in my explanation, but also so much that it appeared as if I did not know that answer at all. &lt;/p&gt;

&lt;p&gt;This happened several times during the assessment, which led to us running out of time. &lt;/p&gt;

&lt;p&gt;My assessor was kind enough to chalk it up to nerves. &lt;/p&gt;

&lt;h1&gt;
  
  
  Lesson Learned #2
&lt;/h1&gt;

&lt;h4&gt;
  
  
  Just because you made it work, doesn't really mean you understand WHY it works.
&lt;/h4&gt;

&lt;p&gt;Okay, so this lesson is one I learn time and time again. It's easy as a new developer to think you know why things are working simply because they do. In my case, I thought I fully understood the connect() function because I had used it. &lt;/p&gt;

&lt;p&gt;I knew, for example, that connect() &lt;em&gt;connects&lt;/em&gt; us to the store, which holds global state. &lt;/p&gt;

&lt;p&gt;I knew that the connect() function took in several optional parameters, the first being &lt;code&gt;mapStateToProps&lt;/code&gt;, the second &lt;code&gt;mapDispatchToProps&lt;/code&gt;, as well as two others that I haven't yet used, such as &lt;code&gt;mergeProps&lt;/code&gt; and &lt;code&gt;options&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I also knew that if a component did not need access to the store to pass state down to props, I'd need to pass in &lt;em&gt;null&lt;/em&gt; as the first parameter.&lt;/p&gt;

&lt;p&gt;What I &lt;em&gt;didn't&lt;/em&gt; fully understand was what was happening as I handed an action-creator function to connect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;getDecks&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../actions/decksActions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getDecks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mapStateToProps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;getDecks&lt;/span&gt;&lt;span class="p"&gt;})(&lt;/span&gt;&lt;span class="nx"&gt;GetterApp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I thought, and subsequently stated, was that I needed to pass &lt;code&gt;{getDecks}&lt;/code&gt; to connect to make it available for the component to use. &lt;/p&gt;

&lt;p&gt;Even though I knew that I had made the function available for use by importing at the top of the file, I thought that passing it to connect was the only reason I was able to use it. However, I could have called the function by simply writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;getDecks&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doing so wouldn't have required redux at all. It also wouldn't have worked.&lt;/p&gt;

&lt;p&gt;Passing the action creator function to connect made it possible to invoke the function by preceding &lt;code&gt;getDecks();&lt;/code&gt; with &lt;code&gt;this.props&lt;/code&gt;. It also, and most importantly, &lt;em&gt;bound the dispatch of the store TO the action creator.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;So here, in my action creator function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDecks&lt;/span&gt; &lt;span class="o"&gt;=&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;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dispatch&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="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;LOADING_DECKS&lt;/span&gt;&lt;span class="dl"&gt;"&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;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/decks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decks&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;DECKS_LOADED&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;decks&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;)&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;&lt;em&gt;I HAVE ACCESS TO DISPATCH BECAUSE IT WAS ACTUALLY BOUND TO THE FUNCTION&lt;/em&gt; . &lt;/p&gt;

&lt;h1&gt;
  
  
  Lesson Learned #3
&lt;/h1&gt;

&lt;h4&gt;
  
  
  Doubting yourself out loud is a major no-no.
&lt;/h4&gt;

&lt;p&gt;When my assessor asked me to guess the order that a few console.logs would be fired, the first words out of my mouth were something along the lines of "this is going to be difficult." &lt;/p&gt;

&lt;p&gt;While this thought spoken out loud helps me stay calm and promotes me taking a deep breath, it certainly doesn't inspire confidence. &lt;/p&gt;

&lt;p&gt;So this lesson was short- only think out loud to show your assessor how you work through a problem.&lt;/p&gt;

&lt;h1&gt;
  
  
  And finally, a bright spot in Lesson #4
&lt;/h1&gt;

&lt;h4&gt;
  
  
  Be proud of however far you make it
&lt;/h4&gt;

&lt;p&gt;It is SO easy and SO tempting to believe that you have to be right 100% of the time, to be afraid to make mistakes, to not want to say "I don't know." &lt;em&gt;Especially when you're in an assessment.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;But it's okay to make mistakes and say I don't know. Ultimately, the person on the other side is there to help you succeed either as a student, or an employee. No one wants to see you fail. &lt;/p&gt;

&lt;p&gt;By admitting the shortcomings in your understanding, or by giving a SUPER quick explanation of why you think something works even if you're wrong, you're making it possible for the person assessing you to steer you in the right direction, or simply to explain to you what part of the puzzle you're missing. &lt;/p&gt;

&lt;p&gt;And THAT is a win in everyone's book. &lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>rails</category>
      <category>ruby</category>
    </item>
    <item>
      <title>React/Redux Basics... In English</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Tue, 17 Mar 2020 01:40:13 +0000</pubDate>
      <link>https://forem.com/cristalcodes/react-redux-basics-in-english-3b9k</link>
      <guid>https://forem.com/cristalcodes/react-redux-basics-in-english-3b9k</guid>
      <description>&lt;p&gt;If you've stumbled across this blog post, it is quite likely that you are a Flatiron School student and are looking for examples of projects and/or blog posts. This particular post is intended to provided some general information that might help you understand some of the necessary concepts and components(pun intended).&lt;/p&gt;

&lt;p&gt;Friendly Reminder: it is normal to feel overwhelmed and/or anxious as you approach this and any project. You are not alone in this feeling, and it behooves you to reach out to classmates, your cohort lead, and/or your educational coach if you should ever feel this way. The Flatiron and general dev community is very supportive!&lt;/p&gt;

&lt;h1&gt;
  
  
  React
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Container vs. Functional Component
&lt;/h3&gt;

&lt;h5&gt;
  
  
  (AKA Stateful vs Stateless, respectively)
&lt;/h5&gt;

&lt;p&gt;You've likely heard all of these terms (if you're a Flatiron Student, you've read them all in the curriculum). &lt;/p&gt;

&lt;p&gt;Let there be no confusion- a container component simply has local state. A functional component, on the other hand, does not. &lt;/p&gt;

&lt;h5&gt;
  
  
  CONTAINER COMPONENT / STATEFUL
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;ContainerComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;someInfo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hi! I'm a stateful component! You can hand me props by writing something like this.props.yourPropName!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Being stateful makes me a "Container Component". Take away my state, and I'm a functional component.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It doesn't matter that I look different from the functional component below! &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;ContainerComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Functional Component / Stateless
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FunctionalComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hi! I'm a stateless component! You can hand me props by passing them into the arrow function!
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;FunctionalComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Local vs Global State
&lt;/h3&gt;

&lt;p&gt;Remember how a stateful component (container component) holds state? That is a "stateful component"... its state is &lt;em&gt;local&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Redux (which we'll get to in a moment) allows us to create &lt;em&gt;global state&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;What's the difference? Let's go back to our stateful component above...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./components/Button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;ContainerComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;showingButton&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;showButtons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;showingButtons&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;hideButtons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;showingButtons&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;onMouseEnter&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;showButtons&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onMouseLeave&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hideButtons&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hi! I'm a stateful component! You can hand me props by writing something like this.props.yourPropName!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Being stateful makes me a "Container Component". Take away my state, and I'm a functional component.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It doesn't matter that I look different from the functional component below! &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

//look here:
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;showingButtons&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
//
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;ContainerComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;this.state.showingButons ?&lt;/code&gt; is a ternary statement. If true, a button is displayed when the mouse scrolls over the div. If false, nothing is displayed but an empty string.&lt;/p&gt;

&lt;p&gt;The component itself has access to it's state BECAUSE IT EXISTS IN THE SAME PLACE. Much the way you have access to your own kitchen, your component has access to what's immediately available in its local state.&lt;/p&gt;

&lt;p&gt;So how do we get access to global state? What IS global state anyway? &lt;/p&gt;

&lt;h3&gt;
  
  
  Global State and Redux
&lt;/h3&gt;

&lt;p&gt;Redux allows us to create a global state &lt;em&gt;that every component has access to&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;If local state is the equivalent of you walking into your kitchen and going into your pantry, global state is the equivalent of you taking your grocery cart into the supermarket. &lt;/p&gt;

&lt;p&gt;To get access to a global store, we import createStore from react-redux. &lt;/p&gt;

&lt;p&gt;createStore takes in an argument, a reducer (or a root reducer that combines all your reducers.... one per resource). It accepts additional arguments, such as applyMiddleware, too. &lt;/p&gt;

&lt;h4&gt;
  
  
  What in tarnation is a reducer?
&lt;/h4&gt;

&lt;p&gt;A reducer is just a function, my dude. It has two arguments- a state, and an action. A switch statement is involved, and includes an action type, provided by dispatch (don't worry, we'll get to that, too). It looks a little something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;decks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;action&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;switch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;LOADING&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;LOADED&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ADD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ADDED&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;


    &lt;span class="nl"&gt;default&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;state&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;If you're thinking, "well, that's not that scary!" you're absolutely right! All you're doing is telling your application, "Hey! If you get this message (case), give me this thing, ok?" &lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Things out of Global State
&lt;/h3&gt;

&lt;p&gt;Let's think back to our first component, the stateful one. It had &lt;em&gt;local state&lt;/em&gt;. It could go into its pantry by stating &lt;code&gt;this.state.someInfo&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;What if you wanted access to THE store? Well, redux gives us access to the store by giving us connect, which is imported at the top of our file as so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importing connect, and then providing the connection when we &lt;em&gt;export&lt;/em&gt; the component...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mapStateToProps&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;YourAppName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and handing connect a first argument of mapStateToProps, which we can declare like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mapStateToProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;state&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;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resourceReducer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resouce&lt;/span&gt;&lt;span class="p"&gt;,&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;Now, in our component, we can call &lt;code&gt;this.props.resource&lt;/code&gt; and get whatever is in global state. It's like showing up at your house party with the groceries you just bought and yelling "CHECK OUT THIS.VONS.CHIPS&amp;amp;DIP". &lt;/p&gt;

&lt;h3&gt;
  
  
  How did we get to the point of getting global props?
&lt;/h3&gt;

&lt;p&gt;Okay, so this is where we come to both dispatch and reducers. Our store takes in an argument of a reducer, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our reducer is something that was imported and passed on to the createStore function provided by redux. &lt;/p&gt;

&lt;p&gt;As we saw, our reducer takes in an an initial state, and an action type. Where does this action type come from? &lt;/p&gt;

&lt;p&gt;Well, one way to get this is by creating an action creator function. It might look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resource&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;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dispatch&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="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ADD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;resource&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;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`/resources`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resource&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;return&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ADDED&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;})&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;If it looks confusing, just focus on the parts that matter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addResource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resource&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="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ADD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;resource&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;What you should be getting from this is: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;the function addResource is called, with an argument that accepts a resource. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;dispatch, given to us by redux, fires off a message (or action type), and a resource. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;our reducer takes the message, and the action ( a resource), and returns something to us. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mapStateToProps gives us access to whatever is returned by simply calling this.props.resource! &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The equivalent would be something like having a central market, with anyone and everyone in the area (components) being able to go into the store by using { connect }, {actionFunction}, and mapStateToProps. &lt;/p&gt;

&lt;p&gt;In other words, all these things come together to help you program an application where local state helps you deal with the here-and-now (local state) and the always(global state). &lt;/p&gt;

&lt;h3&gt;
  
  
  I still don't get it
&lt;/h3&gt;

&lt;p&gt;I feel you. If you're not sure how to get everything working together, build a simple application. Just get it to display things on the page. Use fun event handlers and state to get some fun effects. Practice makes better, after all! &lt;/p&gt;

</description>
      <category>rails</category>
      <category>react</category>
      <category>redux</category>
      <category>jsx</category>
    </item>
    <item>
      <title>Passing Data Around in Javascript</title>
      <dc:creator>Cristal </dc:creator>
      <pubDate>Mon, 17 Feb 2020 04:29:49 +0000</pubDate>
      <link>https://forem.com/cristalcodes/passing-data-around-in-javascript-hpf</link>
      <guid>https://forem.com/cristalcodes/passing-data-around-in-javascript-hpf</guid>
      <description>&lt;p&gt;If you've stumbled across this blog post, it is quite likely that you are a Flatiron School student and are looking for examples of projects and/or blog posts. This particular post is intended to provided some tips for getting through this project.&lt;/p&gt;

&lt;p&gt;Friendly Reminder: it is normal to feel overwhelmed and/or anxious as you approach this and any project. You are not alone in this feeling, and it behooves you to reach out to classmates, your cohort lead, and/or your educational coach if you should ever feel this way. The Flatiron and general dev community is very supportive!&lt;/p&gt;

&lt;h1&gt;
  
  
  The Project
&lt;/h1&gt;

&lt;p&gt;The purpose of this project is to take your Ruby on Rails knowledge, and add a layer of complexity to it by creating a one page application using Vanilla JS as opposed to ActionView. &lt;/p&gt;

&lt;h1&gt;
  
  
  Using fetch();
&lt;/h1&gt;

&lt;p&gt;So you've built your backend API, and upon running your server, you're successfully displaying json. Perfect! The next step is to retrieve this information. &lt;/p&gt;

&lt;p&gt;The boilerplate code for making this request is as follows:&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="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://example.com/movies.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;//Fetch takes in one argument here:&lt;/span&gt;
&lt;span class="c1"&gt;//the path whose resource we're trying to retrieve information from. &lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;response&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;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;//we are returned a promise that contains the response object. This is &lt;/span&gt;
&lt;span class="c1"&gt;//NOT the information we can use just yet. It is simply the HTTP &lt;/span&gt;
&lt;span class="c1"&gt;//response.&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;myJson&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myJson&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;//This second .then extracts the information we want from that HTTP &lt;/span&gt;
&lt;span class="c1"&gt;//response. &lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get a feel for the flow of information, we're going to go through the process of fetching information, creating an object from it (in this case, a pin), and then using that object's information to create a child object (a memory).  &lt;/p&gt;

&lt;p&gt;The models:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Pin&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
  &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:memories&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;dependent: :destroy&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Memory&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:pin&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is my API, displaying json rendered by my Rails application.&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="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;address&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;11 Broadway, New York, NY 10004&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;// Flatiron School &amp;lt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;latitude&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;40.7053111&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;longitude&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;74.0140526&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;What we see is that each pin is stored as an object in an array. Below, jsonData is returning this array, and .forEach is used to comb through each object key for its values below.&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="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;BASE_URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;jsonData&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//iterates through each location object &amp;amp; sets variables&lt;/span&gt;
      &lt;span class="nx"&gt;jsonData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;location&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pinId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pinLabel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;label&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pinLatitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;latitude&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pinlongitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;longitude&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="c1"&gt;//creates a pin using above variables&lt;/span&gt;
        &lt;span class="nx"&gt;pinInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pinId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pinLabel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;coords&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;lat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pinLatitude&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;lng&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pinlongitude&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;dropPin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pinInfo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//We're going to need this later. &lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  PASS THE DATA!
&lt;/h1&gt;

&lt;p&gt;We're going to pick up where we left off above. The last function called was dropPin, with an argument of the each pin that was created with data from the fetch function. &lt;/p&gt;

&lt;p&gt;Our pin is dropped (code redacted to focus on the important matter at hand - passing data). A dialogue box is created when a user clicks on the pin; one of the options is below.&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="c1"&gt;//Each pin carries the following:&lt;/span&gt;
&lt;span class="c1"&gt;//id, label, coords object(which include lat and lng)&lt;/span&gt;


    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;dropPin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;

    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;createMemoryForm(${pin.id});&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Add&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;Memory&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&amp;gt;&amp;lt;br&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say our location is Disneyland. We clicked on the pin, and now we want to jot down a memory for this location. The &lt;code&gt;onClick&lt;/code&gt; attribute in the link fires off &lt;code&gt;'createMemoryForm()'&lt;/code&gt;, with a passed in parameter of &lt;code&gt;${pin.id}&lt;/code&gt; (which holds the value of id for that location). Where does this function come from? &lt;/p&gt;

&lt;p&gt;You. It's you. You need to write the function. &lt;/p&gt;

&lt;p&gt;Let's do that.&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="nx"&gt;createMemoryForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pinId&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="c1"&gt;//First, we declare the function. We have it take in a parameter, and we &lt;/span&gt;
&lt;span class="c1"&gt;//name that parameter in a way that helps us remember what we're passing &lt;/span&gt;
&lt;span class="c1"&gt;//in. &lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The function createMemoryForm has been triggered. The form should be displayed below the map.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`This pin has an id of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;pinId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//I've logged my parameter and function namein the console for easy &lt;/span&gt;
&lt;span class="c1"&gt;//debugging!&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;contentContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content-container&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//grabbed the container I want to put my form in&lt;/span&gt;

    &lt;span class="nx"&gt;contentContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="s2"&gt;`
      &amp;lt;br&amp;gt;
      Add your memory to this location by filling out the form below:
      &amp;lt;br&amp;gt;
      &amp;lt;br&amp;gt;
      &amp;lt;form onsubmit="createAndDisplayMemory();return false;"&amp;gt;
        &amp;lt;label for="date"&amp;gt;Date (YYYY-MM-DD)&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input type="text" id="date"&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;label for="description"&amp;gt;Description:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input type="text-area" id="description" &amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;input type="hidden" id="pin_id" value=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;pinId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &amp;gt;
        &amp;lt;input type ="submit" value="Add Memory!"&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;/form&amp;gt;  `&lt;/span&gt;
   &lt;span class="c1"&gt;//created the form&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can you spot the handshake between our dropPin function and the createMemoryForm function? &lt;/p&gt;

&lt;p&gt;Let's do that again, but let's only grab the pieces we need.&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="c1"&gt;// in dropPin();&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;createMemoryForm(${pin.id});&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Add&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;Memory&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="c1"&gt;//clicking the link triggers createMemoryForm(); below and hands it pin.id (from above) &lt;/span&gt;

&lt;span class="c1"&gt;//in createMemoryForm(pinId)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onsubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;createAndDisplayMemory();return false;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;//focus on this next line! &lt;/span&gt;
&lt;span class="c1"&gt;//the pinId that was handed to this function by dropPin() is given to &lt;/span&gt;
&lt;span class="c1"&gt;//the hidden field with an id of "pin_id". &lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pin_id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;pinId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Add Memory!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user goes on and clicks submit. Where are we going &lt;code&gt;onClick&lt;/code&gt;? To &lt;code&gt;createAndDisplayMemory();&lt;/code&gt;! Again, we're going to break this function into several chunks to try and make it easier to understand. Try to spot the handshake!&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="nx"&gt;createAndDisplayMemory&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;contentContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content-container&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pin_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pin_id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;pin_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pin_id&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;Did you see it? Our form had included &lt;br&gt;
&lt;code&gt;&amp;lt;input type="hidden" id="pin_id" value=${pinId} &amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The following line of code grabs that value &lt;br&gt;
&lt;code&gt;let pin_id = document.getElementById('pin_id').value&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and then we use all the information from our form to create a memory object.&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;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;pin_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;pin_id&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;Do you see the critical piece? We grabbed &lt;code&gt;pin_id&lt;/code&gt;! What is &lt;code&gt;pin_id&lt;/code&gt; on our memory table? &lt;/p&gt;

&lt;h5&gt;
  
  
  A FOREIGN KEY!!!!!!!!!!!!
&lt;/h5&gt;

&lt;p&gt;What this means for us is that our memory will be sent to our database and given its own unique id. That memory will also know who it belongs to. Done over and over again, each new and unique memory will have a foreign key that corresponds to its has_many resource. Cool, right? &lt;/p&gt;

&lt;p&gt;Let's finish creating a memory for this pin.&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="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;BASE_URL&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/memories&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Accept&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&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 send a POST request, and hand our newly created memory to the body of the request : &lt;br&gt;
&lt;code&gt;body: JSON.stringify(memory)&lt;/code&gt;&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="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;contentContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;
    &lt;span class="nx"&gt;contentContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;br&amp;gt;
    Date: &amp;lt;br&amp;gt;
    &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    Description:&amp;lt;br&amp;gt;
     &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;br&amp;gt;
     &amp;lt;a href='#' onClick='editThisMemory(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)'; return false;&amp;gt;Edit this Memory&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
     &amp;lt;a href= "#" onClick= 'deleteThisMemoryWarning(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;);'&amp;gt; Delete Memory &amp;lt;/a&amp;gt;
    `&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we executed our remaining .then functions to return the newly created memory. We can expect to see that memory's date, and description. &lt;/p&gt;

&lt;p&gt;If you're reading closely, you'll also notice that we have two new links with onClick functions:&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;editThisMemory(${memory.id})&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Edit&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="nx"&gt;Memory&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;deleteThisMemoryWarning(${memory.id});&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Delete&lt;/span&gt; &lt;span class="nx"&gt;Memory&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each function is handed a memory id. Can you guess what happens next? &lt;/p&gt;

&lt;p&gt;.....&lt;/p&gt;

&lt;p&gt;We write those two functions, and continue the handshake, of course. &lt;/p&gt;

&lt;p&gt;Some hot tips: &lt;/p&gt;

&lt;h4&gt;
  
  
  HOT TIP 1
&lt;/h4&gt;

&lt;p&gt;When POSTing, PATCHing, DELETEing, you don't necessarily need to use the two .then's that are part of the boilerplate fetch code. Only use your .then's if you need data returned to you so that you can display it. &lt;/p&gt;

&lt;h4&gt;
  
  
  HOT TIP #2
&lt;/h4&gt;

&lt;p&gt;BUILD YOUR CODE AS YOU GO, AND GIVE VARIABLES SEMANTIC MEANING. &lt;/p&gt;

&lt;p&gt;Naming things in a way that is easy to read, and that simply makes sense, will save your life. Especially if you build the functions you need as you go. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;center&gt;&amp;amp;&amp;amp; that's all, folks! &lt;/center&gt;
&lt;/h3&gt;

&lt;p&gt;As always, thank you for reading, and please feel free to reach out with critiques, comments, suggestions, and/or questions. &lt;/p&gt;

&lt;p&gt;Keep it real, y'all! &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>javascript</category>
      <category>womenintech</category>
    </item>
  </channel>
</rss>
