<?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: Ericawanja</title>
    <description>The latest articles on DEV Community by Ericawanja (@ericawanja).</description>
    <link>https://dev.to/ericawanja</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%2F707332%2F867e68a2-5309-4f8d-81d4-0b89b673f325.jpg</url>
      <title>DEV Community: Ericawanja</title>
      <link>https://dev.to/ericawanja</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ericawanja"/>
    <language>en</language>
    <item>
      <title>How to Build a Docker Image from Github and push to Docker Hub using a Jenkins Job</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Sun, 26 May 2024 22:26:13 +0000</pubDate>
      <link>https://dev.to/ericawanja/how-to-push-a-docker-image-to-docker-hub-using-jenkins-job-k5j</link>
      <guid>https://dev.to/ericawanja/how-to-push-a-docker-image-to-docker-hub-using-jenkins-job-k5j</guid>
      <description>&lt;p&gt;Instead of manually building a docker image every time you make changes in your source code, you can build a Jenkins job that pulls the source code, builds the image, and publishes it to to docker hub. &lt;/p&gt;

&lt;p&gt;How do you achieve that? Let's find out&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Setting up the DockerHub credentials on Jenkins
&lt;/h3&gt;

&lt;p&gt;Jenkins will need the docker hub credentials to build and push the image to the docker hub. Instead of using dockerHub username and password, we will Create an Access Token in the dockerHub.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to DockerHub&lt;/li&gt;
&lt;li&gt;Click on the profile Icon and click on the Account settings&lt;/li&gt;
&lt;/ol&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%2Fxig2b0jmgrukr3gziw13.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%2Fxig2b0jmgrukr3gziw13.png" alt="Jenkins" width="800" height="332"&gt;&lt;/a&gt;&lt;br&gt;
3.Click on the Security tab on the left menu, click on the "New Access Token and Enter a brief Description. After clicking the "Generate" button, click on the "Copy and Close" button. &lt;/p&gt;
&lt;h4&gt;
  
  
  How to save the credentials on Jenkins
&lt;/h4&gt;

&lt;p&gt;On Jenkins navigate to add a global credential&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%2Fby9n6wou8t9czy416z8v.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%2Fby9n6wou8t9czy416z8v.png" alt="Jenkins" width="800" height="305"&gt;&lt;/a&gt;&lt;br&gt;
Enter the details needed to create the credential and save&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%2Fay3q1xcpznx3tcdsv468.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%2Fay3q1xcpznx3tcdsv468.png" alt="Jenkins" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Setting up the project on Github
&lt;/h3&gt;

&lt;p&gt;If you don't have a project you can clone this &lt;a href="https://github.com/Ericawanja/Jenkins-DockerHub-Automation"&gt;https://github.com/Ericawanja/Jenkins-DockerHub-Automation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Delete the Jenkinsfile and Dockerfile to follow along&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Setting up the Dockerfile
&lt;/h3&gt;

&lt;p&gt;The docker file contains instructions on how to package the different computer pieces needed for a software application into a single package called an image. &lt;/p&gt;

&lt;p&gt;We will create a simplified Dockerfile which copies all files into a work directory. Since we're not accessing this application from a browser, we will not be exposing any port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="n"&gt;FROM&lt;/span&gt; &lt;span class="nl"&gt;node:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;alpine&lt;/span&gt; 

&lt;span class="n"&gt;WORKDIR&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;

&lt;span class="n"&gt;COPY&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Creating and updating the Jenkins file
&lt;/h3&gt;

&lt;p&gt;Create a Jenkins file on the root folder and follow along to update it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Logging in to Docker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the first step of the Jenkinsfile, we will log in to docker using with credentials() method which allows us to bind credentials into a pipeline script. Binding credentials using withCredentials method prevents exposing them  in the script or on the Jenkins console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="n"&gt;stages&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Login'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;withCredentials&lt;/span&gt;&lt;span class="o"&gt;([&lt;/span&gt;&lt;span class="n"&gt;usernamePassword&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;credentialsId:&lt;/span&gt; &lt;span class="s1"&gt;'dockerJenkinsID'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;usernameVariable:&lt;/span&gt; &lt;span class="s1"&gt;'USERNAME'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;passwordVariable:&lt;/span&gt; &lt;span class="s1"&gt;'PASSWORD'&lt;/span&gt;&lt;span class="o"&gt;)])&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

                   &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s2"&gt;"docker login -u $USERNAME -p $PASSWORD"&lt;/span&gt;                  

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;"usernamePassword" denotes the type of credentials.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;credentialsId&lt;/code&gt; is the ID of the credential stored in Jenkins&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;usernameVariable&lt;/code&gt; and &lt;code&gt;passwordVariable&lt;/code&gt; populate the username and password stored in Jenkins &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Building the docker image&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Building a docker image is gathering all the artifacts needed for your software to run and packaging them so that the software can run anywhere.&lt;/p&gt;

&lt;p&gt;To do so, the system uses a dockerfile which contains step-by-step instructions on how to build the image. Since we already have our dockerfile ready, we will be adding the command to trigger the image build.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Build'&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
            &lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s1"&gt;'docker build -t ericawanja/todoapp:latest .'&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Pushing the image to the docker hub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dockerhub is a cloud-based repository built for finding, using, and sharing docker container images. We will our push the image to the docker hub to make it available for other developers to pull and use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt; &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Push'&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
            &lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;//Deploy our app to DockerHub&lt;/span&gt;
               &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s1"&gt;'docker push ericawanja/todoapp:latest'&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Log out from Docker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logging out from service after logging in is a good security practice that prevents attacks such as session hijacking or unauthorized access.&lt;/p&gt;

&lt;p&gt;We will log out from Jenkins in the "post" section which defines actions that are executed after the main stages in the Jenkins pipeline script have been completed.&lt;/p&gt;

&lt;p&gt;The commands contained in the "always" block are executed every time the pipeline script runs regardless of the pipeline outcome.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; post {
        always {
            sh 'docker logout'
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Creating and Running the Jenkins Jobs
&lt;/h3&gt;

&lt;p&gt;In this step, we will create a Jenkins job that pulls the source code from GitHub and uses the Jenkins file to build and push the image to dockerhub.&lt;/p&gt;

&lt;p&gt;Log in to Jenkins, click "+ New item" and select a pipeline Job type. Don't forget to enter the name before clicking the OK button.&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%2F5benaiqdbvi3qusspvuk.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%2F5benaiqdbvi3qusspvuk.png" alt="Image description" width="800" height="1083"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because we're using a Jenkinsfile, the pipeline script will be from SCM. I'm using a public GitHub repository, therefore I don't have to configure the credentials. Remember to change the branch to "main" or the branch name you want to build.&lt;/p&gt;

&lt;p&gt;Finish setting the job and run it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Automation aims at saving time and effort. By building a Jenkins pipeline that pulls the source code changes, builds an image, and pushes it to docker, will save you time and effort spent doing that manually. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>jenkins</category>
      <category>docker</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction to DevOps</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Tue, 20 Feb 2024 01:26:43 +0000</pubDate>
      <link>https://dev.to/ericawanja/introduction-to-devops-1le3</link>
      <guid>https://dev.to/ericawanja/introduction-to-devops-1le3</guid>
      <description>&lt;p&gt;Considering most if not all companies are aiming to develop and deploy new software quickly, DevOps is an indispensable concept. &lt;/p&gt;

&lt;p&gt;Research indicates that 77% of companies have already adopted the DevOps culture and worth mentioning, is, this figure is expected to increase significantly.&lt;/p&gt;

&lt;p&gt;With these intriguing statistics, you will not go wrong in adding DevOps to your tools list. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. What's DevOps
&lt;/h2&gt;

&lt;p&gt;DevOps, a combination of development (Dev) and IT operations (ops) is a set of practices, tools, and cultural practices that are geared to streamline the software delivery process at a high velocity. &lt;/p&gt;

&lt;p&gt;Activities such as  automation, collaboration, and iterative development are highly emphasized in DevOps. These activities begin with planning, code development all through testing, deployment, and monitoring.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Key Principles of DevOps
&lt;/h2&gt;

&lt;p&gt;DevOps has a set of principles that are geared to enhance automation, collaboration, and continuous improvement across the development and operations teams.&lt;/p&gt;

&lt;p&gt;Some of these principles include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Automation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DevOps aims at automating repetitive tasks such as code integration and deployment, testing, and monitoring to facilitate faster processes and frequent releases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Continous Integration(CI)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Practicing continuous integration in DevOps allows developers to frequently merge their changes into a single repository. Before the merging, unit tests are ran detecting errors early on making it less expensive to fix them&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Continous Deployment(CD)&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Continuous deployment involves automatically building and deploying all code changes to the production environment after running a series of automated tests.&lt;/p&gt;

&lt;p&gt;Automation is heavily relied on in continuous deployment which helps achieve frequent updates in the production environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Infrastructure as Code (IaC)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Infrastructure as Code provides an organized way for managing and provisioning the infrastructure through code instead of a manual way.&lt;/p&gt;

&lt;p&gt;Configuration files for Infrastructure components such as operating systems, databases, and storage are created and versioned making it easy to edit and distribute. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DevOps culture emphasizes on teamwork across the development and operations teams instead of having them 'siloed'. &lt;br&gt;
As a result, the team can leverage each other's strengths which breaks barriers and improving innovation.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. DevOps Lifecycle
&lt;/h2&gt;

&lt;p&gt;DevOps lifecycle incorporates various activities involved in the development, testing, deployment, and maintenance of software. &lt;/p&gt;

&lt;p&gt;Typically an infinite loop is used to represent DevOps lifecycle because of the continuous and iterative nature of DevOps practices.&lt;/p&gt;

&lt;p&gt;Even though specific DevOps stages may vary depending on the organization's culture, the following stages are common in a typical DevOps lifecycle:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Plan
&lt;/h4&gt;

&lt;p&gt;In this initial stage, the project requirements, goals, and timelines are developed to optimize the business impact. &lt;/p&gt;

&lt;p&gt;Various resources are allocated while the communications channels are established. Jira is a  common tool used in DevOps planning &lt;/p&gt;

&lt;h4&gt;
  
  
  2. Code
&lt;/h4&gt;

&lt;p&gt;In this stage, developers write and review code to implement the business solution created in the planning stage. &lt;/p&gt;

&lt;p&gt;Typically, the agile approach is used during this stage while tools like Git and Bitbucket come in handy in keeping track of the changes made in the code&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Build
&lt;/h4&gt;

&lt;p&gt;Next, the source code from the coding stage is converted into a form that can be executed by a computer. &lt;/p&gt;

&lt;p&gt;To create the executable artifact, the source code is integrated, compiled, and packaged along with the necessary dependencies. &lt;/p&gt;

&lt;p&gt;Some of the tools used in the Build stage of the DevOps lifecycle are Apache Maven, Gradle, and Ant.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Test
&lt;/h4&gt;

&lt;p&gt;Software testing involves checking the right product was built (Verification) and the product was built in the right way(Validation).&lt;/p&gt;

&lt;p&gt;Various tests such as unit, component integration, system integration, and user acceptance testing are done using tools such as Junit, Cypress, Selenium, Jmeter, and pytest.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Release
&lt;/h4&gt;

&lt;p&gt;In the release stage, a build that consists of all dependencies is prepared to be deployed using tools such as Gradle are used in this stage&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Deploy
&lt;/h4&gt;

&lt;p&gt;In this stage, the application is made available to the users. A continuous deployment strategy is commonly utilized to allow frequent automated deployments in the production environment.&lt;/p&gt;

&lt;p&gt;Some of the tools used in the DevOps deployment stage are GitHub Actions, Jenkins, Gitlab CI/CD, CicrleCI, and TravisCI.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Operate
&lt;/h4&gt;

&lt;p&gt;The operations team manages the deployed applications to ensure they are constantly available, secure, and reliable by looking at various things like system logs, metrics, and user interactions.&lt;/p&gt;

&lt;p&gt;Configuration management such as Ansible, Chef, and Puppet are used to configure  and manage applications and servers&lt;/p&gt;

&lt;h4&gt;
  
  
  8. Monitor
&lt;/h4&gt;

&lt;p&gt;Continuous monitoring helps the team identify bottlenecks in the production environment to help maintain a healthy and good infrastructure.&lt;/p&gt;

&lt;p&gt;Various tools are used to detect anomalies, gather data, analyze logs and metrics, and troubleshoot the systems to keep them optimized.&lt;/p&gt;

&lt;p&gt;Tools like Grafana, Prometheus, and Splunk are used during this stage of the DevOps lifecycle&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Benefits and Challenges of DevOps
&lt;/h2&gt;

&lt;p&gt;Atlassian &lt;a href="https://www.atlassian.com/whitepapers/devops-survey-2020"&gt;DevOps Trends Survey&lt;/a&gt; shows that 99% of the participant's organizations had significantly benefited after adopting DevOps culture.&lt;/p&gt;

&lt;p&gt;Some of the DevOps benefits are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed:&lt;/strong&gt; The software building and testing processes are automated which makes it to frequently deliver DevOps releases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Frequent deployments&lt;/strong&gt; As a result of the frequent releases DevOps teams quickly push their change to the production environment which is a competitive advantage when fixing bugs are implementing new features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved code Quality&lt;/strong&gt; DevOps embraces shift left testing. Hence bugs are detected early which not only improves code quality but also makes it cheaper to fix&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved collaborations&lt;/strong&gt; By having the development and operations as a single entity, communications across the team are significantly improved which results in better innovations&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, DevOps is a practice and set of tools that empower the development and operations team to deliver reliable and quality customer solutions quickly.&lt;/p&gt;

&lt;p&gt;By embracing automation,  continuous integration and deployment, collaboration, and Infrastructure as Code, many organizations have benefited after adopting DevOps.  &lt;/p&gt;

</description>
      <category>devops</category>
      <category>beginners</category>
      <category>automation</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Debugging in JavaScript</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Fri, 23 Sep 2022 20:04:48 +0000</pubDate>
      <link>https://dev.to/ericawanja/debugging-in-javascript-4ppb</link>
      <guid>https://dev.to/ericawanja/debugging-in-javascript-4ppb</guid>
      <description>&lt;p&gt;Since bugs are quite obvious in software development, Debugging is a skill that every software developer should learn to succeed in their career. &lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it&lt;/em&gt;.&lt;br&gt;&lt;br&gt;
&lt;cite&gt;Benjamin Kernighan&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;Debugging is a part of software testing process which involves finding and fixing errors in a software before releasing it to the public. It entails not only inserting corrective code but also removing defective code. &lt;/p&gt;

&lt;p&gt;Besides, that it helps software developers understand why and how things are happening in the code. As a result, debugging helps software developers learn faster and better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of errors to debug
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/duL28c2tptZ0zAopCf/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/duL28c2tptZ0zAopCf/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Syntax errors
&lt;/h3&gt;

&lt;p&gt;A syntax error occurs when a programming rule is broken. For instance, misspelling keywords, using a variable that has not been declared, or failing to close an opening bracket. &lt;/p&gt;

&lt;p&gt;Note that, syntax errors depend on the syntax rules of the programming language.&lt;br&gt;
The execution of the program stops when a syntax error is encountered and an error is thrown. Hence, it is relatively easy to find syntax errors.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Logic errors
&lt;/h3&gt;

&lt;p&gt;Logic error occurs when a program produces an unexpected output.  Such errors are usually caused by algorithm issues such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect program design. Use flowcharts to visualize the code flow&lt;/li&gt;
&lt;li&gt;Creating an infinite loop without a break statement&lt;/li&gt;
&lt;li&gt;Incorrect use of Booleans or logical operators&lt;/li&gt;
&lt;li&gt;Having the same variable names for different objects&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The key difference between logic and syntax errors is that a program with logic error will run but produce an unexpected result. On the other hand, a program with logic error will not run.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  3. Run-time errors
&lt;/h3&gt;

&lt;p&gt;Unlike other errors which occur when you are interacting with the code on your device, Run time errors occur when the user is interacting with the software.&lt;/p&gt;

&lt;p&gt;For instance, if a user clicks a button to display the sixth element in an array of 5 elements which returns an undefined message.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to debug in JavaScript
&lt;/h2&gt;

&lt;p&gt;The common ways to debug JavaScript code are;&lt;/p&gt;
&lt;h3&gt;
  
  
  Using the console
&lt;/h3&gt;

&lt;p&gt;The console object provides an access to the browser debugging console by using ctrl + shift + I for windows and command + option + k for mac. &lt;/p&gt;

&lt;p&gt;Besides console.log() method which you must have interacted with as a JavaScript dev, there several other console methods.&lt;/p&gt;
&lt;h4&gt;
  
  
  JavaScript Console methods
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;console.log()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Console.log() prints an output on the console.  You can use it to check the input or outputs of a program.&lt;br&gt;
 For instance;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;x&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;y&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="nf"&gt;sum&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;3&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;We expect the above function to return 5, however it returns 23. It is quite easy to spot the error here since the arguments are static but could be hard if the arguments were dynamically received from another function. &lt;/p&gt;

&lt;p&gt;You can console.log each of the parameters in the function to check their types&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;x&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;x&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="c1"&gt;// prints number string&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;y&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="nf"&gt;sum&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;3&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;2.console.table()&lt;/p&gt;

&lt;p&gt;console.table() displays an array or object as a table. It helps visualize various object keys and their values. For instance;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Erica&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;department&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;IT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Wanja&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hr&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;department&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;IT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//output &lt;/span&gt;

&lt;span class="err"&gt;┌─────────┬─────────┬─────────┬────────────┐&lt;/span&gt;
&lt;span class="err"&gt;│&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="err"&gt;│&lt;/span&gt;  &lt;span class="nx"&gt;name&lt;/span&gt;   &lt;span class="err"&gt;│&lt;/span&gt;  &lt;span class="nx"&gt;role&lt;/span&gt;   &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="nx"&gt;department&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;span class="err"&gt;├─────────┼─────────┼─────────┼────────────┤&lt;/span&gt;
&lt;span class="err"&gt;│&lt;/span&gt;    &lt;span class="mi"&gt;0&lt;/span&gt;    &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Erica&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;IT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;    &lt;span class="err"&gt;│&lt;/span&gt;
&lt;span class="err"&gt;│&lt;/span&gt;    &lt;span class="mi"&gt;1&lt;/span&gt;    &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wanja&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hr&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;   &lt;span class="err"&gt;│&lt;/span&gt;    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;IT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;    &lt;span class="err"&gt;│&lt;/span&gt;
&lt;span class="err"&gt;└─────────┴─────────┴─────────┴────────────┘&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Console.group()&lt;/p&gt;

&lt;p&gt;Have you ever had several console messages that it was difficult to differentiate them? Using console.group() helps group the console messages into indented blocks. Even better you can add a label to help identify them. &lt;/p&gt;

&lt;p&gt;To exit a console group, use console.groupEnd() as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users_details&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;userData&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;first user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;users_details&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="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupEnd&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="cm"&gt;/*output
userData
  first user Erica
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Console.trace()
When interacting with a large codebase, it might be strenuous to understand where various functions have been declared. Console.trace() helps to trace the call path of the function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;foo&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;bar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;outputs;&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxn8tx80xg84wxt651mq5.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%2Fxn8tx80xg84wxt651mq5.png" alt="file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;console.assert()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Console.assert prints a message to the console if the expression evaluates to false&lt;/p&gt;

&lt;p&gt;syntax: &lt;code&gt;console.assert(expression, message)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Expression returned false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="c1"&gt;// prints the message if the sum is not equal to `11 &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Debugger
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;debugger&lt;/code&gt; keyword stops code execution and calls for available debugging functionalities. &lt;/p&gt;

&lt;p&gt;Run the below code on the browser and inspect to see the &lt;code&gt;debugger&lt;/code&gt; in action. You can check on this &lt;a href="https://www.youtube.com/watch?v=7qZBwhSlfOo" rel="noopener noreferrer"&gt;demo&lt;/a&gt; to understand JavaScript debugger and breakpoints.&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;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;debugger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Final Words
&lt;/h3&gt;

&lt;p&gt;Follow me on &lt;a href="https://twitter.com/EricaWanja" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;More resources on debugging&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=TtsvMRxmfGA&amp;amp;t=828s" rel="noopener noreferrer"&gt;Essential JavaScript debugging tools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Objects in JavaScript For beginners</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Wed, 03 Aug 2022 11:28:00 +0000</pubDate>
      <link>https://dev.to/ericawanja/objects-in-javascript-for-beginners-38l2</link>
      <guid>https://dev.to/ericawanja/objects-in-javascript-for-beginners-38l2</guid>
      <description>&lt;p&gt;Objects are dictionary like items which are defined as a key-value pair. &lt;/p&gt;

&lt;p&gt;It is a reference data type. That is, object variables are assigned reference pointer that points the location storage in memory. Loosely speaking, if you modify the assigned variable(pointer) then the original value in the memory will be modified too. &lt;/p&gt;

&lt;p&gt;Unlike arrays, objects are unordered hence you cannot use indexes to access items. Don't worry we will discuss later how to access items.&lt;/p&gt;

&lt;p&gt;Example of an object;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&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;h2&gt;
  
  
  How to create an object in JavaScript
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Object literal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the easiest way to create objects in JavaScript where you define and initialize the object inside curly brackets with a key:value pair. &lt;/p&gt;

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

&lt;p&gt;The key, which is also referred to as a property name must be a string  while the value property can be of any data type.&lt;/p&gt;

&lt;p&gt;For instance;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&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;The variable &lt;code&gt;person&lt;/code&gt; has two properties, i.e &lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;New Object keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use the &lt;code&gt;new Object()&lt;/code&gt;constructor to initialize an object.&lt;br&gt;
Notice in this case, you will have to add the properties later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&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;Object&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//initializing an object&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// adding property firstName with a value of John&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Doe&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;ul&gt;
&lt;li&gt;Object constructor&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Object constructor function acts as a blueprint for creating multiple objects. The key values are passed as function parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;last&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;eye&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;last&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;eyeColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;eye&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;//lets create student1 and student2 objects&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;student1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&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;Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&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;student2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sally&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;Rally&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;green&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;## When should you use objects&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Objects are useful in storing with a key-value pair&lt;/li&gt;
&lt;li&gt;Useful in grouping values with similar characteristics together to make your code more readable.
## Drawbacks of JavaScript objects&lt;/li&gt;
&lt;li&gt;Object properties are unordered, hence does not support accessing items with indexes. You must know the property name.&lt;/li&gt;
&lt;li&gt;Does not support operations such as adding or removing an item at a particular position.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;## How to access items in an object&lt;/p&gt;

&lt;p&gt;Object properties can be accessed using a dot or bracket notation.&lt;/p&gt;

&lt;p&gt;For instance:&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="c1"&gt;// outputs 'John'&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lastName&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;//outputs 'Doe'&lt;/span&gt;

&lt;span class="c1"&gt;//Notice that the property is passed as a string in the bracket notation.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you access an unassigned property in an object it outputs &lt;code&gt;undefined&lt;/code&gt; and not &lt;code&gt;null&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="c1"&gt;//undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dot operation can only be used if the property is a valid JavaScript identifier.&lt;/p&gt;

&lt;p&gt;A dot operation will throw an error if the property name has a space, hyphen or if the property is dynamically determined. In such circumstances use the bracket notation.&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;address&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="s1"&gt;building no&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3960&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;street&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;North 1st street&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;USA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;building no&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;//3960&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to add and change properties in an object
&lt;/h2&gt;

&lt;p&gt;Adding properties in objects is so simple. Access the property and assign a value to it. Let's add age and building no to our person object.&lt;/p&gt;

&lt;p&gt;Similarly, you can change a value property by assigning it to a new value.&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;building no&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3960&lt;/span&gt;
&lt;span class="c1"&gt;//change the firstName to Jane&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Jane&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;//16&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;building no&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c1"&gt;//3960&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to delete properties in an object
&lt;/h2&gt;

&lt;p&gt;The delete operator is used to delete both the property and its value in objects.&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="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; 
&lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;building no&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="cm"&gt;/* Before deletion: person.age = 16, 
                   person['building no'] = 3960
after deletion, person.age = undefined
                  person['building no']= undefined
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;## How to iterate an object&lt;br&gt;
The fastest way to transverse an object is using &lt;code&gt;for..in&lt;/code&gt; loop.&lt;/p&gt;

&lt;p&gt;For instance;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// outputs all the properties&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to check if a property exists in an object
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;in&lt;/code&gt; operator to check if a certain property exists in the object. It returns a boolean.&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;country&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;similarly, the &lt;code&gt;hasOwnProperty()&lt;/code&gt; method can be used to check if the property exist.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasOwnProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;in&lt;/code&gt; vs &lt;code&gt;hasOwnProperty()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;in&lt;/code&gt; returns true if the object exists in the object even if it has been inherited from another object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;16&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;obj2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// &lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//outputs true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However &lt;code&gt;hasOwnProperty()&lt;/code&gt; method returns true only if the property is a direct property of the object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;16&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;obj2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// &lt;/span&gt;
&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;//adding the name property&lt;/span&gt;

&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasOwnProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;
&lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasOwnProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note;&lt;code&gt;obj2.hasOwnProperty('age')&lt;/code&gt; returns false because age is not a direct property of the obj2.&lt;/p&gt;

&lt;h2&gt;
  
  
  object methods
&lt;/h2&gt;

&lt;p&gt;An object method, is an object property that is a function.&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastName&lt;/span&gt; 
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// John Doe&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;this&lt;/code&gt; keyword is used to refer to the object&lt;/p&gt;

&lt;p&gt;Note: You can also pass parameters in the method&lt;/p&gt;

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

&lt;p&gt;Objects are a very important data-type in JavaScript since it forms a building block of many other data structures such as linked list and modern JavaScript classes.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Maps in JavaScript</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Wed, 03 Aug 2022 11:12:00 +0000</pubDate>
      <link>https://dev.to/ericawanja/maps-in-javascript-3ng2</link>
      <guid>https://dev.to/ericawanja/maps-in-javascript-3ng2</guid>
      <description>&lt;p&gt;Map data structure was introduced in ES6. It has a similar key-value pair syntax as the objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a map
&lt;/h2&gt;

&lt;p&gt;You can create a map by passing an array of the key-value pairs into the &lt;code&gt;new Map&lt;/code&gt; constructor&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&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;Map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bananas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="c1"&gt;//  Map(3) { 'apples' =&amp;gt; 500, 'bananas' =&amp;gt; 300, 'oranges' =&amp;gt; 200 }&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Alternatively, you can use set() method to add elements into the map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&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;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bananas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="c1"&gt;//  Map(3) { 'apples' =&amp;gt; 500, 'bananas' =&amp;gt; 300, 'oranges' =&amp;gt; 200 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What are the differences between a map and object
&lt;/h2&gt;

&lt;p&gt;Same as objects, maps store key, value pair elements. However, the two are significantly different&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Map&lt;/th&gt;
&lt;th&gt;Objects&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keys&lt;/td&gt;
&lt;td&gt; A map key can be any value. This includes objects, functions or primitives&lt;/td&gt;
&lt;td&gt;Strictly, objects  key must be a string or symbol data type&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;Lengh&lt;/td&gt;
&lt;td&gt; Map has a size property which returns the length of the map&lt;/td&gt;
&lt;td&gt; The length of an object can only be determined by iterating and counting all the elements manually&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;Iteration&lt;/td&gt;
&lt;td&gt;Directly iterable&lt;/td&gt;
&lt;td&gt;You cannot iterate an  object directly. However you can do so by implementing other methods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Default keys&lt;/td&gt;
&lt;td&gt;Map only contains keys that are explicitly declared. Hence, does not contain default keys&lt;/td&gt;
&lt;td&gt;Since objects has a prototype, it contains default keys which can collide with other keys&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Map operations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;add element &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;set()&lt;/code&gt; method is used to add elements to a map. The set method receives the key-value pair of the new element as a parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;get element
&lt;code&gt;get()&lt;/code&gt; method receives the a key parameter of the element
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// outputs 50&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Remove element
&lt;code&gt;delete()&lt;/code&gt; method deletes element from the map.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&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;ol&gt;
&lt;li&gt;Clear Map
&lt;code&gt;clear()&lt;/code&gt; method removes all the elements from a map
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Trasverse a map
&lt;code&gt;forEach()&lt;/code&gt; can be used to access the items in a list sequentially
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&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;Map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bananas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="cm"&gt;/*
  output
  apples 500
  bananas 300
  oranges 200
  */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;keys()&lt;/code&gt; returns an iterable list of the keys. Similarly, &lt;code&gt;values()&lt;/code&gt; returns an iterable list of the values&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&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;Map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bananas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
 &lt;span class="cm"&gt;/*outputs
 { 'apples', 'bananas', 'oranges' }
 */&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="cm"&gt;/*outputs
{ 500, 300, 200 }
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;entries()&lt;/code&gt; transverses the map and returns an array of key-value pair &lt;code&gt;[key, values]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&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;Map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apples&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bananas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

 &lt;span class="cm"&gt;/*
 {
  [ 'apples', 500 ],
  [ 'bananas', 300 ],
  [ 'oranges', 200 ]
}
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Find size of a map
&lt;code&gt;size&lt;/code&gt; property returns the length of the map
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="c1"&gt;//outputs 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Even though objects and maps look quite similar, they are quite different. Map have size property and the keys can be anything including functions and objects.&lt;br&gt;
Objects do not have size property while the keys must be strictly strings. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Linked List Data structure</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Sun, 24 Jul 2022 18:16:00 +0000</pubDate>
      <link>https://dev.to/ericawanja/linked-list-data-structure-11l8</link>
      <guid>https://dev.to/ericawanja/linked-list-data-structure-11l8</guid>
      <description>&lt;p&gt;Linked list is a linear data structure with  items(nodes) with links pointing to other items in the list.&lt;br&gt;
The are three types of linked lists:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Singly linked list - the nodes have one pointer to the next item in the list. The last node points to null. &lt;/li&gt;
&lt;li&gt;Doubly linked lists - every node has two pointers, one pointing to the previous element in the list and the other pointer pointing to the next element.&lt;/li&gt;
&lt;li&gt;Circular linked list - The last node points to the first element in the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article we will be looking at singly linked list.&lt;/p&gt;

&lt;p&gt;An item in singly linked list has two main parts. The first part &lt;br&gt;
holds the data value while the other parts contains a link to the next item. However, the last item has nothing to point to thus its next value is null. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1hl6l08urtaftei4i2g5.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%2F1hl6l08urtaftei4i2g5.png" alt="Linked lists"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why and when to use the Linked lists
&lt;/h2&gt;

&lt;p&gt;Linked lists are recommended if you have a list of objects with links to the next item in the list. Its main advantage is; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy insertion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inserting an element in array is quite expensive because you will have to shift all other items. Similarly, deleting an element in array, will leave holes or else you will have to shift the positions of the elements after the removed element.&lt;/p&gt;

&lt;p&gt;However when using the Linked List you can easily transverse a list and insert or remove  a node at the required position.&lt;/p&gt;
&lt;h2&gt;
  
  
  Drawbacks of linked lists
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Does not support random access of elements. Thus, you will have to transverse through the list sequentially from the first element. This can be quite time consuming especially on the worst case.
## How to create a linked list&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you might have noted from the above diagram, every item in the linked list has the data part and link to the next value.&lt;br&gt;
 Below is a code template for a node (data item) in linked list. You can check the complete code snippets used &lt;a href="https://github.com/Ericawanja/Javascript-Data-structure-and-Algorithms/blob/main/Linked%20Lists/Leetcode%20Linked%20list%20problems/LinkedList.js" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let us initialize a linked list. &lt;br&gt;
 Note, that the head will have a null value  and a size of zero because we have not added any items yet.&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;class&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LinkedList&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;//methods&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1. Insert Node at the first position (head)
&lt;/h2&gt;

&lt;p&gt;To insert a node at the first position we will use the Node constructor.&lt;/p&gt;

&lt;p&gt;We will create a new node with a data property of the value to be inserted and next property of the previous head.&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="nf"&gt;insertFirst&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Insert Node at the Last position (Tail)
&lt;/h2&gt;

&lt;p&gt;To insert an element at the tail, we will have to transverse through the list untill we get to the last value which points to null.&lt;/p&gt;

&lt;p&gt;We will assign the new node to the next value of the last node.&lt;/p&gt;

&lt;p&gt;Don't forget to check if the head is empty. If so, the new node will be the head.&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="nf"&gt;insertLast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;//if empty make the node the head&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// the loop terminates when  the pointer gets to a node whose next property is null&lt;/span&gt;
        &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Insert Node at index
&lt;/h2&gt;

&lt;p&gt;The first thing to do when working with an index, is to check if the index is valid. That is, not less than zero or greater than the size of the list.&lt;/p&gt;

&lt;p&gt;If the index is equal to zero, the node is to be made the head.&lt;/p&gt;

&lt;p&gt;Else, we will transverse the list checking if the position is less than the index using two pointers.&lt;br&gt;
The previous pointer points to the element just before the position to insert the node while the current points to the node on the position we want to add the node.&lt;/p&gt;

&lt;p&gt;When the loop terminates, the next property of the previous item will point to the node to be added &lt;code&gt;previous.next = node&lt;/code&gt; and the next item of the new node will point to the current item, &lt;code&gt;node.next = current&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nf"&gt;insertatIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Checking if the index is valid. That is, less than zero or greater than the size &lt;/span&gt;

      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;//inserting at the first position. You can reuse the insertFirst()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//making the new node the head and the next value, the previous head&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// creating the node using the Node class&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// &lt;/span&gt;

    &lt;span class="c1"&gt;//set current to first&lt;/span&gt;
    &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;//looping through untill you get to the index &lt;/span&gt;
    &lt;span class="k"&gt;while&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;lt;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;previous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&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;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Get Node at index
&lt;/h2&gt;

&lt;p&gt;To get an element at a particular index in linked list, loop through the list checking if the current position is equal to the index.&lt;/p&gt;

&lt;p&gt;If the position value is equal to the index, output its data value.&lt;/p&gt;

&lt;p&gt;Else, increment the position and move the pointer to the next item.&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="nf"&gt;getAt&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="c1"&gt;// the loop terminates if the currenmt value (this.head) is null&lt;/span&gt;
        &lt;span class="k"&gt;if&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;==&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&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;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// moving the pointer to the next value&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;h2&gt;
  
  
  5. Remove node at index
&lt;/h2&gt;

&lt;p&gt;First, check if the index is valid. That is, it is not less than zero or greater than the size if you know the size.&lt;/p&gt;

&lt;p&gt;If the head is  eqaul to zero, then you should remove the first value by moving the head pointer to the &lt;code&gt;head.next&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, transverse through the list to find the node with the link to the node to be deleted (previous) and the element after the node to be deleted (current next).&lt;br&gt;
Note: the node to be removed is at  the  position equal to the index.&lt;/p&gt;

&lt;p&gt;To remove the node,  the next property of the previous should point to the next element after the item to be deleted. That is &lt;code&gt;previous.next = current.next&lt;/code&gt;&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbhq0se7c56yudy74lxf.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%2Fpbhq0se7c56yudy74lxf.png" alt="Linked lists"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nf"&gt;removeAtIndex&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="c1"&gt;//checking if the index is valid&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Deleting from beginning &lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="nx"&gt;previous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;     
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;previous&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Clear List
&lt;/h2&gt;

&lt;p&gt;An empty linked list has the head value as null. Hence to clear the list you need to point the head value to null.&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="nf"&gt;clearList&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&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;h2&gt;
  
  
  7. Transverse a linked list
&lt;/h2&gt;

&lt;p&gt;We transverse through a linked list using the head pointer. Remember that the head pointer refers to the first node. &lt;/p&gt;

&lt;p&gt;On the while loop, we will check that head is not equal to null. That is, the list is not empty or we have not exhausted looping through the list and print head.data ( remember that a node is an object) and then move the pointer to the next value.&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="nf"&gt;printList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Big O Analysis
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;O&lt;/th&gt;
&lt;th&gt;Explanation&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Insertion&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt; You just need to change the pointers of the previous node and the next node&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deletion&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;

&lt;td&gt; You need to change the pointer of the previous node only
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt; We have iterate sequentially over every element until we get to the target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traversing&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;We have to sequentially iterate over ever element&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;The best way to understand data structures is through practice. After understanding the basics, try writing the code snippets or look for leetcode problems and solve.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Google chrome extension manifest v3 for beginners</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Sun, 12 Jun 2022 21:14:39 +0000</pubDate>
      <link>https://dev.to/ericawanja/google-chrome-extension-manifest-v3-for-beginners-5ao3</link>
      <guid>https://dev.to/ericawanja/google-chrome-extension-manifest-v3-for-beginners-5ao3</guid>
      <description>&lt;p&gt;Manifest file uses JSON format to describe the important information about the extension. It contains fields that are required, recommended while other are optional depending on the extension you are building.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; refers to the name of the extension and should be up to 45 characters.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;version&lt;/code&gt; digits separated by dots showing the extension version. For example; 1.0.0&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;manifest_version&lt;/code&gt; version of the manifest. The latest is 3&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;host_permissions&lt;/code&gt; It is a group of URLs which the extension needs extra privileges. you must specify the host permissions in manifest v3 and higher.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&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;My YT Bookmarks&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;version&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;0.1.0&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;description&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;Saving timestamps in YT videos&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;permissions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;storage&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;tabs&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;host_permissions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://*.youtube.com/*&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;manifest_version&lt;/span&gt;&lt;span class="dl"&gt;"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recommended fields are;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt;- brief details on the functionality of the extension&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;action&lt;/code&gt;  action key allows us to use the chrome.action API to control the toolbar for your extension in chromes UI. It also allows us to specify the objects of default icons, the default title and the default popup html.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&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;Saving timestamps in YT videos&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;action&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;default_icon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;16&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;assets/ext-icon.png&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;24&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;assets/ext-icon.png&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;32&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;assets/ext-icon.png&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;default_title&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;My YT Bookmarks&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;default_popup&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;popup.html&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;The optional fields are;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;code&gt;author&lt;/code&gt;  it is a string of the authors name
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;author&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;Erica&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;background&lt;/code&gt; background scripts interact with the events through the Chrome API. These scripts are registered as an object using the &lt;code&gt;service_worker&lt;/code&gt; key.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;service_worker&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;background.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;permissions&lt;/code&gt; – extensions may require various permissions such s to use chrome storage to function properly. The permissions required are passed as an array of strings.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;permissions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;storage&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;tabs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;web_accessible_resources&lt;/code&gt; it is an array of objects that declare the various resource such as images or any other asset needed by the extension
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;web_accessible_resources&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;resources&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;assets/bookmark.png&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;assets/play.png&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;assets/delete.png&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;assets/save.png&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;matches&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://*.youtube.com/*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;content_scripts&lt;/code&gt; are scripts that can manipulate the page’s DOM and run in context of a particular page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content_scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;matches&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://*.youtube.com/*&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;js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;contentScript.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the script is using a JavaScript library, then it should also be injected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content_scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;matches&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://*.youtube.com/*&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;js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;jquery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;contentScript.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final remarks
&lt;/h2&gt;

&lt;p&gt;There is much more to do with chrome extensions, but this is a great starting point. We will be looking on all other files in details soon&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Git and GitHub for beginners</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Sun, 28 Nov 2021 19:37:25 +0000</pubDate>
      <link>https://dev.to/ericawanja/git-and-github-for-beginners-33a0</link>
      <guid>https://dev.to/ericawanja/git-and-github-for-beginners-33a0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Topics covered&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introduction to version control systems&lt;/li&gt;
&lt;li&gt;Git and GitHub&lt;/li&gt;
&lt;li&gt;Branching and merging&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/ericawanja/how-to-contribute-on-github-2p18"&gt;How to contribute to open source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/ericawanja/how-to-contribute-on-github-2p18"&gt;How to sync your Repo&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Git and GitHub are must-learn tools for every software developer. These tools not only make it easy to track changes in your personal projects, but they also make it seamless to contribute and coordinate team projects. This guide is to help every beginner to harness their skills and have an easy time learning and using these tools. Let’s get into it.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is a version control system?
&lt;/h1&gt;

&lt;p&gt;Version control systems are tools that are used by software developers to track and manage changes in a project. These tools keep track of the change made, who made and the time it was made. Thus, making it easy to turn back to the previous versions of a document and identify errors if they occur.&lt;/p&gt;

&lt;h4&gt;
  
  
  Types of version control systems
&lt;/h4&gt;

&lt;p&gt;There are three main types of VCS, namely;&lt;br&gt;
• Local version control system&lt;br&gt;
• Centralized version control system&lt;br&gt;
• Distributed version control system&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A local version&lt;/em&gt; control system is a type of VCs that uses the local database in your computer to store the changes made. It stores them as a patch where every patch contains the changes made to the file since the previous versions and not the entire file. Consequently, to see how the file appeared at any instance, you have to add all the relevant patches to come up with the document.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9z6317zxcmucgl9kozv.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%2Fw9z6317zxcmucgl9kozv.png" alt="lvcs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A centralized version&lt;/em&gt; control system uses a central server to store the repository. Thus every developer must be connected to the central server to access the repository and make the changes. Even though it is quite easy to maintain a single repository in the server, in case the central server crashes, you may risk losing the data which is a major drawback. An example of centralized VCS is &lt;a href="https://subversion.apache.org/" rel="noopener noreferrer"&gt;Apache Subversion&lt;/a&gt; which is abbreviated SVN.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdl9fhu1r5dmhvoj4layx.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%2Fdl9fhu1r5dmhvoj4layx.png" alt="cvcs"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Distributed VCS
&lt;/h2&gt;

&lt;p&gt;Unlike the centralized VCS, every contributor has their own local copy of the main repository. Thus they can change, update and commit to their local repository without interfering with the main repository. The contributors copy the main repository by cloning it. Also, they have to stage, commit and push the changes to make them available for other contributors to see.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7yopqorgos3tno6v0sjh.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%2F7yopqorgos3tno6v0sjh.png" alt="dvcs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After knowing what a version control system let is us dive into GIT&lt;/p&gt;
&lt;h1&gt;
  
  
  What is git?
&lt;/h1&gt;

&lt;p&gt;Git is an open-source distributed version control software that was created in 2005 by Linus Torvalds for the Linux kernel. It allows a team of developers to work on a project where each of them has a copy of their main repository which is located in the central server.&lt;/p&gt;

&lt;p&gt;Features of Git&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Free and open-source- you don’t have to pay anything to use Git. Also, its source code is available openly, hence you can modify it to your preference.&lt;/li&gt;
&lt;li&gt; Distributed development- Git supports cloning where the contributors can store a local copy of the  main repository&lt;/li&gt;
&lt;li&gt; Supports non-linear development – git supports independent lines of code known as branches, which can be staged, committed, and updated independently of the main codebase. Hence, branching gives a developer a safe space to implement and test something new without interfering with the codebase. The branches can later be merged into the codebase.&lt;/li&gt;
&lt;li&gt; Scalable- Git is quite scalable making it easy to handle an increase in the number of collaborators.&lt;/li&gt;
&lt;li&gt; Secure – this tool uses the secure hash function (SHA1) for naming and identifying objects in a repository. Hence every change is well monitored making it impossible to make changes without being noticed.
##What is GitHub?
&lt;em&gt;GitHub&lt;/em&gt; is a hosting company that was founded in 2008 that provides a platform for developers to host and share their projects. it provides access control and management features for every hosted project. Basically, it offers source code management among other features of git.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are many alternatives to GitHub such as GitLab and bitbucket. Consequently, you do not necessarily need GitHub to use git, but you require git to use GitHub.&lt;/p&gt;
&lt;h1&gt;
  
  
  Getting started with GIT
&lt;/h1&gt;

&lt;p&gt;You need to install git on your operating system. This &lt;a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git" rel="noopener noreferrer"&gt;guide here&lt;/a&gt; will help you. &lt;br&gt;
Also, create a GitHub account, and let’s move on.&lt;/p&gt;
&lt;h2&gt;
  
  
  How git GitHub woks and its commands
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx2ul8z2eou71kyiiw4w2.jpg" 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%2Fx2ul8z2eou71kyiiw4w2.jpg" alt="github"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's discuss the diagram briefly;&lt;br&gt;
After the user makes changes on the working file, git takes notice of the recently modified files. the user can check the modified files using &lt;strong&gt;git status&lt;/strong&gt; command. &lt;/p&gt;

&lt;p&gt;The modified files are &lt;strong&gt;added&lt;/strong&gt; to a staging area which acts as the temporary location for the files.&lt;/p&gt;

&lt;p&gt;All the staged files are ready to be &lt;strong&gt;committed/moved&lt;/strong&gt; to a local repository. Up to this point the changes are only visible on the developer’s local machine and cannot be accessed by other contributors online.&lt;br&gt;
To make the file available online, you need to host on an online hosting service such as GitHub. So, you need to &lt;strong&gt;push&lt;/strong&gt; the local repository to sync it with the remote repository.&lt;/p&gt;

&lt;p&gt;Take an instance, that the other contributors have pushed changes to the remote repository. You must sync your local repository with the remote repository to be up-to-date with the changes done. To do that you use &lt;strong&gt;Git Pull&lt;/strong&gt; command which will sync your local repository.&lt;br&gt;
Let’s now look at the git commands&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Git status
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;git status&lt;/strong&gt; command lists all the files that have been modified recently and has not been added to the local repository. In the below case the Two Sum.md file has not yet been added to the local repository&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\Users\ERICA WANJA\Desktop\coding problems&amp;gt; git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add &amp;lt;file&amp;gt;..." to include in what will be committed)
        leetcode/Two Sum.md

nothing added to commit but untracked files present (use "git add" to track)
PS C:\Users\ERICA WANJA\Desktop\coding problems&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Git add
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;git add&lt;/strong&gt; command is used to move the files to the staging area for committing. To stage your files use the commands below;&lt;br&gt;
&lt;strong&gt;git add filename&lt;/strong&gt;- to add a specific file&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add -all&lt;/code&gt; which is shortened to &lt;code&gt;git add -A&lt;/code&gt;  stages all the files, that is the new, modified and deleted files. On the other hand the &lt;code&gt;git add .&lt;/code&gt; command stages only the new and modified files excluding the deleted files.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Git commit
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git commit&lt;/code&gt; moves the repository from the staging area to the local repository. In other words, it stores the snapshots of the changes made to the local repository instead of blindly copying the entire repository one more time. &lt;br&gt;
Every time you are making a commit you must give a brief message explaining the changes made.&lt;br&gt;
For example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit –m “solved the two sum problem”
```


###4. Git pull 
The pull command helps to keep your local repo up-to-date with the remote repository. It up streams any change made by another contributor in the remote repository to your local repository.
To pull the changes, you need to set the origin or parent remote repository
Command:


```
git remote add origin LinkToTheRemoteRepo
```


After setting the origin remote repository, you can now pull the changes using the below command;


```
git pull origin master
```


**Note:** it is a good practice that you pull the changes before the push command when working on a team’s project.
###5. Git push
`git push` command transfers the commits changes from the local repository to the remote repository(GitHub). Thus, the changes you have made will be published on the central repository and made available online. 
Commands
`git push  origin main ` pushes the commits to the main or the master branch
`git push origin branchName` pushes the commits to the named branch.(you will learn about branches shortly)

##Branching and merging on GitHub
**Branching** simply means creating a different line of development (branch) where you can test and experiment new things before implementing them into the main codebase. Thus practicing branching will save you from messing up with production codebase.

After testing the new changes on the branch, you can later on integrate them with the main line of development. This act of integrating the branches to the main line of development is known as **merging.**
##Git branch commands
`git branch branchname` command is used to create a new branch
`git checkout  branchname` command is used to move to the specified branch. After checking out to the branch you can now commit and push the changes.
`git checkout-b branchname` command is the short form of the above two commands. It creates a new branch and moves (checks out) to it at the same time.

##Creating remote branches
A locally created branch is only available on your device and not available to the other team members. You can push this local branch to make it available remotely using the below command.


```java
git push –u origin &amp;lt;name&amp;gt;
```


##Deleting branches
`git branch –d branchname` command is used to delete branches after merging the changes.
In some cases git may refuse to delete the branch if it has changes which have not been merged with the main branch which is a safety mechanism to prevent accidental loss of data. 

However, if you are sure you want top delete the branch with uncommitted changes, you can use the command below;


```
git branch –D branchname
```


Also, you use the following command to delete a remote repository;


```
git push origin --delete branchname
```



I greatly appreciate that you stopped by. I hope the article has been of help. You can also check this [article](https://dev.to/ericawanja/how-to-contribute-on-github-2p18/edit) on how to contribute on GitHub and how to sync your repository.




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

&lt;/div&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>How to contribute on GitHub</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Sun, 28 Nov 2021 19:33:04 +0000</pubDate>
      <link>https://dev.to/ericawanja/how-to-contribute-on-github-2p18</link>
      <guid>https://dev.to/ericawanja/how-to-contribute-on-github-2p18</guid>
      <description>&lt;p&gt;At the heart of GitHub is to make team collaboration seamlessly. You can only contribute to a public repository or a private repository where you have been added as a collaborator.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Fork the repository
&lt;/h3&gt;

&lt;p&gt;On GitHub move to the repository, you want to contribute to and fork it by clicking the fork button located on the upper right corner.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xxfslrio--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pze856dn4q4zhi95qkt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xxfslrio--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pze856dn4q4zhi95qkt.png" alt="Image description" width="826" height="270"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Clone the fork
&lt;/h3&gt;

&lt;p&gt;Cloning a git repository copies the content of the remote repository to your local device. While on the repository you have forked, click the green clone or download button and copy the displayed URL. &lt;br&gt;
On your device terminal, run the below command to clone the repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone URL_OF_Forked_Repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create a branch
&lt;/h3&gt;

&lt;p&gt;To start working on the codebase, you must first navigate to the project folder and create a branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd projectfolder
&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;git checkout –b branchname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Make the changes, stage, commit and push them
&lt;/h3&gt;

&lt;p&gt;After making the changes on your local repository, you need to make them available in the remote repository. Run the below commands&lt;br&gt;
&lt;code&gt;git status&lt;/code&gt; to check uncommitted changes&lt;br&gt;
&lt;code&gt;git add *&lt;/code&gt; to add all  the changes to the staging area&lt;br&gt;
&lt;code&gt;git commit –m ‘the commit message’&lt;/code&gt; command to commit the changes&lt;br&gt;
&lt;code&gt;git push origin branchName&lt;/code&gt; to push the changes to GitHub&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 5: Pull the requests
&lt;/h3&gt;

&lt;p&gt;on your GitHub account move to the repository that you have just committed the changes and refresh the page. You will see a green Compare and Pull request button. Click on it and the maintainer will merge the commits.&lt;/p&gt;
&lt;h1&gt;
  
  
  How to sync a repository
&lt;/h1&gt;

&lt;p&gt;While pulling the request you may run to some troubles such as having your repository several commits behind the main repository. That happens when a team member pull request gets merged after you had forked the repository.&lt;br&gt;
Consequently, you need to upstream the changes to sync it with your repo.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1:  Add a new remote upstream repository
&lt;/h3&gt;

&lt;p&gt;you should add a remote upstream repository as the parent of your local repo. That will give it a reference project where it will inherit any changes made. &lt;br&gt;
First, run &lt;code&gt;git remote -v&lt;/code&gt; to check if your repo has a parent&lt;br&gt;
If no parent is listed, run the below command to add one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Sync the repo
&lt;/h3&gt;

&lt;p&gt;To sync the repo, first, move to the main branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, fetch the changes from the original repository to your repo, by running the below command;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, merge the changes with the main branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;merge&lt;/span&gt; &lt;span class="n"&gt;upstream&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it, your forked repo is up to date, you can go on push the changes and pull the request.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>Quick Overview of CSS</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Wed, 24 Nov 2021 07:26:45 +0000</pubDate>
      <link>https://dev.to/ericawanja/quick-overview-of-css-5b71</link>
      <guid>https://dev.to/ericawanja/quick-overview-of-css-5b71</guid>
      <description>&lt;p&gt;Css is an acronym for cascading style is a styling language for HTML documents. It is used to define the appearance of the html elements.&lt;/p&gt;

&lt;p&gt;In other words, we would call it the &lt;em&gt;make up&lt;/em&gt; for the HTML&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/fuJPZBIIqzbt1kAYVc/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/fuJPZBIIqzbt1kAYVc/giphy.gif" alt="gif" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you attach CSS TO HTML?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;External css&lt;/strong&gt;&lt;br&gt;
To attach a css file externally, you need to create a separate file, save it with .css extension and attach it on the head section of your html document. &lt;em&gt;Note&lt;/em&gt; that the href attribute is used to define the path to your css file. Thus you must ensure that the pathname is correct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"myStylesheet.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!--the body--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Internal css&lt;/strong&gt;&lt;br&gt;
When using internal css, the styles are defined inside the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags on the head section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inline css
&lt;/h3&gt;

&lt;p&gt;The styles are defined inside the opening tag of the element as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color:red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is the first heading&lt;span class="nt"&gt;&amp;lt;/h&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Selectors
&lt;/h2&gt;

&lt;p&gt;Selectors are used to select the code block you want to apply the styles.&lt;br&gt;
syntax;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;Selector&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="py"&gt;Style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;value&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;They can be divided into five;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. simple selectors&lt;/strong&gt;&lt;br&gt;
They include;&lt;br&gt;
-Element name e.g. &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;span&lt;/code&gt;,  &lt;code&gt;div&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Content&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&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;-Id  e.g. &lt;code&gt;#title&lt;/code&gt;, &lt;code&gt;#first-par&lt;/code&gt;. &lt;strong&gt;Note&lt;/strong&gt;: that the id name should start with a &lt;strong&gt;#&lt;/strong&gt; symbol.&lt;br&gt;
e.g;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'first-par'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nf"&gt;#first-par&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&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;-Class selector e.g.  &lt;strong&gt;.title&lt;/strong&gt; Note that the class name is preceded by a dot.&lt;br&gt;
eg;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'par'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.par&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Combinator selector&lt;/strong&gt;&lt;br&gt;
They indicate relationship between elements. They include&lt;br&gt;
      -&lt;strong&gt;Descendant selector&lt;/strong&gt; e.g.  &lt;code&gt;div p{…..}&lt;/code&gt; selects &lt;em&gt;all the paragraph elements in div&lt;/em&gt;&lt;br&gt;
     -&lt;strong&gt;Child selector (&amp;gt;)&lt;/strong&gt;  e.g. &lt;code&gt;div &amp;gt;p{……}&lt;/code&gt; &lt;em&gt;selects all the p elements that are children of a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/em&gt;&lt;br&gt;
     -&lt;strong&gt;adjacent sibling ( + )&lt;/strong&gt;  selects an element that is directly after another specific element e.g. &lt;code&gt;div + p{…..}&lt;/code&gt; &lt;em&gt;selects all the paragraph after the div element&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Pseudo-class selector&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They are used to add styles to selectors only after meeting a certain condition&lt;br&gt;
Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nt"&gt;Selector&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;pseudo-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="py"&gt;Property&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;value&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;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#FF00FF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Pseudo-element selector&lt;/strong&gt;&lt;br&gt;
selects only a specific part of an element&lt;br&gt;
Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;Selector&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;pseudo-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="py"&gt;Property&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;value&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;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;::first-line&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ff0000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;small-caps&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;h2&gt;
  
  
  Flex box and GRID
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Flexbox&lt;/strong&gt; is a one dimensional layout design where you specify if the items should be horizontally or vertically aligned.&lt;br&gt;
References: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout&lt;/a&gt; &lt;br&gt;
&lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"&gt;https://css-tricks.com/snippets/css/a-guide-to-flexbox/&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Grid&lt;/strong&gt; is a two dimension layout design i.e rows and columns.&lt;br&gt;
&lt;a href="https://css-tricks.com/snippets/css/complete-guide-grid/"&gt;https://css-tricks.com/snippets/css/complete-guide-grid/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Transitions
&lt;/h2&gt;

&lt;p&gt;Transitions in CSS provide a way to control the speed of a changing property in css.&lt;br&gt;
 For instance, if you increase the width of an object it occurs instantly. However, with transitions you can decrease this speed such that you observe every change as it happens.&lt;br&gt;
Ref:&lt;br&gt;
-&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://www.w3schools.com/css/css3_transitions.asp"&gt;https://www.w3schools.com/css/css3_transitions.asp&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Animations
&lt;/h2&gt;

&lt;p&gt;CSS animations makes it possible to animate different styles without using JavaScript or a library&lt;/p&gt;

&lt;p&gt;Ref:&lt;br&gt;
-&lt;a href="https://www.w3schools.com/css/css3_animations.asp"&gt;https://www.w3schools.com/css/css3_animations.asp&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Responsive web design
&lt;/h2&gt;

&lt;p&gt;Responsiveness is the art of ensuring that a web page looks good in all devices. That is, the  web design should adjust accordingly depending on the screen size, orientation and the platform.&lt;br&gt;
The common ways to achieving responsiveness is use of flexible grids, media queries, and setting the viewport.&lt;br&gt;
&lt;a href="https://i.giphy.com/media/9oIP19hZ9kzKJUmpdU/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/9oIP19hZ9kzKJUmpdU/giphy.gif" alt="Image description" width="480" height="348"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  MEDIA QUERIES
&lt;/h2&gt;

&lt;p&gt;Media queries specify styles to be applied when certain conditions are meant.&lt;br&gt;
Example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;lightblue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Breakpoints
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;CSS breakpoints&lt;/strong&gt; are points where the website content responds according to the device width&lt;br&gt;
In the previous example, when the screen is resized to a maximum width of 600px, it will adopt to the given styles. i.e 600px is the breakpoint.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>css</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Quick overview of html</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Tue, 23 Nov 2021 15:24:31 +0000</pubDate>
      <link>https://dev.to/ericawanja/quick-overview-of-html-and-css-1eb5</link>
      <guid>https://dev.to/ericawanja/quick-overview-of-html-and-css-1eb5</guid>
      <description>&lt;p&gt;&lt;a href="https://i.giphy.com/media/l3vRfNA1p0rvhMSvS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l3vRfNA1p0rvhMSvS/giphy.gif" alt="Image description" width="621" height="249"&gt;&lt;/a&gt;&lt;br&gt;
HTML which is an abbreviation of hypertext markup language, is the standard markup language used in building websites. At the basic level it defines the structure of the website.&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"X-UA-Compatible"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"IE=edge"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--ALL OTHER CONTENT GOES HERE--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;An html document is made up of three sections;&lt;br&gt;
Declaration section which defines the type of the document&lt;br&gt;
The head section enclosed in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tags which contains the meta information and the title of document&lt;br&gt;
The body section enclosed between &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;/body&amp;gt;&lt;/code&gt; which is the part visible on the browser.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Tags
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Html tags&lt;/strong&gt; are keywords used to define how content will be displayed and formatted on a web browser.&lt;br&gt;
Example; &lt;code&gt;&amp;lt;p&amp;gt;A paragraph..&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Some tags have a closing tag while others do not have. Tags with only opening tags are also referred as &lt;em&gt;empty tags&lt;/em&gt;. For instance &lt;code&gt;&amp;lt;hr&amp;gt;&lt;/code&gt; which defines an horizontal line &lt;br&gt;
There are several types of tags such as;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heading tags&lt;/strong&gt; used to define headings, ranging from &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;. &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; defines the &lt;strong&gt;most important heading&lt;/strong&gt; while &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt; define the &lt;strong&gt;least important heading&lt;/strong&gt;.&lt;br&gt;
Example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Heading 1&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Heading 2&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h6&amp;gt;&lt;/span&gt;Heading 4&lt;span class="nt"&gt;&amp;lt;/h6&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;/p&gt;

&lt;h1&gt;Heading 1&lt;/h1&gt;

&lt;h2&gt;Heading 2&lt;/h2&gt;

&lt;h4&gt;Heading 4&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Paragraph tags&lt;/strong&gt; define a paragraph. &lt;code&gt;&amp;lt;p&amp;gt;A paragraph..&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure tags&lt;/strong&gt; that help in defining the structure of the html document. They include; &lt;em&gt;head&lt;/em&gt;, &lt;em&gt;html&lt;/em&gt;, and &lt;em&gt;body&lt;/em&gt; tags.&lt;br&gt;
 &lt;strong&gt;Formatting tags&lt;/strong&gt; which are used in defining how the elements should be displayed. For instance the &lt;em&gt;italics tag&lt;/em&gt; &lt;code&gt;&amp;lt;i&amp;gt;italics tag&amp;lt;/i&amp;gt;&lt;/code&gt; format the content to italics&lt;br&gt;
&lt;strong&gt;Self-closing tags&lt;/strong&gt; are tags which do not contain the closing tags. &lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Elements and Attributes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Html element&lt;/strong&gt; is made up of the html tags and the content inside the tag&lt;br&gt;
Example of a HTML elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;My First Heading&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Attributes&lt;/strong&gt; are used in html documents to provide extra information about elements. The attributes or the extra information is defined inside the opening tag using name value pairs: &lt;em&gt;name= “value”.&lt;/em&gt; &lt;strong&gt;Note&lt;/strong&gt; that the value is inside the quotes.&lt;br&gt;
For instance the &lt;code&gt;href attribute&lt;/code&gt; is used to specify the URL of a page;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://twitter.com/lux_academy"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Visit our twitter page&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Links
&lt;/h1&gt;

&lt;p&gt;Html links allow users to jump to another webpage when they click on it. Links in html are defined using the &lt;strong&gt;anchor tag&lt;/strong&gt; &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;. The tag has the &lt;em&gt;href&lt;/em&gt; attribute which defines the web page to be visited&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://twitter.com/lux_academy"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Follow us on twitter&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Lists
&lt;/h2&gt;

&lt;p&gt;Html lists are used to group related items. There are three types of html lists;&lt;br&gt;
     -Ordered lists&lt;br&gt;
     -Unordered lists&lt;br&gt;
     -Description lists&lt;/p&gt;
&lt;h3&gt;
  
  
  HTML ordered lists
&lt;/h3&gt;

&lt;p&gt;Ordered list is created using the &lt;code&gt;&amp;lt;ol&amp;gt; tags&lt;/code&gt; while the items are listed inside the &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;tags. The ordered items are marked with numbers by default.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ol&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;HTML&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Css&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;JavaScript&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;    
&lt;span class="nt"&gt;&amp;lt;/ol&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ordered list tag, &lt;code&gt;&amp;lt;ol&amp;gt;&lt;/code&gt;, has a type attribute, which is used to specify the ordering format. below are the different type attributes and there respective ordering formats.&lt;br&gt;
  -&lt;em&gt;type '1'&lt;/em&gt; -numbers&lt;br&gt;
  -&lt;em&gt;type 'I'&lt;/em&gt; -upper case roman numbers&lt;br&gt;
  -&lt;em&gt;type 'i'&lt;/em&gt; -lower case roman numbers&lt;br&gt;
  -&lt;em&gt;type 'A'&lt;/em&gt;  -upper case letters&lt;br&gt;
  -&lt;em&gt;type 'a'&lt;/em&gt;  -lower case letters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt; &lt;span class="nt"&gt;&amp;lt;ol&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"I"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;HTML&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Css&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;JavaScript&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/ol&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTML unordered lists
&lt;/h3&gt;

&lt;p&gt;Unordered list is created using the &lt;code&gt;&amp;lt;ul&amp;gt; tags&lt;/code&gt; while the items are listed inside the &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;tags. Its items are marked with bullets by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;HTML&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Css&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Javascript&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also has a type attribute used to define the type of bulleting;&lt;br&gt;
 -&lt;em&gt;type "disc"&lt;/em&gt; - items are marked with bullets&lt;br&gt;
 -&lt;em&gt;type "circle"&lt;/em&gt; -items are marked with circles&lt;br&gt;
 -&lt;em&gt;type "square"&lt;/em&gt;  -items are marked with circles&lt;br&gt;
 -&lt;em&gt;type "none"&lt;/em&gt;   -the items are not marked&lt;/p&gt;

&lt;p&gt;Example in a code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"circle"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;HTML&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Css&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
 &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Javascript&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;/p&gt;

&lt;ul&gt;  
 &lt;li&gt;HTML&lt;/li&gt;  
 &lt;li&gt;Css&lt;/li&gt;  
 &lt;li&gt;Javascript&lt;/li&gt;  
&lt;/ul&gt;  

&lt;h3&gt;
  
  
  Description list
&lt;/h3&gt;

&lt;p&gt;Html description list is a listing style where the items are listed alongside their descriptions. The &lt;code&gt;&amp;lt;dl&amp;gt;&lt;/code&gt; tag is used to create a description list, the items are listed inside the &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt; tags while their descriptions are stated in the &lt;code&gt;&amp;lt;dd&amp;gt;&lt;/code&gt; tags.&lt;br&gt;
For instance;&lt;/p&gt;

&lt;dl&gt;  
  &lt;dt&gt;Html&lt;/dt&gt;  
  &lt;dd&gt;-It is a markup language&lt;/dd&gt;  
  &lt;dt&gt;Css&lt;/dt&gt;  
  &lt;dd&gt;-Its is a styling language&lt;/dd&gt;     
&lt;/dl&gt;  

&lt;p&gt;&lt;strong&gt;code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dl&amp;gt;&lt;/span&gt;  
  &lt;span class="nt"&gt;&amp;lt;dt&amp;gt;&lt;/span&gt;Html&lt;span class="nt"&gt;&amp;lt;/dt&amp;gt;&lt;/span&gt;  
  &lt;span class="nt"&gt;&amp;lt;dd&amp;gt;&lt;/span&gt;-It is a markup language&lt;span class="nt"&gt;&amp;lt;/dd&amp;gt;&lt;/span&gt;  
  &lt;span class="nt"&gt;&amp;lt;dt&amp;gt;&lt;/span&gt;Css&lt;span class="nt"&gt;&amp;lt;/dt&amp;gt;&lt;/span&gt;  
  &lt;span class="nt"&gt;&amp;lt;dd&amp;gt;&lt;/span&gt;-Its is a styling language&lt;span class="nt"&gt;&amp;lt;/dd&amp;gt;&lt;/span&gt;     
&lt;span class="nt"&gt;&amp;lt;/dl&amp;gt;&lt;/span&gt;  

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Images
&lt;/h2&gt;

&lt;p&gt;Images are added on webpages to improve their appearance. The &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag is used to embed the image. This tag has two attributes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src&lt;/code&gt; attribute which defines the location  or the path to the image
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;alt&lt;/code&gt; attribute used to specify the text to be displayed if the image cannot be accessed.
Syntax;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"path"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"alternatetext"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tables
&lt;/h2&gt;

&lt;p&gt;HTML tables are used to display tabular data. Data is contained in the table cells inside the rows and columns.  A table is created in html using the &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; tag. Each row is defined by &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; tag, table headings are defined by &lt;code&gt;&amp;lt;th&amp;gt;&lt;/code&gt; while the data cells are defined by &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
Example of a simple html table;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Company&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Country&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;John Doe&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Germany&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Forms
&lt;/h2&gt;

&lt;p&gt;Forms are used in html to collect the user inputs which is sent to the server for processing. The &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; tag is used to define an html form.&lt;br&gt;
Some of the form elements are;&lt;br&gt;
&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; , &lt;code&gt;&amp;lt;label&lt;/code&gt;, &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;&lt;br&gt;
A simple html form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"fname"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First name:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"fname"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"fname"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"lname"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Last name:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"lname"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"lname"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Doe"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Final words
&lt;/h3&gt;

&lt;p&gt;Check on my &lt;a href="https://dev.to/ericawanja/quick-overview-of-css-5b71"&gt;Quick CSS overview article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>A simple introduction to react router</title>
      <dc:creator>Ericawanja</dc:creator>
      <pubDate>Wed, 10 Nov 2021 10:53:13 +0000</pubDate>
      <link>https://dev.to/ericawanja/a-simple-introduction-to-react-router-51cn</link>
      <guid>https://dev.to/ericawanja/a-simple-introduction-to-react-router-51cn</guid>
      <description>&lt;p&gt;React router is a library built on top of react, which is used to navigate multiple routes in single-paged applications. Thus, it allows the user to move to different components without having to refresh the app, reducing the loading time, which improves the user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s the need for the react router?
&lt;/h2&gt;

&lt;p&gt;Traditionally, when a user clicked a link to a new web page, the new data from the server would rewrite the entire web page and force the site to refresh, which renders a whole different page. These types of apps are known as multi-page apps.  Besides causing the pages to refresh, which takes some time, the users will see the pages redraw on the browser, which is not a good user experience and also it makes it hard to manage the app state.&lt;/p&gt;

&lt;p&gt;What’s the solution?&lt;/p&gt;

&lt;p&gt;The solution is changing from multi-page apps to single-page apps. In this rendering technique, you will never have to navigate to a whole new web page completely. Instead, the different components (known as views) will be loaded on the same page dynamically without navigating to an entirely new web page. This concept of single-page apps is used in popular web apps such as Facebook, Twitter, Instagram, etc.&lt;/p&gt;

&lt;p&gt;To achieve all that, you will require the &lt;strong&gt;react-router library&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  React router components
&lt;/h2&gt;

&lt;p&gt;The react-router library has three major components, namely;&lt;br&gt;
• Routers&lt;br&gt;
• Route matchers&lt;br&gt;
• Navigation links&lt;/p&gt;
&lt;h2&gt;
  
  
  Routers
&lt;/h2&gt;

&lt;p&gt;React router has two main routing components, namely, HashRouter and BrowseRrouter. These components define the routing region where you can use the navigation links and route matchers.&lt;/p&gt;

&lt;p&gt;• Browserouter is used in dynamic webpages that use databases and whose information changes frequently. This routing technique makes the use of HTML history API to store and access the locations visited by the user&lt;/p&gt;

&lt;p&gt;• Hashrouter, on the other hand, is used to route static web pages. The current location is stored on the hash portion of the URL. Thus the URL looks like this; &lt;a href="http://example.com#/about"&gt;http://example.com#/about&lt;/a&gt;. However, the # is never sent to &lt;br&gt;
the server. Hence it has no special meaning. &lt;/p&gt;
&lt;h2&gt;
  
  
  Navigation links
&lt;/h2&gt;

&lt;p&gt;React router provides &amp;lt;Link&amp;gt; tags that are used to create and change links. It is used in the place anchor tag (&amp;lt;a&amp;gt;) in HTML. Navigation links receive the to attribute whose value specifies the URL.&lt;br&gt;
Syntax;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Link to="/about"&amp;gt;About&amp;lt;/Link&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&amp;lt;NavLink&amp;gt;, which is also a navigation link in react-router, is a special type of &amp;lt;Link&amp;gt; component that is used to add styles when the current location matches with the route. This tag automatically inherits the active class when visited. The styles of the active class must be defined in the stylesheet.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;NavLink to="/about"&amp;gt;About&amp;lt;/NavLink&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Router matchers
&lt;/h2&gt;

&lt;p&gt;Router matchers help determine the components to be displayed when a certain URL is visited. The two main route matching components are &lt;code&gt;&amp;lt;Route&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Switch&amp;gt;&lt;/code&gt;&lt;br&gt;
    • &lt;code&gt;&amp;lt;Route&amp;gt;&lt;/code&gt; helps determine the connection between the URL specified on the  tag and the component displayed on the user interface. It has a path attribute that specifies the pathname to the component&lt;br&gt;
      • &lt;code&gt;&amp;lt;Switch&amp;gt;&lt;/code&gt; finds through its children a path that matches the requested URL and ignores others when it sees one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Switch&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;exact&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Switch&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Final remarks
&lt;/h1&gt;

&lt;p&gt;That was a simple introduction to the basics of react router. However, &lt;strong&gt;one good habit of a software developer is practicing and getting their hands dirty.&lt;/strong&gt; Thus, it will be wise of you also to check this &lt;a href="https://dev.to/ericawanja/understand-react-router-concepts-by-creating-a-simple-react-app-5e5g"&gt;simple hands-on guide with react router&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
