<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sid Saythongphet</title>
    <description>The latest articles on DEV Community by Sid Saythongphet (@sid_saythongphet).</description>
    <link>https://dev.to/sid_saythongphet</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%2F774106%2F2e57ab74-21bf-4084-b7a2-21bec71366c3.jpeg</url>
      <title>DEV Community: Sid Saythongphet</title>
      <link>https://dev.to/sid_saythongphet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sid_saythongphet"/>
    <language>en</language>
    <item>
      <title>React Context Hook</title>
      <dc:creator>Sid Saythongphet</dc:creator>
      <pubDate>Wed, 07 Dec 2022 00:05:26 +0000</pubDate>
      <link>https://dev.to/sid_saythongphet/react-context-hook-4ppb</link>
      <guid>https://dev.to/sid_saythongphet/react-context-hook-4ppb</guid>
      <description>&lt;p&gt;React Context is a vital tool that allows for easy sharing of data throughout your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is React Context?
&lt;/h2&gt;

&lt;p&gt;React Context is a method in which data can be shared without having to manually pass down props through several nested children components.&lt;/p&gt;

&lt;p&gt;From reactjs.org&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Context provides a way to pass data through the component tree without having to pass props down manually at every level.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  When to use React Context?
&lt;/h2&gt;

&lt;p&gt;Context is best used when sharing data that is considered "global."&lt;/p&gt;

&lt;p&gt;Some examples may include:&lt;/p&gt;

&lt;p&gt;User authentication&lt;br&gt;
User settings&lt;br&gt;
Language&lt;br&gt;
Themes&lt;/p&gt;

&lt;p&gt;React Context helps us solve the problem of &lt;strong&gt;prop drilling&lt;/strong&gt;, a term used to describe when props are passed down through multiple levels of components.&lt;/p&gt;

&lt;p&gt;Let's look at an example of this. Here, we have some data living in ComponentA and we need that data passed to ComponentD.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ComponentA = () =&amp;gt; {
    const [data, setData] = useState("")
    return (
        &amp;lt;ComponentB data={ data } /&amp;gt;
    )
}

const ComponentB = ({ data }) =&amp;gt; {
    return (
        &amp;lt;ComponentC  data={ data } /&amp;gt;
    )
}

const ComponentC = ({ data }) =&amp;gt; {
    return (
        &amp;lt;ComponentD  data={ data } /&amp;gt;
    )
}

const ComponentD = ({ data }) =&amp;gt; {
    return (
        &amp;lt;h1&amp;gt;"Hello World!"&amp;lt;/h1&amp;gt;
        &amp;lt;h1&amp;gt;{ data }&amp;lt;/h1&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, data is being passed at each level, but is not actually used in the middle components. This process can be tedious.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using React Context
&lt;/h2&gt;

&lt;p&gt;When using React Context, we must do three things: create, provide, and consume.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a new file that uses &lt;code&gt;createContext&lt;/code&gt; and exports a &lt;code&gt;Provider&lt;/code&gt; wrapper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { createContext, useState } from 'react'

export const Context = createContext()

export const ContextProvider = ({ children }) =&amp;gt; {
    const [data, setData] = useState({})

        return (
                &amp;lt;ContextProvider.Provider value={{ data }} &amp;gt;
                        { children }
                &amp;lt;/ContextProvider.Provider&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within our provider wrapper, we are able to pass a value prop that will contain our data.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Provide&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we have our context created, lets add it to our example.&lt;br&gt;
To do this, we will have to import the provider to one level above the consuming component. In this case, ComponentD only needs the data, so we have to import our provider to ComponentC.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

import { ContextProvider } from './Context'
import { ComponentD } from './ComponentD'

const ComponentC = () =&amp;gt; {
        return (
                &amp;lt;ContextProvider&amp;gt;
                        &amp;lt;ComponentD /&amp;gt;
                &amp;lt;/ContextProvider&amp;gt;
        )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Consume&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And finally, we can now consume the data in ComponentD by using the &lt;code&gt;useContext&lt;/code&gt; hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useContext } from 'react'

import { Context } from './Context'

const ComponentD = () =&amp;gt; {
        const { data } = useContext(Context)
    return (
        &amp;lt;h1&amp;gt;"Hello World!"&amp;lt;/h1&amp;gt;
        &amp;lt;h1&amp;gt;{ data }&amp;lt;/h1&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that is it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Context can be a great tool to use for supplying child components with global data, regardless of how deeply they are nested.&lt;/p&gt;

</description>
      <category>web3</category>
    </item>
    <item>
      <title>Phase 4 project</title>
      <dc:creator>Sid Saythongphet</dc:creator>
      <pubDate>Fri, 08 Apr 2022 20:56:41 +0000</pubDate>
      <link>https://dev.to/sid_saythongphet/phase-4-project-22nh</link>
      <guid>https://dev.to/sid_saythongphet/phase-4-project-22nh</guid>
      <description>&lt;p&gt;Working on my phase 4 project for the Flatiron School has really opened up my eyes to the complexity of creating a fullstack application. From designing the front end with React.js, to creating an API using Ruby on Rails and integrating the use of Amazon Web Service S3, I was pleasantly surprised to see how it all worked together. And I know I have only touched the surface of it all with it all still being new to me.&lt;/p&gt;

&lt;p&gt;One of the things I had to spend some time on for this project was the associations. I had worked with the one-to-many and many-to-many relationships between multiple tables before in my previous project, but this time around, I found myself needing to implement a relationship between a table and its self.&lt;/p&gt;

&lt;p&gt;For this project I had a User table which, each user was able to follow another user. In accomplishing this relationship, I approached it by creating a join table for the relationship, which I named Followship.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails g resource Followship follower_id:integer followee_id:integer&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In creating this table, I added the attributes follower_id, indicating the user that was doing the following, and followee_id, indicating the user that was being followed. Then before migrating this table to my database, I added indexes for each of the attributes, as well as making a specific follower_id, followee_id combinating index unique to prevent duplicate followship relationships. My migration ended up looking like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateFollowships &amp;lt; ActiveRecord::Migration[7.0]
  def change
    create_table :followships do |t|
      t.integer :follower_id
      t.integer :followee_id

      t.timestamps
    end
    add_index :followships, :follower_id
    add_index :followships, :followee_id
    add_index :followships, [:follower_id, :followee_id], unique: true
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After migrating, I moved to my Followship model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Followship &amp;lt; ApplicationRecord
  belongs_to :follower, foreign_key: 'follower_id', class_name: 'User'
  belongs_to :followee, foreign_key: 'followee_id', class_name: 'User'

  validates :follower_id, presence: true
  validates :followee_id, presence: true
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, I indicated the two belongs_to associations since this was a joins table. Unlike joining a table to another table, I had to add a couple of other options. Because :follower and :followee are not models in themselves, I had to include a class_name attribute that indicated what table to look push from, in this case the User table. I need assigned which column in my followship table it cooresponded with.&lt;/p&gt;

&lt;p&gt;Once that was set up, I had to move on to my user model to incorporate the has many relationships.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ApplicationRecord

  has_many :followships, dependent: :destroy

  has_many :passive_followships, foreign_key: :followee_id, class_name: 'Followship', dependent: :destroy
  has_many :followers, through: :passive_followships

  has_many :active_followships, foreign_key: :follower_id, class_name: 'Followship', dependent: :destroy
  has_many :followees, through: :active_followships

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

&lt;/div&gt;



&lt;p&gt;In setting up my associations in the User model, I created the connection between the two tables. I then created two seperate associations, one indicating the current users followers (:passive_followship) and the other indicating the users the current user is following (:active_followship). Similar to the Followship model, I used the class_name to specify the Followship table and also specifying the foreign_key. I was then able to make a direct relationship between the user and their followers with &lt;code&gt;has_many :followers, through: :passive_followships&lt;/code&gt; and a direct relationship between the user and who they follow with &lt;code&gt;has_many :followees, through: :active_followships&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hooray!&lt;/p&gt;

&lt;p&gt;This process did take me some time to wrap my head around, but I enjoyed the journey. Working through the project for the last couple of weeks has had its ups and downs, but I feel accomplished with the work I have been able to do thus far!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Third Project Blog</title>
      <dc:creator>Sid Saythongphet</dc:creator>
      <pubDate>Fri, 25 Feb 2022 21:58:15 +0000</pubDate>
      <link>https://dev.to/sid_saythongphet/third-project-blog-45a4</link>
      <guid>https://dev.to/sid_saythongphet/third-project-blog-45a4</guid>
      <description>&lt;p&gt;In this post we will be talking about what got me through my third project at the Flatiron School. Before starting on this phase, my coding knowledge was pretty limited to the frontend. I enjoyed my time with JavaScript and even more so with React. I've found myself truly engaged in the process of learning how to code and my interest continued to grow even more during this phase as we delve into the backend. We were starting to learn a new language, and that language was Ruby.&lt;/p&gt;

&lt;p&gt;So what is Ruby?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ruby is...&lt;br&gt;
A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.&lt;br&gt;
Source: &lt;a href="https://www.ruby-lang.org/en/"&gt;https://www.ruby-lang.org/en/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For me, I enjoyed Ruby a lot. The code looked cleaner and the syntax seemed easier to read. At first, I thought I would dread not being able to see how my code was working in a browser, but I found that I actually enjoyed just having the tools to just run my code in my terminal. It also gave me a different incite on debugging.  To be honest, I am not particularly fond of the debugger tool in JavaScript, and I mostly just added a console.log in whenever I needed to check stuff out. However, with Ruby's "Pry" gem, I quickly made a new best friend.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pry is a runtime developer console and IRB alternative with powerful introspection capabilities. Pry aims to be more than an IRB replacement. It is an attempt to bring REPL driven programming to the Ruby language.&lt;br&gt;
Source: &lt;a href="https://github.com/pry/pry"&gt;https://github.com/pry/pry&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I found myself using “binding.pry” a lot in my project. It helped me in creating my models, figuring out how to generate my seed data, and establishing my routes.&lt;/p&gt;

&lt;p&gt;One example was when I was trying to find a join table instance based on the ids of its two belongs to tables.  In doing so I first created a get route to play around with the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get ‘/users_clubs/user_:user_id/club_:club_id’ do
binding.pry 
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then booted up my Postman and made a request to the address. This then opened up a repl for me to check what my params where. I had my params and I went to figuring out the proper syntax to find my UserClub instance where both the user_id and club_id matched my params. After a few tries, I found ...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[2] pry(main)&amp;gt; UserClub.where(['user_id=? and club_id=?', 1, 1])
D, [2022-02-27T15:31:55.728583 #1719] DEBUG -- :   UserClub Load (3.8ms)  SELECT "user_clubs".* FROM "user_clubs" WHERE (user_id=1 and club_id=1)
=&amp;gt; [#&amp;lt;UserClub:0x000055a72e43ca58 id: 11, user_id: 1, club_id: 1, created_at: 2022-02-25 17:45:26.001501 UTC, updated_at: 2022-02-25 17:45:26.001501 UTC&amp;gt;]
[3] pry(main)&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I found what I was looking for, however it still wasn't coming out just right for my request. I continued to figure out what I was missing and it turned out to be that it was returning an array, which meant I needed to pull just one index of the array. so I adjusted my code &lt;code&gt;UserClub.where(['user_id=? and club_id=?', params[:user_id], params[:club_id]])[0]&lt;/code&gt; and successfully got my delete route to work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delete '/users_clubs/user_:user_id/club_:club_id' do
    @user_club = UserClub.where(['user_id=? and club_id=?', params[:user_id], params[:club_id]])[0]
    @user_club.destroy
    @user_club.to_json(include: [:user, :club])
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This continued for a lot of my progress during this project and made the process of finding out how everything could connect fun. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Journey to My Second Project</title>
      <dc:creator>Sid Saythongphet</dc:creator>
      <pubDate>Wed, 02 Feb 2022 20:12:10 +0000</pubDate>
      <link>https://dev.to/sid_saythongphet/the-journey-to-my-second-project-2mk2</link>
      <guid>https://dev.to/sid_saythongphet/the-journey-to-my-second-project-2mk2</guid>
      <description>&lt;p&gt;Another month, another project! This time, we strayed away from regular JavaScript and dove into React! And my &lt;em&gt;REACTion&lt;/em&gt; to that was pure bliss! From the first introduction to components, I was &lt;em&gt;hooked&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;With React, we are creating components in which we can nest other components in like Russian dolls. We then can pass "props" from a parent to a child.&lt;/p&gt;

&lt;p&gt;The type-A persona in me was so happy to be able to have a way to organize my code into sections and then to be able to reuse it multiple times. And lets not forget how much cleaner the code looks. Take the following example of creating a button the normal way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const createButton = (name, id) =&amp;gt; {
    const btn = document.createElement('button')
    btn.id = id
    btn.innerText = name
    return btn
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, in React:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Button({ id, text }) {
    return(
        &amp;lt;button id={ id }&amp;gt;{ text }&amp;lt;/button&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simpler to read and understand the end result. Bonus, less to write out too. And don't get me started on the redundancy of creating an element and assigning attributes to lets say a form! I really loved the process of using React!&lt;/p&gt;

&lt;p&gt;Now this time around, with the idea of having a hierarchy for which my components resided in, I felt I had a little more control in organizing my thoughts and ideas. With this new control, I decided to actually map out my brainstorming ideas. Which led me to...&lt;/p&gt;

&lt;p&gt;An introduction to the world of mind mapping. Of course I have always brainstormed, but most of that never actually made it onto page. It was all in my head which I would say "I'll remember for later"... Yeah, I never remembered. So, as I initiated the thought process into my project this time around, I decided I should first sit down and download a mind mapping software. That turned out to be XMind. Once in, I started just writing away my ideas. And boy did this process help. It aided tremendously to visualize my idea and see how everything worked, separately and together. I loved seeing how my app hierarchy branched out and to see how each of my components worked together. It made figuring out where my state lived, where my requests to my API were being handled, and where my props needed to be passed down to. To also gave me a bit more confidence into exploring external APIs, which being the superhero fanatic that I am, I chose to use the Marvel API.&lt;/p&gt;

&lt;p&gt;With the help of mind mapping, figuring out how to incorporate an external API was easier. I was able to pinpoint where I needed to pull requests and how to integrate it into my own RESTful API. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0tRh07pt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fcbm6vypr5ldi9p5hcf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0tRh07pt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fcbm6vypr5ldi9p5hcf.jpg" alt="Mind Map" width="880" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From this map, I was able to start up a mock editor and just play around and see what worked and what didn't. I troubleshooted how to work with an external API, how my components worked with each other, and how I wanted the general style to look. &lt;/p&gt;

&lt;p&gt;Once I felt ready with my ideas and had a clearer understanding of how the whole thing was put together, I opened up my command line and...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DEr1InXe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40jl1cmr0i3btvvlevvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DEr1InXe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40jl1cmr0i3btvvlevvk.png" alt="Marvel Project Search" width="880" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>First Project</title>
      <dc:creator>Sid Saythongphet</dc:creator>
      <pubDate>Wed, 12 Jan 2022 18:17:25 +0000</pubDate>
      <link>https://dev.to/sid_saythongphet/first-project-2pma</link>
      <guid>https://dev.to/sid_saythongphet/first-project-2pma</guid>
      <description>&lt;p&gt;A month ago I started on an endeavor, to become a Software Engineer. I had no experience in coding before making this decision, but the idea had always intrigued me. Little did I know, this was going to be quite the knowledge overload! However, after the last four weeks, and still knowing I have a long way to go, I feel like I can get a hang of this! &lt;/p&gt;

&lt;p&gt;I began this process by joining the Flatiron Flex Software Engineer Bootcamp in mid December, where we have been mainly focused on JavaScript for this first phase. Looking back, I had no idea what I was getting into. Functions, arrays, objects, and methods had no context to me. The complexity of running an application began to unfold.&lt;/p&gt;

&lt;p&gt;For my first project, I created a single-page website for journaling. Now with this journaling application, I wanted to take into consideration the Two Minute Rule, which I became familiarized with after reading "Atomic Habits" by James Clear. With this rule stating a new habit shouldn't take more than 2 minutes to do, this website takes that into account and binds you to journal for only a few short minutes.&lt;/p&gt;

&lt;p&gt;What originally started out as an interactive page that would include a timer, text input, and a collection of past entries, became a far more complex puzzle that I thoroughly enjoyed solving. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6-FvPDip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksj5sh0pdlq105u9z4ix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6-FvPDip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksj5sh0pdlq105u9z4ix.png" alt="Screenshot of journal page of project" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6m5WJLUr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qdefzlyk17x82ghleot5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6m5WJLUr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qdefzlyk17x82ghleot5.png" alt="Screenshot of entries page of project" width="880" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It amazed me how many different ways the code could be constructed to build a functioning webpage. As I continued to work on it, I found different ways to write a code to eliminate the redundancy. I particularly became fond of the use of functions to reduce repetition. In the beginning, for example, I was doing things such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const secOne = document.createElement('section')
secOne.id = 'section-one'
secOne.className = 'col s12'
const secTwo = document.createElement('section')
secTwo.id = 'section-two'
secTwo.className = 'col s12'
const secThree = document.createElement('section')
secThree.id = 'section-three'
secThree.className = 'col s12'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This process became time consuming, but was easily fixed by making a function that took in some arguments!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const createSection = (id, className) =&amp;gt; {
    const section = document.createElement('section')
    section.id = id
    section.className = className
    return section
}

const secOne = createSection('section-one', 'col s12')
const secTwo = createSection('section-two', 'col s12')
const secThree = createSection('section-three', 'col s12')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helped tremendously to clean my code and I know there may be even better ways to refactor the code for simplicity, but it was a really good feeling to know all the learning from the last month was starting to click.&lt;/p&gt;

&lt;p&gt;Once I knew I was getting more comfortable working with functions and arguments, the project process continued faster than before. I began to try different ways of writing my existing code. It became even more interesting to refactor the code than it was to write it the first time!&lt;/p&gt;

&lt;p&gt;Now that I am at a point that I believe my first project is complete, I am eager to work on my next! The future is looking bright for this new adventure I am on and hope to soak up as much knowledge I can! &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>firstpost</category>
    </item>
  </channel>
</rss>
