<?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: kirthinandi</title>
    <description>The latest articles on DEV Community by kirthinandi (@kirthinandi).</description>
    <link>https://dev.to/kirthinandi</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%2F903501%2F15c3cc2a-13c5-4e30-a69d-b7d34c2f3c8c.png</url>
      <title>DEV Community: kirthinandi</title>
      <link>https://dev.to/kirthinandi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kirthinandi"/>
    <language>en</language>
    <item>
      <title>Displaying Validation Errors on Frontend (React &amp; Rails)</title>
      <dc:creator>kirthinandi</dc:creator>
      <pubDate>Fri, 28 Oct 2022 19:11:57 +0000</pubDate>
      <link>https://dev.to/kirthinandi/displaying-validation-errors-on-frontend-react-rails-3cp5</link>
      <guid>https://dev.to/kirthinandi/displaying-validation-errors-on-frontend-react-rails-3cp5</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1k2i2wbvsa1rpc4kkd38.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1k2i2wbvsa1rpc4kkd38.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Do you want to know how to display your validation errors on the frontend of your application? Then, follow along! If you have your backend set up properly, you should have a private method in your application controller that displays an object with the key, errors. It should look something 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 ApplicationController &amp;lt; ActionController::API
    rescue_from ActiveRecord::RecordInvalid, with: :invalid

...

private 

def invalid(e)
    render json: { errors: e.record.errors.full_messages }, 
    status: :unprocessable_entity
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Displaying Errors on Frontend
&lt;/h2&gt;

&lt;p&gt;Now that you have your backend set up, we can move to the frontend to display these errors for the user. In the component where we would like our errors to be shown, we will need set a state for these errors with an initial value as an empty array ([]).&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, {useState, useEffect} from 'react';

export default function OurComponentFunction() {
   const [errors, setErrors] = useState([])
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, wherever you are fetching the data for which you want the errors to be displayed, you will need to create an if statement. The if statement will state that if there are errors associated with the data, then you will set the errors state with those specific errors. If there are no errors, then the frontend will carry on as expected and display the data needing to be displayed. In the example below, we fetching from "food" and trying to create a new food post.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function handle Submit(e) {
  e.preventDefault();
  fetch("/food", {
     method: "POST", 
            headers: {
               "Content-Type": "application/json",
                accepts: "application/json",
              },
            body: JSON.stringify({
               name: name, 
               category: category
            }),
        })
            .then((r) =&amp;gt; r.json())
            .then((data) =&amp;gt; {
                if(data.errors) {
                   setErrors(data.errors)
                } else {
                   addNewFoodToArray(data)
                }
            })
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, that we have our errors being set in the errors state, we need to render it so that it can be shown on the application browser for the user. We will need to map through all the errors in the errors state so that we can return each error individually in an element tag of your choice. In the example below, we are using the 'p' tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return (
...
   {errors.map((error) =&amp;gt; {
       return &amp;lt;p&amp;gt;{error}&amp;lt;/p&amp;gt;
   }
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Finally, you have the tools and knowledge to try displaying your own errors on your application browser for the user to see! Go ahead and give it a try!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>What are Active Model Serializers?</title>
      <dc:creator>kirthinandi</dc:creator>
      <pubDate>Sun, 09 Oct 2022 20:47:42 +0000</pubDate>
      <link>https://dev.to/kirthinandi/what-are-active-model-serializers-2ij</link>
      <guid>https://dev.to/kirthinandi/what-are-active-model-serializers-2ij</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8NdgV6uy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8w59l9dp68pszuu0f4s4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8NdgV6uy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8w59l9dp68pszuu0f4s4.jpeg" alt="Image description" width="480" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When creating a Rails API data structure, the process consists of setting up routes and controllers to take care of different requests and return the requested JSON. When returning this JSON, we can customize it to only display what we specifically want it to. There are various ways to show the information we want but the &lt;strong&gt;Rails' Active Model Serializer&lt;/strong&gt; provides a simple way to customize JSON data while also following the "convention over configuration" technique.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Active Model Serializer
&lt;/h2&gt;

&lt;p&gt;In order to use the Active Model Serializer, you, first, need to install the gem in the Gemfile and activate it by running the command, '&lt;em&gt;bundle install&lt;/em&gt;', in your terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Gemfile
...
gem 'active_model_serializers'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you need to create the &lt;strong&gt;ActiveModel::Serializer&lt;/strong&gt; by running the command, '&lt;em&gt;rails g serializer &lt;/em&gt;', in the terminal. Below is what the generated serializer would look like for a particular model, Restaurant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# app/serializers/restaurant_serializer.rb
class RestaurantSerializer &amp;lt; ActiveModel::Serializer
  attributes :id
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Currently, the serializer is only allowing us to display the id of the specific restaurants in our data. If we want to customize the attributes being shown to the user, we can modify the serializer file by adding 'name, the year it started, cuisine, and a popular dish to the attributes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class RestaurantSerializer &amp;lt; ActiveModel::Serializer
  attributes :id, :name, :year_started, :cuisine, :popular_dish
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restaurants Controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# app/controllers/restaurants_controller.rb
def show
  restaurant = Restaurant.find(params[:id])
  render json: restaurant
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, if we navigate to the localhost:3000/restaurants browser, we should we see all the restaurants listed including the attributes listed above. &lt;/p&gt;

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

&lt;p&gt;You just learned how to create a serializer to display specific information for the user. With this knowledge, you can try creating a serializer on your own!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>rails</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Active Record: Seed Data</title>
      <dc:creator>kirthinandi</dc:creator>
      <pubDate>Mon, 19 Sep 2022 01:01:32 +0000</pubDate>
      <link>https://dev.to/kirthinandi/active-record-seed-data-4pp7</link>
      <guid>https://dev.to/kirthinandi/active-record-seed-data-4pp7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yEsNOE-G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tulp22nx6teqima70o3d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yEsNOE-G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tulp22nx6teqima70o3d.jpeg" alt="Image description" width="640" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Seed Data?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Seed data&lt;/strong&gt; is sample data. When creating or working with an application that requires a database, it is ideal to also create sample data that can be used to test out the application and its function in the future. In Active Record, the process of making the sample data to be inputted in the database is also known as "&lt;strong&gt;seeding the database&lt;/strong&gt;". &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should We Use Seed Data?
&lt;/h2&gt;

&lt;p&gt;You may be wondering what the purpose of seed data is when we can already create data in the console. It is encouraged to create a seed data Ruby file so that it is easier to share data and the instructions on how to create this data with other developers. This file can also be useful if there are instances where the development database gets deleted.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Can We Create Seed Data?
&lt;/h2&gt;

&lt;p&gt;There are a few simple steps in which we can produce seed data. First, we need to create a Ruby file called &lt;strong&gt;seeds.rb&lt;/strong&gt; in the db folder. Next, using Active Record Methods, we can create new data. In the following example, we will be adding new food items to go in a foods table that has already been created. When creating the data, we need to include the table's column names that we want to provide information in. In the example below, the first food item's name we are adding is the Mexican Pizza. To add it to the name column in our food table, we need to add &lt;code&gt;name: "Mexican Pizza"&lt;/code&gt; in the create method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#db/seeds.rb

Food.create(name: "Mexican Pizza", price: "$4.49", calories: "540 cal");
Food.create(name: "Grilled Cheese Burrito", price: "$4.29", calories: "720 cal");
Food.create(name: "Nachos BellGrande", price: "$4.69", calories: "730 cal");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After writing the code necessary to generate the data, we can run &lt;strong&gt;bundle exec rake db:seed&lt;/strong&gt; in the terminal. Since there won't be any output to the terminal after running this command, we can enter the terminal's console by running &lt;strong&gt;rake console&lt;/strong&gt; in the terminal. To have all the new food items that have been added to the table returned, we can type Food.all in the console. To see the first food item, we can type Food.first in the console. To see the second food item, we can type Food.second and so on. To see a specific attribute of a specific item, we can type Food.first.name or Food.second.price. &lt;/p&gt;

&lt;h2&gt;
  
  
  How To Create More Data?
&lt;/h2&gt;

&lt;p&gt;Oh no! We forgot to add important data! To make/add new data after creating the original data, we can use the Active Record methods similarly to how we did in the example above in the seeds.rb file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#db/seeds.rb

Food.create(name: "Mexican Pizza", price: "$4.49", calories: "540 cal");
Food.create(name: "Grilled Cheese Burrito", price: "$4.29", calories: "720 cal");
Food.create(name: "Nachos BellGrande", price: "$4.69", calories: "730 cal");

#new data 
Food.create(name: "Chicken Quesadilla", price: "$4.39", calories: "520 cal");
Food.create(name: "MTN DEW Baja Blast", price: "$2.19", calories: "280 cal");

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

&lt;/div&gt;



&lt;p&gt;After adding the data to the seeds.rb file, we will need to exit the console using the &lt;strong&gt;control + c&lt;/strong&gt; keys on our keyboard and running the seeds.rb file again using the &lt;strong&gt;bundle exec rake db:seed&lt;/strong&gt; command in the terminal. Then, we can enter the console again to test out our new data by typing rake console in the terminal. After entering the console, we can type Food.all to see all the items listed including the new items we added. If you want to remove the data from all the existing tables and re-run the seed file, you can run the command, bundle exec rake db:seed:replant in the terminal after exiting the console. Use this command with caution because it will delete all the data currently existing. &lt;/p&gt;

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

&lt;p&gt;Now that you understand the importance of using seed data and how to create it, you are ready to go ahead and try producing sample data on your own. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>programming</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>An Introduction to the useEffect Hook</title>
      <dc:creator>kirthinandi</dc:creator>
      <pubDate>Sat, 27 Aug 2022 21:10:17 +0000</pubDate>
      <link>https://dev.to/kirthinandi/an-introduction-to-the-useeffect-hook-5642</link>
      <guid>https://dev.to/kirthinandi/an-introduction-to-the-useeffect-hook-5642</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Ue0_1QD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0lxa0s8xm6s2wyr5sli.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Ue0_1QD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0lxa0s8xm6s2wyr5sli.jpeg" alt="Image description" width="880" height="587"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  What are React Hooks?
&lt;/h2&gt;

&lt;p&gt;In React, there are &lt;strong&gt;hooks&lt;/strong&gt; which essentially give function components permission to "hook" into React's features such as state and other methods. There are three general rules when it comes to hooks that should be kept in mind when working with them. &lt;/p&gt;

&lt;h2&gt;
  
  
  React Hooks Rules:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Hooks can only be called inside React function components&lt;/li&gt;
&lt;li&gt;Hooks can only be called at the top level of the function component&lt;/li&gt;
&lt;li&gt;Hooks cannot be conditional&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Side Effects
&lt;/h2&gt;

&lt;p&gt;A function is considered to have a &lt;strong&gt;side effect&lt;/strong&gt; if it is called and the function causes change outside of the function itself. Examples of common side effects are making requests, fetching data from a database, incorporating a timer, directly updating the DOM, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  The useEffect Hook
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;useEffect hook&lt;/strong&gt; available in React allows us to perform some of these side effects mentioned earlier in the function components. To use this hook, it needs to be imported, first.&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, { useEffect } from "react";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the function component that we want to perform the side effect, we can call the useEffect hook and pass in a callback function which will act like the desired side effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
 //side effect function
  useEffect(
     () =&amp;gt; {
       console.log("Hello, I am second");
     }
  );
  console.log("Hi, I am first");
  return (
    &amp;lt;div&amp;gt; 
       &amp;lt;button&amp;gt;Click me&amp;lt;/button&amp;gt;
       &amp;lt;input type="text" placeholder="Type here..." /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;p&gt;When we run the code above, the messages will appear in this order: &lt;br&gt;
    1. Hi, I am first&lt;br&gt;
    2. Hello, I am second&lt;/p&gt;

&lt;p&gt;By passing a console message in the useEffect hook, we are telling the function component to do something after it renders which is console logging the message we want. We can do other things in the hook such as fetching data, creating a timer, or updating the DOM. &lt;/p&gt;

&lt;h2&gt;
  
  
  useEffect Dependencies
&lt;/h2&gt;

&lt;p&gt;Because the useEffect hook runs on every render meaning it may perform the side effect many times, we need to control this using a dependency. To control the amount of renders, we can incorporate a second parameter, a &lt;strong&gt;dependency array&lt;/strong&gt;, in the useEffect hook. &lt;/p&gt;

&lt;h2&gt;
  
  
  No Dependency
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
   //Runs on every render
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Empty Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
   //Runs only on the first render
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Props/State Value
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
   //Runs on the first render 
   //And when dependency value changes 
}, [prop, state]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, that you have the introductory knowledge needed to put the useEffect hook to use, go ahead and try it out! Good luck!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What Are JavaScript Events?</title>
      <dc:creator>kirthinandi</dc:creator>
      <pubDate>Fri, 05 Aug 2022 16:47:42 +0000</pubDate>
      <link>https://dev.to/kirthinandi/what-are-javascript-events-4dci</link>
      <guid>https://dev.to/kirthinandi/what-are-javascript-events-4dci</guid>
      <description>&lt;h2&gt;
  
  
  JavaScript Events
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;JavaScript events&lt;/strong&gt; can be defined as something the user does in a website or browser. This can be a multitude of different things such as clicking a button, closing the browser, hovering over an element on the browser, etc. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9nIIi0IL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahmekg9g5fd8f81n8177.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9nIIi0IL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahmekg9g5fd8f81n8177.gif" alt="Image-description" width="498" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Listeners
&lt;/h2&gt;

&lt;p&gt;JavaScript is capable of detecting or listening for the events taking place in a browser. For example, when a user clicks on a specific button, JavaScript can pay attention to the user's click and do something after the click like displaying text or an image. &lt;/p&gt;

&lt;p&gt;To tell JavaScript to listen for an event, we can use the method, &lt;strong&gt;addEventListener()&lt;/strong&gt;, on an element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eventTarget.addEventListener('click', function() {
   console.log('You clicked me!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the addEventListener() is being added onto the element we select. This can be a button we have created like the example below, a variable containing the wanted element, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const button = document.createElement('button');
button.addEventListener('click', function() {
   console.log('You clicked me!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The event listener takes in two arguments with the first being the event we want JavaScript to listen for. In this case, it was the 'click' event but it can be a mouseover, keydown, drag, scroll, or any of the other various DOM events. The second argument is the function which tells JavaScript what to do once the event has been completed. In the example above, the browser's console will print the statement, 'You clicked me!' &lt;/p&gt;

&lt;p&gt;Now, that you have learned the basics of JavaScript events and using event listeners, you can try to create your own event and event listener!&lt;/p&gt;

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

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
