<?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: Augustus Otu</title>
    <description>The latest articles on DEV Community by Augustus Otu (@augani).</description>
    <link>https://dev.to/augani</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%2F172375%2Fd1b6bd79-45c3-4197-80c4-b2af71fac033.jpg</url>
      <title>DEV Community: Augustus Otu</title>
      <link>https://dev.to/augani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/augani"/>
    <language>en</language>
    <item>
      <title>How to create a smooth draggable list with react in 10 mins</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Sun, 27 Jun 2021 11:43:01 +0000</pubDate>
      <link>https://dev.to/augani/how-to-create-a-smooth-draggable-list-with-react-in-10-mins-2fbn</link>
      <guid>https://dev.to/augani/how-to-create-a-smooth-draggable-list-with-react-in-10-mins-2fbn</guid>
      <description>&lt;p&gt;Welcome to another tutorial!!&lt;/p&gt;

&lt;p&gt;Today, we are going to create a draggable list that you can use in your react applications with ease, using framer-motion. If you go to their examples page on  &lt;a href="https://codesandbox.io/s/framer-motion-2-drag-to-reorder-fc4rt" rel="noopener noreferrer"&gt;codesandbox&lt;/a&gt; , you will see this implemented. In case you want to know how you can do it yourself, read on.&lt;/p&gt;

&lt;p&gt;To start, if you have a list of items in a container or div that you want to have your users reorder by just dragging one item over another to swap positions, it's not a hustle since you are in the right place. This is what we are going to build in a few minutes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1624633429677%2F_MvQHtavH.gif" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1624633429677%2F_MvQHtavH.gif" alt="chrome-capture.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the code, my favorite part!!&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./style.css&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;List&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&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;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;List&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;n&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;))&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&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;&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="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is a normal react app where you are exporting the main component called App. We have another component below that will be the item in the main we will be dragging. A list that we map to produce our six items in the main app.&lt;/p&gt;

&lt;p&gt;For now, our item component is just normal div with no properties to make it interactive, we add the framer motion package since that is what we will be using.&lt;/p&gt;

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

yarn add framer-motion //or
npm i framer-motion


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

&lt;/div&gt;

&lt;p&gt;When its done doing it magic, we import it into our file and get the &lt;strong&gt;motion&lt;/strong&gt; element from &lt;em&gt;'framer-motion'&lt;/em&gt;. Then change our normal div in the &lt;strong&gt;Item&lt;/strong&gt; component to &lt;em&gt;motion.div&lt;/em&gt;, so we have properties we can use to drag and reorder the item when rendered.&lt;/p&gt;

&lt;p&gt;Next, we will have to add the properties we want to use;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;drag&lt;/strong&gt;- this will allow us drag our div when rendered in the page. This takes in two types, a boolean and string(x or y). When set to true, we can drag the component in both direction, when set to &lt;strong&gt;y&lt;/strong&gt; we can only drag it up or down and &lt;strong&gt;x&lt;/strong&gt;, left or right. For this tutorial we only want our users dragging it either up or down, so we set it to &lt;strong&gt;y&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;drag&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&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;motion&lt;/span&gt;&lt;span class="p"&gt;.&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is what the code looks like now. If you dragged the element, you will realise it goes outside our container that the list rendered in. We don't want that, so we need to add constraints to make sure users can only drag within the container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;dragConstraints&lt;/strong&gt; - this takes an object of the four sides of the area the item is in, top, bottom, left, right. These accept values as pixels. How far away from the top, bottom, left or right should be the limit, where the component can't be dragged across. If you give it a &lt;strong&gt;top&lt;/strong&gt; of &lt;strong&gt;0&lt;/strong&gt;, it means the element can only be dragged to the very edge of the top of the parent component, in this case, our container.
If you give it a &lt;strong&gt;10&lt;/strong&gt;, it means it can be dragged up to 10px from the top of the parent component. For our case, we want it to be able to reach the edges and since we are only dragging on the &lt;strong&gt;y&lt;/strong&gt; axis, we only need to take care of the top and bottom.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;dragListeners&lt;/strong&gt; - One thing we also need to take care of is to know when the item is being dragged and when it is dropped after dragging. This will help us be able to reorder the items very well. 
When dragging the item, we might want to help the users know by performing some form of animation on the item being dragged by either increasing it in size or decreasing it, just to differentiate that from the other items.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;layout&lt;/strong&gt; - We will add this property as well to help us animate the item when dragging as it will be changing position i n the list. Framer motion has done a lot of work for us to have these cool stuff. &lt;a href="https://www.framer.com/api/motion/animation/#layout-animations" rel="noopener noreferrer"&gt;Read more&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;animations&lt;/strong&gt; - We also might want to add a couple of animations to the item that will be dragged, in our case, we can add the whileHover and whileTap properties or leave it, I ill but you can check the docs later and add. I think the name gives a hint about what each does. When the item is hovered, do this, when the item is tapped or clicked, do that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;controls&lt;/strong&gt; - We want to add the various functions that will be called to help us reorder our list when it is dragged from one position to the other. They are &lt;strong&gt;updateOrder&lt;/strong&gt; and &lt;strong&gt;updatePosition&lt;/strong&gt;, and we will use the &lt;a href="https://codesandbox.io/s/framer-motion-2-drag-to-reorder-fc4rt?file=/src/use-position-reorder.js:0-1772" rel="noopener noreferrer"&gt;usePositionReOrder&lt;/a&gt; and &lt;a href="https://codesandbox.io/s/framer-motion-2-drag-to-reorder-fc4rt?file=/src/use-measure-position.js" rel="noopener noreferrer"&gt;useMeasurePosition&lt;/a&gt; hooks. We don't need to rewrite our own.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What &lt;strong&gt;usePositionReorder&lt;/strong&gt; hook does is reorder our list that is rendered when we drag an item from one position to the other and also updates the position of the item given its new position after the drag event. Use measure position uses the ref of the item to determine its position from where it was dragged from and where it has been placed and its index in the list. This is what it uses to send the data to &lt;strong&gt;updatePosition&lt;/strong&gt; from the &lt;strong&gt;usePositionReOrder&lt;/strong&gt; hook. So it will take data from the item being dragged such as its dragoffset vertically, since we are only dragging along the y axis. This will help the hook swap the item that we are changing positions with the dragged item.&lt;/p&gt;

&lt;p&gt;When the item is being dragged, aside from letting the component itself know that it is in a dragging state, we have to let our &lt;strong&gt;usePositionReOrder&lt;/strong&gt; hook know, using another property which is the &lt;strong&gt;onViewBoxUpdate&lt;/strong&gt; prop. This property is a callback that will fire every time the viewport is updated due to a drag activity. And it sends the delta of the item and the index to &lt;strong&gt;updateOrder&lt;/strong&gt; from the &lt;strong&gt;usePositionReorder&lt;/strong&gt; hook. The list is reordered and sent back to us in the &lt;strong&gt;orderedList&lt;/strong&gt; and a new list is rendered into our view. &lt;/p&gt;

&lt;p&gt;Our code finally looks like this&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./style.css&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;motion&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;framer-motion&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;usePositionReorder&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;./usePositionReorder&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;useMeasurePosition&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;./useMeasurePosition&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;List&lt;/span&gt; &lt;span class="o"&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;Item One&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;Item Two&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;Item Three&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;Item Four&lt;/span&gt;&lt;span class="dl"&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;updatedList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateOrder&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;usePositionReorder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;List&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;ul&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;updatedList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;
          &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;ind&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;updateOrder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;updateOrder&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;updatePosition&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&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;))&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;ul&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateOrder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ind&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isdragged&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsDragged&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useState&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;itemRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMeasurePosition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pos&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;li&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;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;zIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isdragged&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;dragConstraints&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;dragElastic&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;layout&lt;/span&gt;
      &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;itemRef&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;onDragStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&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="nf"&gt;setIsDragged&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="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;onDragEnd&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&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="nf"&gt;setIsDragged&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="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isdragged&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mf"&gt;1.05&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;onViewportBoxUpdate&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&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;delta&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;isdragged&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nf"&gt;updateOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;drag&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&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;motion&lt;/span&gt;&lt;span class="p"&gt;.&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;li&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When clicking to drag the items in the list, you will realize they are a bit hard to drag from one end to the other. We can add the &lt;strong&gt;dragElastic&lt;/strong&gt; property of 1 to make it smoother.&lt;/p&gt;

&lt;p&gt;Now this is our look&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1624791455644%2FWYNY6AiNu.gif" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1624791455644%2FWYNY6AiNu.gif" alt="chrome-capture (1).gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The possibilities are endless, so go ahead and build something with it. A &lt;a href="https://github.com/Augani/react-draggable-list" rel="noopener noreferrer"&gt;link&lt;/a&gt; to the repo to view the entire code and &lt;a href="https://react-wt4hcq.stackblitz.io" rel="noopener noreferrer"&gt;live&lt;/a&gt;.&lt;br&gt;
And explore more with framer motion &lt;a href="https://www.framer.com/api/motion/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Till next time..&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Js regex cheatsheet Part 1</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Thu, 28 May 2020 11:21:03 +0000</pubDate>
      <link>https://dev.to/augani/js-regex-cheatsheet-part-1-1njb</link>
      <guid>https://dev.to/augani/js-regex-cheatsheet-part-1-1njb</guid>
      <description>&lt;p&gt;Hey there and welcome to this quick tutorial. I woke up to a mail about today being a year's anniversary since joining this awesome community, so I decided to write something in celebration. &lt;/p&gt;

&lt;p&gt;This is just a little cheat sheet you can bookmark and check whenever you want to write a regular expression for that awesome program you are writing. &lt;/p&gt;

&lt;p&gt;I won't bore you with much info as I assume you already now what regular expressions are. If not, they are patterns that you can use to manipulate text or match character combinations in strings. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions"&gt;Read more&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's dive right in shall we.&lt;/p&gt;

&lt;p&gt;When writing regular expressions, we can use a literal like&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;let&lt;/span&gt; &lt;span class="nx"&gt;kofi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/ama/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or we can use the constructor like&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;let&lt;/span&gt; &lt;span class="nx"&gt;kofi&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ama&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;Both of these are valid and mean the same thing. So you can use any format.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that the pattern used in the constructor is always a string or better yet wrapped in quotes. Also when using literals, if by any case there will be special characters like question marks, plus signs in your pattern you have to make sure a backslash &lt;em&gt;"\"&lt;/em&gt; precedes them as they have meanings in regular expressions as you are about to see.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I will be using two methods with regular expressions;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;RegExp.test();&lt;/li&gt;
&lt;li&gt;RegExp.exec();&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;RegExp.test() is a method that tests for your pattern and returns either true or false. If it finds your pattern in the given string, it returns true. if not, false.&lt;/p&gt;

&lt;p&gt;RegExp.exec() is a method that searches for a match in a string and returns information when it finds the match, as an array and null when it doesn't find a match.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  RegExp.test()
&lt;/h2&gt;

&lt;p&gt;For the method test these are the ways you can use it&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="cm"&gt;/**
This finds the exact match in a string. Thus the string must contain "abc" in the exact order or sequence.
**/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;ama&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lamal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;
&lt;span class="sr"&gt;/ama/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;almal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns false&lt;/span&gt;

&lt;span class="cm"&gt;/**
This next one lets you find a range of characters in a string and is one of my favourites to use.
**/&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;196&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i was born in 1996&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;

&lt;span class="c1"&gt;//or&lt;/span&gt;

&lt;span class="c1"&gt;//This means all the numbers from 0-9, thus 0123456789.&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;0-9&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i was born in 1996&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;//returns true&lt;/span&gt;


&lt;span class="c1"&gt;//This returns false because there is neither 0,4 nor 3 in the string&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;043&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i was born in 1996&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns false&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's catch a breather here. Remember the special characters I mentioned earlier on? We will get to that real quick but first, let's look at a couple of common shortcuts for writing expressions.&lt;/p&gt;

&lt;p&gt;Please take note of these&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="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;  &lt;span class="c1"&gt;//returns true if any number is found in a given string "19"&lt;/span&gt;
&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;D&lt;/span&gt; &lt;span class="c1"&gt;//returns true if there aren't any numbers in a string "the"&lt;/span&gt;

&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;w&lt;/span&gt; &lt;span class="c1"&gt;//returns true if any alphanumeric is found in a given string "u2"&lt;/span&gt;
&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;W&lt;/span&gt; &lt;span class="c1"&gt;//returns true if there aren't any alphanumeric in a given string  "(-)"&lt;/span&gt;

&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="c1"&gt;//returns true if there is any whitespace thus space, tab and newline " "&lt;/span&gt;
&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nx"&gt;S&lt;/span&gt; &lt;span class="c1"&gt;//returns true if there is any non-whitespace character "khi "&lt;/span&gt;

&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="c1"&gt;//returns true for any character except a new line&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;A special character like a caret &lt;em&gt;^&lt;/em&gt; is used for negative matching a range of values. This means if any other value exists in a given string other than the ones it precedes in a pattern, return true.&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;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mi"&gt;1996&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;199619961996&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//returns false&lt;/span&gt;

&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mi"&gt;1996&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1996199619967&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//returns true because of 7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now to our special characters&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="cm"&gt;/**
Question marks are used for optional matching, meaning the value they come right after can be present in a given string or not and in this case was the letter "u"
**/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;favou&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="nx"&gt;rite&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;favourite&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// returns true&lt;/span&gt;
&lt;span class="sr"&gt;/favou&lt;/span&gt;&lt;span class="se"&gt;?&lt;/span&gt;&lt;span class="sr"&gt;rite/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;favorite&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;

&lt;span class="cm"&gt;/**
Plus signs are used to indicate whether the value it comes after will appear once or more times in a given string
**/&lt;/span&gt;
&lt;span class="sr"&gt;/vo+/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;volvo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;

&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="sr"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;20019&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;

&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="sr"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;volvo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns false&lt;/span&gt;

&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="sr"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&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="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns false&lt;/span&gt;

&lt;span class="cm"&gt;/**
A star also does the same as a plus but also returns true when there is no match too
**/&lt;/span&gt;

&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="sr"&gt;*/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;volvo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;


&lt;span class="cm"&gt;/**
Braces are used to make sure a pattern is represented exactly a number of times. 
It can also be used to specify a range. A good example is when you want to validate dates and time. {3} means the value it comes after must appear exactly 4 times in a given string. 
{1,3} means the value it comes after must be present at least once and at most 3 times. In the example below, the first set means any digit given to represent a day can be either "3" or "30" thus one or two digits as there is only up to 31 days in a month.
 The next means the month can be either "4" or "12" as there is only up to 12 months in a year and the last accepts exactly 4 digits.
**/&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\d{1,2}&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;\d{1,2}&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;\d{4}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3-01-1996&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//returns true&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;That will be it for part one, part two will tackle &lt;em&gt;RegExp.exec()&lt;/em&gt; and more advanced regular expressions that will help you build your own expressions with ease. So bye for now, catch you soon on part two. Hope this helped you understand a bit of what you can do with regular expressions.&lt;/p&gt;

&lt;p&gt;Comments are welcome😊&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>code</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to create an Animated order button with just HTML and css</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Mon, 20 Apr 2020 21:10:33 +0000</pubDate>
      <link>https://dev.to/augani/how-to-create-an-animated-order-button-with-just-html-and-css-15d5</link>
      <guid>https://dev.to/augani/how-to-create-an-animated-order-button-with-just-html-and-css-15d5</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/augani/embed/JjPLMwR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>How to build a graphql api from scratch</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Tue, 28 May 2019 16:04:46 +0000</pubDate>
      <link>https://dev.to/augani/how-to-build-a-graphql-api-from-scratch-19c0</link>
      <guid>https://dev.to/augani/how-to-build-a-graphql-api-from-scratch-19c0</guid>
      <description>&lt;p&gt;I have seen a lot of tutorials online about how to build a graphql api and i must say lack one thing, the basics. So what i am going to do here is have this tutorial in two parts. Part 1 will talk about what graphql is and go ahead to setup a simple server with express alongside graphql.&lt;/p&gt;

&lt;p&gt;What you will learn in this tutorial isn't solely for javascript folks as i will make sure i take you through the basics and you can go ahead and look at the libraries for other languages and start building on the knowledge acquired here.&lt;/p&gt;

&lt;p&gt;Part 2 will be an advanced part where we actually build a full api that we will test with postman and the graphiql interface. At the end of this tutorial i hope you will be able to build your own api for any app you are working on or a new project you would like to start. So lets get started.&lt;/p&gt;

&lt;p&gt;Graphql is simply a query language for whichever api you are building. When i say query language i mean, a way of interacting with your api itself and not a database as we used to know it, when we hear about the word "query". If you have been programming for long, i know you have come across query when working with SQl(Standard query language) databases such as MYSQL and POSTGRESQl. We use to query databases with the standard language mentioned above so something like&lt;/p&gt;

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

&lt;p&gt;I guess you remember something like that, now what this allows us to do is select data that we need, when we need it. When retrieving data from the database using SQL we have the flexibility of getting what we need and not more than that. However, if you are familiar with rest apis, you realize that data is given to you usually in a JSON format when you send a GET or POST request to an endpoint. Most of the data the REST api sends won't be used by the client side but bandwidth will be consumed. This one of the things graphql is solving by allowing you to query your api like we did with SQl. Now that you understand how it works, i will take you through the terms you will be mostly using when working with graphql.&lt;/p&gt;

&lt;p&gt;When working with graphql, all your request to the single endpoint will be post requests. I know you are wondering how you will just get data like you use to do in the REST architecture. That brings us to the term, Query. Query is used to get data from your api. But what use is an api if you can't also manipulate data on the server side as well, so that brings us to the term, Mutation. Mutation is just like POST, DELETE, PUT in the rest architecture. There are other terms like subscriptions and fragments, but we will be focusing on queries and mutations for the purpose of this tutorial, but feel free to read about them on their page, &lt;a href="https://graphql.github.io/learn/queries" rel="noopener noreferrer"&gt;Learn more about Graphql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that you know the terms, let us see some code right away. My favorite part. I assume you know a bit of js and node. If you don't please leave a comment and my next article will take you through the basics of node. First off, we create a server using node and express. You can create a new folder in whichever workspace you are ok with so open your directory or create a new on using cmd &lt;/p&gt;

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

&lt;p&gt;After creating the directory for the app, run "cmd" in the address bar(assuming you are on windows to open the command line in that folder.&lt;/p&gt;

&lt;p&gt;Lets start a new project with npm init&lt;/p&gt;

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

&lt;p&gt;Just go with the defaults and in the end, you should have something like this&lt;/p&gt;

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

&lt;p&gt;Afterwards, let us install all the packages we will need, by running the following in that same directory&lt;/p&gt;

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

&lt;p&gt;You can also install the body-parser package to turn our requests into json &lt;/p&gt;

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

&lt;p&gt;Express is the ever popular framework for node, graphql is what we just talked about and express-graphql contains some important modules we will be using to build our server and api and mongoose will help us connect to our mongodb database with ease.&lt;/p&gt;

&lt;p&gt;You can then open the newly created project with your favorite IDE and craete a new file named index.js if you went with the defaults of npm init, or whichever file you names as the main in your package.json file. After creating the file we create a simple server in this file with express. Something like&lt;/p&gt;

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

&lt;p&gt;Now you have the express server setup with graphql. Express is being used to start our server and we require graphql http from express graphql to use as a middleware for our api. That is going to handle all the request that goes to the graphql route given. In the graphqlhttp module imported, we are going to give the  options with which graphql is going to work with. Some of them are the schema, which will let graphql know how we are going to query our data and how we want our data to be like. Another option is also the root value that will take all our resolvers thats the functions that will allow us create and manipulate data in graphql. Another useful option is the "graphiql" which will give us the ability to interact with our api using an interface when we navigate to the "graphql" route in our browser. So let us add the options now&lt;/p&gt;

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

&lt;p&gt;In the above gist, we can see the schema and graphiql options added to our code now. The schema is required to have graphql run successfully, because that is the only way graphql will understand our request to the api we are about to build. So i created a function called defineSchema which basically defines our schema. In the schema, we have "buildSchema" which was imported from the graphql package. this is what will build our schema using the string we give it.&lt;/p&gt;

&lt;p&gt;MainQuery is a GraphQL Object Type that has a field named library. the library field is of Strings, which means only strings will be in that field and the exclamation mark after it means, it is not nullable. So whenever we query our api for library an empty array will come to show that it is empty or an array of strings will be given by the api based on what that field has.&lt;/p&gt;

&lt;p&gt;There is also a getlibrary function that gets the books in the library, for now it is just an array because we haven't connected a database yet. The name of the schema in your queries should match the name of the function keys in your rootValue, this will help graphql know what you want and get you exactly that. So the more schema types we add to the queries the more mtaching functions we add to the rootValue. Schema defines the data, rootValue gets us the data.&lt;/p&gt;

&lt;p&gt;So if you start your server using node and navigate to the graphql route, you should see this simple interface that will allow you to interact with the api you just created. For now, it doesn't do much, but i hope you understand how it works. This should be what you see at your "/graphql" route&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kJ1d-Jap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.ibb.co/s94cXMc/Screenshot-19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kJ1d-Jap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.ibb.co/s94cXMc/Screenshot-19.png" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now lets query our new graphql api now and get the books in our library using the  GraphQL schema language. &lt;/p&gt;

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

&lt;p&gt;From this query and curly braces the next level is the name as stated in our rootValue, thats the function to get the data. If you enter the code in your new graphql explorer, you should have the getlibrary function called and books returned as the data. So using the same route, we can state another schema and root value and query it with ease, thats the power of graphql. I hope you enjoyed this tutorial and learnt something today. Will continue with the next part where we actually build a fully functioning api, where we store and retrieve data from our mongodb database. See you in the next post. Connect with me on twitter @AugustusOtu with any questions or comment here for any explanations. Share to your circles.&lt;/p&gt;

&lt;p&gt;Happy coding....Bye for now&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>node</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Which should be my next post? Topics 👇</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Mon, 27 May 2019 22:48:25 +0000</pubDate>
      <link>https://dev.to/augani/which-should-be-my-next-post-topics-4fp1</link>
      <guid>https://dev.to/augani/which-should-be-my-next-post-topics-4fp1</guid>
      <description>&lt;ol&gt;
&lt;li&gt;&lt;p&gt;How to easily accept stripe payments in node&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to setup a graphql server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to connect sockets to your node app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to setup your express app and solve most errors you are to face.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to connect a react app with a node backend.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can comment the topics you want me to write about. Let's go&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>How to write a promise in javascript</title>
      <dc:creator>Augustus Otu</dc:creator>
      <pubDate>Mon, 27 May 2019 17:25:15 +0000</pubDate>
      <link>https://dev.to/augani/how-to-write-a-promise-in-javascript-11g8</link>
      <guid>https://dev.to/augani/how-to-write-a-promise-in-javascript-11g8</guid>
      <description>&lt;p&gt;Hello and welcome to my post. I am going to teach you how to write a promise. First, why should you use promises in your code? The answer is simple, and that is, it helps you wait for the response of an action before going on to perform another action. I know you want to see the code so here you go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PnzCcA07--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/1zrvp32/promise.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PnzCcA07--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/1zrvp32/promise.png" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is as simple as you see. Now you can go ahead and have promises in your code.&lt;br&gt;
You can connect with me on twitter. Thank you and happy coding&lt;/p&gt;

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