<?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: emmacohanim</title>
    <description>The latest articles on DEV Community by emmacohanim (@emmacohanim).</description>
    <link>https://dev.to/emmacohanim</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%2F904986%2Ffa354050-68ed-404c-a6db-41379e41beea.png</url>
      <title>DEV Community: emmacohanim</title>
      <link>https://dev.to/emmacohanim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emmacohanim"/>
    <language>en</language>
    <item>
      <title>Reflections</title>
      <dc:creator>emmacohanim</dc:creator>
      <pubDate>Fri, 28 Oct 2022 19:41:44 +0000</pubDate>
      <link>https://dev.to/emmacohanim/reflections-54k4</link>
      <guid>https://dev.to/emmacohanim/reflections-54k4</guid>
      <description>&lt;p&gt;The past four months have been a WHIRLWIND. Over the course of my time in Flatiron's Software course, I learned so much and met many incredible people. Read on to hear more about my experience with Flatiron.&lt;/p&gt;

&lt;p&gt;I'll start off by talking about why I chose to do a tech bootcamp. My introduction to programming was somewhat unconventional. It occurred early on in my life and accidentally while playing the computer game MarbleBlast Gold. I had completed all of the levels and wanted a new challenge, so, at ten years old, I turned to the internet in hopes of finding additional levels. I unfortunately did not find any new levels, but I did find a Youtube tutorial demonstrating how to modify the levels that already existed. &lt;/p&gt;

&lt;p&gt;After following the tutorial, I had written my first lines of code. But I didn't know this at the time. All I knew was that I had typed some weird-looking words and symbols into a big black box, and had been able to customize the levels in my favorite game.&lt;/p&gt;

&lt;p&gt;Fast forward 10+ years, and I found myself feeling unchallenged at work. I missed using my brain to solve complex problems, and knew that no amount of crossword puzzling would fill that void. I learned about tech bootcamps from a family friend who had completed one, and I started looking into them. I took the plunge and enrolled at Flatiron after dipping my toe into the programming pool through some free courses, and I'm so glad that I did.&lt;/p&gt;

&lt;p&gt;Going into a tech bootcamp, I had some expectations and tons of questions. I knew that I would come out of the bootcamp with the ability to conceptualize, design, and build websites, but I really had no idea what that entailed. What was a backend? How did it communicate with a frontend? When would I start cracking cringey coding jokes? (The answer to that last one was two weeks in. What's a ghost's favorite data type? A BOOlean! Awful, I know)&lt;/p&gt;

&lt;p&gt;Now, four months later, I have answers to all of those questions and so many more. I learned that JavaScript can be vanilla, which I guess makes frameworks such as React spicy? And I learned that Semantic UI can be both a help and a hinderance. Most importantly, though, I learned which parts of the app-building process I enjoy most and which parts make me want to escape from reality by blasting pop-punk.&lt;/p&gt;

&lt;p&gt;Angst aside, I have enjoyed these past four months so much. I feel empowered and prepared to enter the job market, hiring freezes be damned. I plan to take the skills I gained over the past several months to a career focused on bridging the gap between tech and business, and I am excited to do so.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rails Generators</title>
      <dc:creator>emmacohanim</dc:creator>
      <pubDate>Mon, 10 Oct 2022 04:26:01 +0000</pubDate>
      <link>https://dev.to/emmacohanim/rails-generators-4o0h</link>
      <guid>https://dev.to/emmacohanim/rails-generators-4o0h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When building a rails application, we, as developers, must build the structure of our database as well as actions that allow the client to interact with our database and retrieve our data for the user. This requires us to create migrations, models, controllers, and routes. We can accomplish these tasks one of two ways: manually or using rails resource. Read on to learn about both of these methods and why developers generally prefer to use the second method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Method
&lt;/h2&gt;

&lt;p&gt;In order to build our rails application, we first must create our migration. We can do so by cding into our application and entering the following in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g migration manual_method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have our migration, we must build our table by specifying our attribute names and data types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ManualMethod &amp;lt; ActiveRecord::Migration[7.0]
  def change
    create_table :manual_methods do |t|
      t.string :attribute_1
      t.integer :attribute_2

  end
end

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

&lt;/div&gt;



&lt;p&gt;Now that we have structured our table, we need to create the schema for our database. We can do so by migrating our new migration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With our table created, we can turn our attention to creating our model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g model manual_method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to our migration, schema, and model, we will also need a controller to hold our actions as well as a resource route that our front end can send requests to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g controller manual_methods controller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
    resources :my_resources
    # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whew, that's done. Now, imagine that we have an application with multiple models. In that case, we would need to repeat this entire tedious process for each of those models. Sounds like a lot of work, right? Well, it doesn't have to be. Thanks to rails' handy-dandy generate resource task, we can focus on the functionality of our application while rails handles the creation of our resources under the hood!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resource Method
&lt;/h2&gt;

&lt;p&gt;Let's utilize the rails g resource task to achieve the same end result as in our previous example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g resource resource_method attribute_1 attribute_2:integer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rails will now do the work of creating our migration, model, controller, and resource routes. Pretty cool!&lt;/p&gt;

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

&lt;p&gt;Once our migration has been created, we can see that it contains our attribute names and data types. All that's left for us to do is send our migration up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Rails g resource is a powerful tool for developers to utilize as it streamlines the process of building our database structure. Thanks to the work that rails does under the hood, we can spend less time structuring our database and more time working on the functionality of our application.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>programming</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Breaking Down Variable Types in Ruby</title>
      <dc:creator>emmacohanim</dc:creator>
      <pubDate>Mon, 19 Sep 2022 08:47:31 +0000</pubDate>
      <link>https://dev.to/emmacohanim/breaking-down-variable-types-in-ruby-1609</link>
      <guid>https://dev.to/emmacohanim/breaking-down-variable-types-in-ruby-1609</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;There are four types of variables in Ruby: local variables, global variables, instance variables, and class variables. With so many variable types to choose from, it can be difficult to know which type should be used when assigning values to variables in Ruby code. Read on to learn about the behaviors and constraints of these different types of variables.&lt;/p&gt;

&lt;h1&gt;
  
  
  What are sigils?
&lt;/h1&gt;

&lt;p&gt;Sigils are special characters attached to the beginning of some Ruby variables to indicate the variable's type. The two sigils you will encounter in Ruby code are @ and $. We use the @ sigil to identify instance variables and class variables. In Ruby code, @ indicates that the type of variable we have encountered is an instance variable, while the appearance of @@ indicates that we are dealing with a class variable. We can use the other sigil, $, to identify global variables in our code.&lt;/p&gt;

&lt;h1&gt;
  
  
  Local Variables
&lt;/h1&gt;

&lt;p&gt;Local variables in Ruby are variables that are defined within a local scope. This scope can be within a class, module, or method. Local variables can begin with a lowercase letter or underscore. Because local are only defined in the local scope, these variables can only  be used within their class, module, or method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_method
    variable_type = "local"
    puts "This method accesses a #{variable_type} variable!"
end

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

&lt;/div&gt;



&lt;h1&gt;
  
  
  Global Variables
&lt;/h1&gt;

&lt;p&gt;Global variables are variables that are defined within the global scope. These variables can be used and accessed anywhere within an application. This type of variable is preceded by a $. Global variables are convenient as they can be used to allow one class, method, or module in your application to easily access the value of a variable defined within another without the use of props. Although global variables may seem simple, they can result in unwanted complexities in your code and should therefore be used with caution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_method
    $variable_type = "global"
end

def other_method_in_application
    puts "This method accesses a #{variable_type} variable!"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Instance Variables
&lt;/h1&gt;

&lt;p&gt;Instance variables are variables that act on a particular instance within a class. As mentioned above, these variables begin with the @ sigil. The example below illustrates the initialization of instance variables within a class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass
    def initialize(instance_variable, other_instance_variable)
        @instance_variable = instance_variable
        @other_instance_variable = other_instance_variable
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Class Variables
&lt;/h1&gt;

&lt;p&gt;Class variables are variables that act on an entire ruby class. As described above, we can use two @ sigils to indicate that we are dealing with a class method. The example below demonstrates the initialization of class variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass
    def initialize
        @@class_variable = class_variable
        @@other_class_variable = other_class_variable
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;When deciding which type of variable to utilize in your Ruby program, it is important to consider two things. First of all, we must take into account which part(s) of our application will need to access our variable.  Second, we must ask ourselves whether or not we would like the value of our variable to be consistent throughout our program. In general, it is best practice to avoid the use of global variables and instead utilize local variables. Additionally, sigils allow us to easily identify our variable types as global, instance, or class variables.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>beginners</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Reacting to Big Div Energy</title>
      <dc:creator>emmacohanim</dc:creator>
      <pubDate>Mon, 29 Aug 2022 05:22:52 +0000</pubDate>
      <link>https://dev.to/emmacohanim/reacting-to-big-div-energy-41hf</link>
      <guid>https://dev.to/emmacohanim/reacting-to-big-div-energy-41hf</guid>
      <description>&lt;p&gt;React makes creating complex, interactive applications a relatively pain-free process. It accomplishes this by straying from Vanilla JavaScript's use of imperative programming, which requires developers to tell JavaScript both &lt;em&gt;what&lt;/em&gt; to render and &lt;em&gt;how&lt;/em&gt; to render it. React utilizes declarative programming to handle the how of rendering under the hood, which leaves developers free to focus on what an app can do.&lt;/p&gt;

&lt;p&gt;Like most good things though, React's convenience comes at a price, and that price is pedantry. React holds developers to high syntactical standards, and, in exchange, it does the dirty work on the DOM side. If its standards are not met, React will complain by raising an error. Let's consider the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyBrokenComponent() {
    return (
        &amp;lt;h1&amp;gt;Beware!&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;I will return an error&amp;lt;/p&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we are telling React to return a &lt;code&gt;h1&lt;/code&gt; element and a &lt;code&gt;p&lt;/code&gt; element when &lt;code&gt;MyBrokenComponent&lt;/code&gt; is rendered by its parent component. This will result in the following error:&lt;/p&gt;

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

&lt;p&gt;This error is telling us that React cannot render a component with more than one parent element. We are getting this error because React requires that return statements be wrapped in a parent element, and the return statement above does not meet this requirement. Let's look at another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyOtherBrokenComponent() {
    return (
        &amp;lt;p&amp;gt;Try again!&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;I will also return an error&amp;lt;/p&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example will result in the same syntax error as our previous example. Although our return statement only contains one &lt;em&gt;type&lt;/em&gt; of element, &lt;code&gt;p&lt;/code&gt;, it still contains two elements, and thus fails to meet React's one-parent standard. Let's examine an example that will not return an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyWorkingComponent() {
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;You're in the clear!&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;I will not return an error&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is apparent when comparing our error-free component to previous examples that &lt;code&gt;MyWorkingComponent&lt;/code&gt; has something the others lack: one parent element. In this case, as in many others, that parent element is a &lt;code&gt;div&lt;/code&gt;. Wrapping elements within one parent element enables React to make sense of our declarative statements, and using &lt;code&gt;div&lt;/code&gt;s is an easy for developers to ensure that React's syntactical needs are being met.&lt;/p&gt;

&lt;p&gt;While &lt;code&gt;div&lt;/code&gt;s are a useful tool for repairing syntax, they are not the only one we as developers have at our disposal. Let's consider the two examples below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyDivlessComponent() {  
    return &amp;lt;p&amp;gt;I will not return an error either!&amp;lt;/p&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyHappyComponent() {
    &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;Divs&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;keep&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;React&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;happy!&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our first component, &lt;code&gt;MyDivlessComponent&lt;/code&gt;, has a working return statement but no &lt;code&gt;div&lt;/code&gt;. How can this be? Well, a &lt;code&gt;div&lt;/code&gt; is just one example of a parent component. The key to following React's strict syntax rules is to keep everything in the return statement contained inside of one box, or parent element. In the case of &lt;code&gt;MyDivlessComponent&lt;/code&gt;, our parent element is a &lt;code&gt;p&lt;/code&gt; element without any child elements. On the other hand, &lt;code&gt;MyHappyComponent&lt;/code&gt; contains 4 child elements, and thus requires a parent element to be wrapped around those children.&lt;/p&gt;

&lt;p&gt;Learning the ins and outs of a new framework can be tricky, but &lt;code&gt;div&lt;/code&gt;s provide developers with an easy fix to one of React's most common errors. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>innerHTML v. innerText</title>
      <dc:creator>emmacohanim</dc:creator>
      <pubDate>Mon, 08 Aug 2022 02:29:00 +0000</pubDate>
      <link>https://dev.to/emmacohanim/innerhtml-v-innertext-1047</link>
      <guid>https://dev.to/emmacohanim/innerhtml-v-innertext-1047</guid>
      <description>&lt;p&gt;If you've ever found yourself unsure whether to use &lt;code&gt;.innerHTML&lt;/code&gt; or &lt;code&gt;.innerText&lt;/code&gt;, you're not alone! Distinguishing between the two is something that many beginning developers struggle with when attempting to manipulate the DOM. Read on to learn about the differences between the two properties and why seasoned developers approach innerHTML with caution.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;.innerHTML&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;InnerHTML is a JavaScript property that allows developers to dynamically manipulate an element's HTML information within the DOM. This property can be used to set an element's inner text, &lt;em&gt;but it can also be used to set attributes and provide formatting instructions&lt;/em&gt;. Let's look at the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const div = document.createElement("div")
div.innerHTML = "&amp;lt;p id="p1" class="paragraph"&amp;gt;innerHTML is a powerful tool!&amp;lt;/p&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we are using &lt;code&gt;document.createElement&lt;/code&gt; to create a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element. We then use innerHTML to tell JavaScript to create a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element with the id "p1" within our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. We are also using innerHTML to set the text content of our newly-created &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;When our page loads, the innerHTML property will allow JavaScript to recognize everything that we would like to include in our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. JavaScript will render &lt;code&gt;innerHTML is a powerful tool!&lt;/code&gt; as "innerHTML is a powerful tool!"&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;.innerText&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;InnerText is a JavaScript property that enables developers to dynamically manipulate an element's inner text information within the DOM. This property can be used to set an element's inner text content, but it cannot be used to set attributes or provide formatting instructions. Let's revisit our example above using innerText.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const div = document.createElement("div")
const p = document.createElement("p")
div.append(p)
p.id = "p1"
p.className = "paragraph"
p.innerText = "innerHTML is a powerful tool!"

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

&lt;/div&gt;



&lt;p&gt;Here, we are using &lt;code&gt;document.createElement&lt;/code&gt; to create both a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element and a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element. We then use &lt;code&gt;div.append&lt;/code&gt; to append our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element to our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element and &lt;code&gt;p.id&lt;/code&gt; to set the id of our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element. Finally, we are using innerText to set the text content of our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;When our page loads, &lt;code&gt;innerHTML is a powerful tool!&lt;/code&gt; will be rendered as "innerHTML is a powerful tool!".&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison
&lt;/h2&gt;

&lt;p&gt;You may notice that our innerText example accomplished the same goal as our innerHTML example but required a few more steps to do so. Let's explore why this is the case. &lt;/p&gt;

&lt;p&gt;In our innerHTML example, we used innerHTML to create a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element, set its class and id, append it to our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, and set our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;'s text content. Because we used innerHTML to create our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; directly within our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, we did not need to use &lt;code&gt;div.append&lt;/code&gt; as we did in our innerText example.&lt;/p&gt;

&lt;p&gt;Similarly, we used innerHTML to set the class name and id of our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; value by placing these attributes directly inside our &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag as they would appear in an HTML file. Because of this, we did not need to use &lt;code&gt;p.id&lt;/code&gt; or &lt;code&gt;p.className&lt;/code&gt; as we did in our innerText example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;We have seen how innerText and innerHTML can be used to manipulate the DOM. We have also seen the limitations of the innerText property and explored why this property requires extra steps when compared the innerHTML property. Now, let's discuss why developers do not always opt for the use of innerHTML.&lt;/p&gt;

&lt;p&gt;As we have learned, innerHTML has the unique ability to create elements and set attributes. Unfortunately, it can just as easily remove them, whether you want it to or not! Remember, &lt;strong&gt;innerText&lt;/strong&gt; &lt;em&gt;only modifies the text content of an element&lt;/em&gt;, but &lt;strong&gt;innerHTML&lt;/strong&gt; &lt;em&gt;modifies an element's inner text, child nodes, and attributes.&lt;/em&gt; Because of this, it is important to exercise caution when using innerHTML and to opt for innerText when you are unsure where your data is coming from.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
    </item>
  </channel>
</rss>
