<?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: Emmanuel C. Okolie</title>
    <description>The latest articles on DEV Community by Emmanuel C. Okolie (@emmykolic).</description>
    <link>https://dev.to/emmykolic</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%2F850708%2F2531bcb4-2719-4ffc-bec8-eff8d16396dc.jpg</url>
      <title>DEV Community: Emmanuel C. Okolie</title>
      <link>https://dev.to/emmykolic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emmykolic"/>
    <language>en</language>
    <item>
      <title>How To Build An Interactive Quiz Project Using Vanilla JavaScript</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Mon, 10 Mar 2025 12:23:23 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-build-an-interactive-quiz-project-using-vanilla-javascript-jdh</link>
      <guid>https://dev.to/emmykolic/how-to-build-an-interactive-quiz-project-using-vanilla-javascript-jdh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;One fun thing about JavaScript is that it can be used to do a lot of mind-blowing things. Now, for educational purposes, I’ve always longed for an Interactive Quiz Project that beginners can easily follow.&lt;/p&gt;

&lt;p&gt;So for this Guide, we’ll be looking at how To Build An Interactive Quiz Project.&lt;/p&gt;

&lt;p&gt;After following the step-by-step guide in this tutorial, the Interactive Quiz Project will be up and running in your browser interface. Without wasting much of your time, let’s jump into this tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;To achieve the Interactive Quiz Project, you should be familiar with the following languages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step-by-Step Process Of Making  An Interactive Quiz Session
&lt;/h2&gt;

&lt;p&gt;So, we’re about to dive into the process of making a quiz session for this project! Note. We’ll be using basic arithmetic as our example.&lt;/p&gt;

&lt;p&gt;Without further delay, let’s head on. &lt;br&gt;
First, you’ll create a folder. In our case, we’re calling it &lt;strong&gt;&lt;code&gt;Quiz_Tutorial&lt;/code&gt;&lt;/strong&gt;  Then you’ll create a file inside of this folder and name it &lt;strong&gt;&lt;code&gt;index.html&lt;/code&gt;&lt;/strong&gt; Then you’ll open it in your code editor.&lt;/p&gt;

&lt;p&gt;so the index.html will contain codes like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
        &amp;lt;meta charset="utf-8"&amp;gt;
        &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
        &amp;lt;title&amp;gt;Quiz Tutorial&amp;lt;/title&amp;gt;
        &amp;lt;link rel="stylesheet" type="text/css" href="style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
        &amp;lt;div class="center"&amp;gt;
                &amp;lt;div id="quiz"&amp;gt;&amp;lt;/div&amp;gt;
                &amp;lt;button id="submit"&amp;gt;Get Results&amp;lt;/button&amp;gt;
                &amp;lt;div id="results"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;script type="text/javascript" src="main.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After doing this, your interface will look something like this 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F2v13kxzu2cbjnwi1zcr5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F2v13kxzu2cbjnwi1zcr5.png" alt="From Emmykolic" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you get to this point, you know you’re on the right track. And we need to add some styling to it. To make it presentable, create another file called &lt;strong&gt;&lt;code&gt;style.css&lt;/code&gt;&lt;/strong&gt; and add the following codes inside it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body{
        font-size: 20px;
        font-family: sans-serif;
        color: #333;
}
.center{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Adjust as needed */
}

.question{
        font-weight: 600;
}
.answers {
    margin-bottom: 20px;
}
#submit{
        font-family: sans-serif;
        font-size: 20px;
        background-color: #297;
        color: #fff;
        border: 0px;
        border-radius: 3px;
        padding: 20px;
        cursor: pointer;
        margin-bottom: 20px;
}
#submit:hover{
        background-color: #3a8;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After doing this, the interface will change to something like this: 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fh68j9iao1u9zt7famfse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fh68j9iao1u9zt7famfse.png" alt="From Emmykolic’s Desk" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you notice, the aritimatics are not showing, and it wasn’t added in the HTML. Good, that is because we’re fetching the maths questions from our JavaScript. To see how we did that, create another file and name it as &lt;strong&gt;&lt;code&gt;main.js&lt;/code&gt;&lt;/strong&gt; and add the codes below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var quizContainer = document.getElementById('quiz');
var resultsContainer = document.getElementById('results');
var submitButton = document.getElementById('submit');


var myQuestions = [
        {
                question: "What is 10/2?",
                answers: {
                        a: '3',
                        b: '5',
                        c: '115'
                },
                correctAnswer: 'b'
        },
        {
                question: "What is 30/3?",
                answers: {
                        a: '3',
                        b: '5',
                        c: '10'
                },
                correctAnswer: 'c'
        }
];


function generateQuiz(questions, quizContainer, resultsContainer, submitButton){

        function showQuestions(questions, quizContainer){
                // code will go here
                // we'll need a place to store the output and the answer choices
                var output = [];
                var answers;

                // for each question...
                for(var i=0; i&amp;lt;questions.length; i++){

                        // first reset the list of answers
                        answers = [];

                        // for each available answer to this question...
                        for(letter in questions[i].answers){

                                // ...add an html radio button
                                answers.push(
                                        '&amp;lt;label&amp;gt;'
                                                + '&amp;lt;input type="radio" name="question'+i+'" value="'+letter+'"&amp;gt;'
                                                + letter + ': '
                                                + questions[i].answers[letter]
                                        + '&amp;lt;/label&amp;gt;'
                                );
                        }

                        // add this question and its answers to the output
                        output.push(
                                '&amp;lt;div class="question"&amp;gt;' + questions[i].question + '&amp;lt;/div&amp;gt;'
                                + '&amp;lt;div class="answers"&amp;gt;' + answers.join('') + '&amp;lt;/div&amp;gt;'
                        );
                }

                // finally combine our output list into one string of html and put it on the page
                quizContainer.innerHTML = output.join('');
        }

        function showResults(questions, quizContainer, resultsContainer){
                // code will go here


                // gather answer containers from our quiz
                var answerContainers = quizContainer.querySelectorAll('.answers');

                // keep track of user's answers
                var userAnswer = '';
                var numCorrect = 0;

                // for each question...
                for(var i=0; i&amp;lt;questions.length; i++){

                        // find selected answer
                        userAnswer = (answerContainers[i].querySelector('input[name=question'+i+']:checked')||{}).value;

                        // if answer is correct
                        if(userAnswer===questions[i].correctAnswer){
                                // add to the number of correct answers
                                numCorrect++;

                                // color the answers green
                                answerContainers[i].style.color = 'lightgreen';
                        }
                        // if answer is wrong or blank
                        else{
                                // color the answers red
                                answerContainers[i].style.color = 'red';
                        }
                }

                // show number of correct answers out of total
                resultsContainer.innerHTML = numCorrect + ' out of ' + questions.length;
        }

        // show the questions
        showQuestions(questions, quizContainer);

        // when user clicks submit, show results
        submitButton.onclick = function(){
                showResults(questions, quizContainer, resultsContainer);
                // on submit, show results
        }
}

generateQuiz(myQuestions, quizContainer, resultsContainer, submitButton);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above code makes the math question display and also display the result once you click &lt;strong&gt;Get Result&lt;/strong&gt;. Here’s a GIF that shows your end result: 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F6m6w8jq86rlbfjz8kg64.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F6m6w8jq86rlbfjz8kg64.gif" alt="The End Result" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Building an interactive quiz project using Vanilla JavaScript is an exciting way to enhance your web development skills while creating a dynamic and engaging user experience. By following a step-by-step approach, you can break down the project into manageable tasks, such as structuring the HTML, styling with CSS, and implementing JavaScript functionalities for question handling, answer validation, and score tracking.&lt;/p&gt;

&lt;p&gt;Through this process, you gain hands-on experience with JavaScript concepts like event listeners, DOM manipulation, and data handling, which are crucial for interactive web applications. Additionally, you can enhance the quiz by adding features such as timers, progress tracking, and animations to make it more engaging.&lt;/p&gt;

&lt;p&gt;With practice and creativity, you can expand your quiz project into a more sophisticated application, integrating APIs or databases for a richer experience. The key takeaway is that Vanilla JavaScript provides a solid foundation for interactive web development, empowering you to build projects that are both functional and user-friendly. Keep experimenting, and you'll continue to improve your skills as a JavaScript developer! 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt;&lt;/a&gt; has &lt;code&gt;4+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;/p&gt;

&lt;p&gt;His stacks include &lt;code&gt;ReactJs&lt;/code&gt; &lt;code&gt;Laravel&lt;/code&gt; &lt;code&gt;PHP&lt;/code&gt; &lt;code&gt;JavaScript,&lt;/code&gt; and other languages and frameworks.&lt;br&gt;
As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;/p&gt;

&lt;p&gt;If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please follow him on his &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://github.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/" rel="noopener noreferrer"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://www.twitter.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>How To Build A YouTube API Connection (Project) Using Vanilla JavaScript</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Mon, 25 Nov 2024 08:39:36 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-build-a-youtube-api-connection-project-using-vanilla-javascript-31</link>
      <guid>https://dev.to/emmykolic/how-to-build-a-youtube-api-connection-project-using-vanilla-javascript-31</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As a developer, you will use API at some point in your web-developing Journey. The use of API is almost an undeniable fact for a developer. &lt;/p&gt;

&lt;p&gt;So for the sake of this Guide, we’ll be looking at how the &lt;strong&gt;YouTube API Connection&lt;/strong&gt; can be done. The YouTube Data API retrieves video data and presents it on a webpage when building a YouTube API connection project with vanilla JavaScript. Here is a straightforward, step-by-step setup guide for this project.&lt;/p&gt;

&lt;p&gt;Without wasting your precious time! Let's dive into this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;The things you need to achieve building an outstanding YouTube API Connection Project. are as follows:&lt;br&gt;
You must have a basic knowledge of&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;JavaScript(Basic)&lt;/li&gt;
&lt;li&gt;Understand API&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Is An API
&lt;/h2&gt;

&lt;p&gt;Application Programming Interfaces, or APIs, are a collection of guidelines and conventions that facilitate communication between various software programs. Imagine it as a bridge that spans two distinct systems, enabling them to communicate or carry out activities without having to comprehend one another's inner workings.&lt;/p&gt;

&lt;p&gt;Here’s a breakdown of how an API works and its purpose:&lt;br&gt;
&lt;strong&gt;1. The Operation of APIs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An application can send a request to another application through an API, and the other application will reply with the information or action that was requested. To ensure that both programs can understand one another, the format of these requests and answers is standardized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- &lt;em&gt;Endpoints and URLs:&lt;/em&gt;&lt;/strong&gt; Applications can access particular features or data by using endpoints, also known as URLs, which are usually provided by APIs. For instance, you can search for videos on YouTube using the &lt;code&gt;https://www.googleapis.com/youtube/v3/search&lt;/code&gt; endpoint in the YouTube API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- &lt;em&gt;Data Format:&lt;/em&gt;&lt;/strong&gt; JSON (JavaScript Object Notation) and XML are two typical formats used by APIs to exchange data. These formats organize the data in a way that both programs can understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The Significance of APIs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Facilitate Interconnectivity:&lt;/strong&gt; APIs enable them to interact and cooperate Whether two systems are located on the same server or on different continents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Encapsulate Complexity:&lt;/strong&gt; Applications can request functionality or data using APIs without having to understand how the other application operates internally. For example, a weather app can simply ask a weather API for the current weather without having to understand how weather data is gathered.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Increase Functionality:&lt;/strong&gt; APIs enable developers to include features from other platforms or services. For instance, an application may display a map using the Google Maps API rather than creating mapping features from the ground up.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Practical Applications of APIs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Social Media:&lt;/strong&gt; To show social media content or enable sharing straight to Facebook, Instagram, or Twitter, many apps leverage their APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Payment Processing:&lt;/strong&gt; Online retailers can take payments without managing private financial information by using payment APIs, such as those offered by PayPal or Stripe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Weather Data:&lt;/strong&gt; The most recent weather data for any area may be retrieved and displayed by apps and websites using a weather API.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Types of APIs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web APIs:&lt;/strong&gt; Allow applications to communicate over the internet, often using HTTP requests. Examples include REST APIs and GraphQL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Library APIs:&lt;/strong&gt; Allow code libraries within a programming language to interact with each other, like a math library’s API in Python or JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Operating System APIs:&lt;/strong&gt; Allow applications to interact with the underlying operating system, like Windows API or iOS API.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. REST APIs (Representational State Transfer)&lt;/strong&gt;&lt;br&gt;
 REST APIs are a common type of web API that follow specific architectural principles, making them stateless and standardized. REST APIs operate over HTTP and are designed to work with resources represented as URLs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Making an API Request to a Weather Service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you want to know the weather in New York City. You could send an HTTP request to a weather API, like so:&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is API knowledge necessary?
&lt;/h2&gt;

&lt;p&gt;Understanding APIs (Application Programming Interfaces) is crucial for contemporary software development since they act as a link between various software systems, facilitating smooth functionality and communication. For the following reasons, it is essential to comprehend APIs:&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;1. Makes Work Easier&lt;/strong&gt; &lt;br&gt;
Through the use of integration APIs, developers can integrate features without having to start from scratch by allowing various apps or services to communicate with one another. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To show videos on your website, use the YouTube API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Incorporate payment gateways such as PayPal or Stripe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Obtain meteorological information from outside sources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;2. Increases Output&lt;/strong&gt;&lt;br&gt;
Instead of having to start from scratch, the developer can concentrate on creating distinctive features for their apps by utilizing APIs. &lt;br&gt;
For instance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can utilize APIs like OAuth or Firebase in place of developing a user authentication mechanism.&lt;/li&gt;
&lt;li&gt;Time is saved by APIs that offer readily usable data and features, such as OpenWeather and Google Maps.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;3. Facilitates Scalability&lt;/strong&gt;&lt;br&gt;
Applications can expand by adding functionality thanks to APIs without having to completely redo the system. &lt;br&gt;
For instance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a basic app first, then use the Google Analytics API to add features like user analytics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integrate third-party services to improve functionality while maintaining the app's flexibility and modularity.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;4. Motivates Interoperability&lt;/strong&gt;&lt;br&gt;
Communication across different platforms, programming languages, and technologies is standardized by APIs. This guarantees that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A React-developed front-end can communicate with Python or &lt;code&gt;Node.js&lt;/code&gt; built back-end.&lt;/li&gt;
&lt;li&gt;APIs allow data to be shared easily across IoT devices, web apps, and mobile apps.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;5. Crucial to Contemporary Web Development&lt;/strong&gt;&lt;br&gt;
To provide dynamic and real-time functionality, the majority of contemporary web and mobile applications mostly rely on APIs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Social media sharing and analytics APIs (Facebook, Twitter).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud storage APIs for file management (e.g., Dropbox, Google Drive).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;APIs for user customization, like Netflix's recommendation API or Spotify's playlist API.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In a nutshell&lt;/strong&gt;&lt;br&gt;
In today's digital ecosystem, APIs serve as the foundation for connectivity. Knowledge of APIs enables you to integrate, innovate, and grow effectively, making it a crucial ability for developers regardless of the size of the project or application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples Of Scenarios API Can Be Use
&lt;/h2&gt;

&lt;p&gt;Application Programming Interfaces, or APIs, are strong instruments that facilitate data sharing and communication across various software systems. &lt;br&gt;
&lt;strong&gt;Here are five significant situations in which APIs can be applied:&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;1. Social Media Integration Scenario:&lt;/strong&gt; &lt;br&gt;
Users can sign in on a website or application using their Google, Twitter, or Facebook accounts.&lt;br&gt;
Social media login APIs, such as the Google OAuth and Facebook Graph APIs, were utilized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It makes it easier for users to log in.&lt;/li&gt;
&lt;li&gt;With permission from the user, it enables developers to safely retrieve user profile data.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;2. Applications of Weather&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Situation:&lt;/strong&gt; Real-time weather data for locations is shown on a travel app.&lt;br&gt;
Weather APIs, such as OpenWeatherMap and WeatherStack, were utilized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Current weather information, such as temperature, humidity, and predictions, is provided.&lt;/li&gt;
&lt;li&gt;Location-based weather services are made possible.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;3. Gateways for payments&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Situation:&lt;/strong&gt; Consumers can use digital wallets like PayPal or Stripe or credit/debit cards to make payments on an e-commerce site.&lt;/p&gt;

&lt;p&gt;Payment APIs, such as PayPal and Stripe, were utilized.&lt;br&gt;
&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Facilitates safe online transaction processing.&lt;/li&gt;
&lt;li&gt;Features like fraud detection and recurring payments are supported.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;4. Location and Map Services&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Situation:&lt;/strong&gt; A food delivery app watches the delivery driver in real-time and displays the customer's position.&lt;br&gt;
Mapbox and Google Maps are two examples of mapping APIs that are used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provides real-time tracking, route optimization, and geolocation.&lt;/li&gt;
&lt;li&gt;Interactive maps improve the user experience.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;5. Platforms for E-Learning&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Scenario:&lt;/strong&gt; A virtual meeting tool for live courses and video conferencing is integrated into an online learning platform.&lt;br&gt;
Video communication APIs, such as the Zoom and Twilio APIs, were utilized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It makes it possible to arrange and schedule live classes with ease.&lt;/li&gt;
&lt;li&gt;Offers live chat, transcribing, and recording features.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;The Reasons APIs Are Essential&lt;/strong&gt; &lt;br&gt;
APIs make development easier, improve functionality, and guarantee effective service-to-service communication. Instead of starting from scratch, they enable developers to concentrate on generating distinctive features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step By Step Process On Building The YouTube Connection Project
&lt;/h2&gt;

&lt;p&gt;Now this is the part we’ve been waiting for. Let’s Go…&lt;/p&gt;

&lt;p&gt;So Note that the YouTube Data API is used to retrieve video data and present it on a webpage when building a YouTube API connection project using vanilla JavaScript. Here is a straightforward, step-by-step setup tutorial for this project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Set Up Your Google API Key&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the &lt;a href="https://console.cloud.google.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Google Cloud Console&lt;/strong&gt;&lt;/a&gt;.
    then you’ll see the interface below, that says welcome! the that will take you to the next step.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new project or select an existing one.&lt;br&gt;
    from the image below we created a new project that gave us this view, now you’ll move to the next step.&lt;br&gt;
&lt;a href="https://media2.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%2Ff3l0zj7gep949xb3u7oz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ff3l0zj7gep949xb3u7oz.png" alt="Emmykolic’s Snippet" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;strong&gt;APIs &amp;amp; Services&lt;/strong&gt; as shown below, and then it will take you to a page with a diagram that looks like statistics. Make sure you are meticulous about this, cause we're getting there…&lt;br&gt;
&lt;a href="https://media2.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%2Fp31lkjbhs96kq9msn8cv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fp31lkjbhs96kq9msn8cv.png" alt="Emmykolic’s Snippet" width="800" height="617"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On that page, look at the left side of your screen. You’ll see &amp;gt; Library. Click on it, and it will take you to a fresh-looking page, where you can search for any API Library of your choice. See the image below for more explanation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fu12tqwkjknpd5vqctjw3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fu12tqwkjknpd5vqctjw3.jpg" alt="Emmykolic’s Snippet" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will search &lt;code&gt;"YouTube Data API v3"&lt;/code&gt; in the search bar as displayed below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F5ic5srgkx3lz912l5rfo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5ic5srgkx3lz912l5rfo.jpg" alt="Emmykolic’s Snippet" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click enter for search, you will get the YouTube Data API, this is the API we need which will enable us to make the API connection in our Local Project. The Image Below is an example of what you’ll see after searching…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fsl0qotppdxo32tk7kbba.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fsl0qotppdxo32tk7kbba.jpg" alt="Emmykolic’s Snippet" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the searching, you’ll click on the YouTube Icon and it will bring you here, all you have to do is to Enable the API, by clicking the Enable Button. As shown Below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flzxqj2v3tzh2zhjgi614.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flzxqj2v3tzh2zhjgi614.jpg" alt="Emmykolic’s Snippet" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After enabling the API you click on the &lt;strong&gt;&lt;code&gt;Credentials&lt;/code&gt;&lt;/strong&gt; link it’s usually by the left side of your screen directly under where you have Library. &lt;br&gt;
There, you will see the YouTube API you just Generated. where the arrow in the image is pointing. You then click on &lt;strong&gt;SHOW KEY&lt;/strong&gt; the API key will pop up and you will now copy it and keep it somewhere safe in case of implementing it soon.&lt;/p&gt;

&lt;p&gt;But note that API Key 1 has a warning beside it, which means your API is not restricted to only the use of YouTube API, and leaving it like that could be very dangerous, so it needs restriction let’s go...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fw9qcfq50cnpyj5p4cn0f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fw9qcfq50cnpyj5p4cn0f.jpg" alt="Emmykolic’s Snippet" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So to remove the warning sign what we will do is to click on the word API Key. The word is a Link that will take us to a page where we can make some changes, when you get to the new page scroll down you’ll see a section called API Restrictions. &lt;/p&gt;

&lt;p&gt;By default it’s in the Don’t restrict key checkbox, you’ll change it and click on the Restrict Key. &lt;/p&gt;

&lt;p&gt;As shown Below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F55yhwu64mi2wfc1mabvp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F55yhwu64mi2wfc1mabvp.jpg" alt="Emmykolic’s Snippet" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Immediately a dropdown will display and you will click on the &lt;strong&gt;&lt;code&gt;YouTube Data API v3&lt;/code&gt;&lt;/strong&gt; and then click the ok right beneath the dropdown. After that, you’ll now click on the save button below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fzxg067j2p5m6c905xrm7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fzxg067j2p5m6c905xrm7.jpg" alt="Emmykolic’s Snippet" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Immediately you save, it will take you back to the page you were coming from, but this time with a green verified-looking badge. The moment you follow these steps you are good to go.&lt;/p&gt;

&lt;p&gt;The image below is the last step. so from here, it’s to make use of the  API key you copied, you’ll need it to authenticate requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fceulvobc9f8byp81zmxl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fceulvobc9f8byp81zmxl.jpg" alt="Emmykolic’s Snippet" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Basic HTML Structure&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start with a simple HTML structure where you’ll display search results or video information.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;YouTube API Project&amp;lt;/title&amp;gt;
  &amp;lt;style&amp;gt;
    /* Basic styling */
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    #search-container {
      margin-top: 20px;
    }
    .video {
      margin: 15px 0;
    }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;YouTube Video Search&amp;lt;/h1&amp;gt;
  &amp;lt;div id="search-container"&amp;gt;
    &amp;lt;input type="text" id="query" placeholder="Search for videos" /&amp;gt;
    &amp;lt;button onclick="searchVideos()"&amp;gt;Search&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div id="results"&amp;gt;&amp;lt;/div&amp;gt;

  &amp;lt;script src="index.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Make the app.js JavaScript file.&lt;/strong&gt;&lt;br&gt;
Write the JavaScript code in &lt;strong&gt;&lt;code&gt;app.js&lt;/code&gt;&lt;/strong&gt; to communicate with the YouTube API and retrieve video information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Establish Your API Key:&lt;/strong&gt; Specify the YouTube Data API's base URL.&lt;br&gt;
&lt;strong&gt;Describe the&lt;/strong&gt; &lt;code&gt;search. Videos&lt;/code&gt; &lt;strong&gt;Function:&lt;/strong&gt; Retrieve videos in response to user queries.&lt;br&gt;
&lt;strong&gt;Display Results:&lt;/strong&gt; Include the video results in the HTML #results div.&lt;/p&gt;

&lt;p&gt;Here's how to accomplish it:&lt;br&gt;
Below is the Javascript controlling it. Note: the API_KEY below will be replaced with the copied API_KEY from your &lt;strong&gt;&lt;code&gt;YouTube API&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;




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

const API_KEY = 'AIzaSyDGpbbfEO5x89tDGePuCRD8kaev4B26y7Q'; // Replace with your actual API key
const BASE_URL = 'https://www.googleapis.com/youtube/v3/search';

async function searchVideos() {
  const query = document.getElementById('query').value;

  try {
    const response = await fetch(`${BASE_URL}?part=snippet&amp;amp;q=${query}&amp;amp;type=video&amp;amp;key=${API_KEY}`);
    const data = await response.json();

    if (response.ok) {
      displayResults(data.items);
    } else {
      console.error('Error fetching videos:', data.error.message);
    }
  } catch (error) {
    console.error('Network error:', error);
  }
}

function displayResults(videos) {
  const resultsContainer = document.getElementById('results');
  resultsContainer.innerHTML = ''; // Clear previous results

  videos.forEach((video) =&amp;gt; {
    const videoElement = document.createElement('div');
    videoElement.classList.add('video');

    videoElement.innerHTML = `
      &amp;lt;h3&amp;gt;${video.snippet.title}&amp;lt;/h3&amp;gt;
      &amp;lt;img src="${video.snippet.thumbnails.medium.url}" alt="${video.snippet.title}" /&amp;gt;
      &amp;lt;p&amp;gt;${video.snippet.description}&amp;lt;/p&amp;gt;
      &amp;lt;a href="https://www.youtube.com/watch?v=${video.id.videoId}" target="_blank"&amp;gt;Watch Video&amp;lt;/a&amp;gt;
    `;

    resultsContainer.appendChild(videoElement);
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Key Parts Explained&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Endpoint and Parameters:&lt;/strong&gt; BASE_URL, the part parameter (snippet for title, description, and thumbnails), and the q parameter for the search query are used to create the URL endpoint.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To obtain just video results, use type=video filters.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Show Results:&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;You may utilize the &lt;code&gt;snippet.title&lt;/code&gt;, &lt;code&gt;snippet.thumbnails&lt;/code&gt;, and &lt;code&gt;snippet.description&lt;/code&gt; that are included in each video object to fill in the HTML.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linking to the YouTube video URL is aided by the &lt;code&gt;video.id.videoId&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managing Errors:&lt;/strong&gt; Try-catch ensures that API and network errors are detected and recorded.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Execute and Evaluate Your Project&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Launch a web browser and open the &lt;code&gt;index.html&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Click "&lt;strong&gt;Search&lt;/strong&gt;" after entering a search word. The results container will show the results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advice for Improvement&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To retrieve additional results, use pagination.&lt;/li&gt;
&lt;li&gt;While the data is being retrieved, use a loading indication.&lt;/li&gt;
&lt;li&gt;Use more filters, such as publication date or relevance sorting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With just vanilla JavaScript, this configuration offers a simple yet useful YouTube API connection project!&lt;/p&gt;

&lt;p&gt;Here’s the result I got.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7dmw6hdugrhtz9v61ng6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7dmw6hdugrhtz9v61ng6.png" alt="Emmykolic’s Snippet" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;without searching anything you’ll see this, then you search for anything of your choice. As long as it’s on YouTube you’ll see it. &lt;br&gt;
Below I searched for Nickelodeon, and here’s the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F8jp0grouay1cojat6zw0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F8jp0grouay1cojat6zw0.png" alt="Emmykolic’s Snippet" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After searching, you’ll get the above interface as your result. You can go ahead and find anything you wish. Note that this can be customized to whatever you want in your projects.&lt;/p&gt;

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

&lt;p&gt;An enjoyable method to improve your knowledge of APIs and asynchronous programming is to create a YouTube API connection project with vanilla JavaScript. Following this tutorial, you now know how to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use an API key to set up and use the YouTube Data API.&lt;/li&gt;
&lt;li&gt;Use' fetch' To handle asynchronous data and make API queries.&lt;/li&gt;
&lt;li&gt;Display the retrieved video results by dynamically updating the DOM.&lt;/li&gt;
&lt;li&gt;Put error management into practice to guarantee a seamless user experience.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This project shows how powerful JavaScript and APIs are for creating dynamic, data-driven websites. To make the project more aesthetically pleasing and user-friendly, think about incorporating features like pagination, sophisticated search filters, or design improvements as you work on it. &lt;/p&gt;

&lt;p&gt;Investigating and implementing these concepts can distinguish your project and strengthen your front-end web development abilities.&lt;/p&gt;

&lt;p&gt;But for now, see you next time…&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt;&lt;/a&gt; has &lt;code&gt;4+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;br&gt;
His stacks include &lt;code&gt;ReactJs&lt;/code&gt; &lt;code&gt;Laravel&lt;/code&gt; &lt;code&gt;PHP&lt;/code&gt; &lt;code&gt;JavaScript,&lt;/code&gt; and other languages and frameworks.&lt;br&gt;
As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;br&gt;
If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please follow him on his &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://github.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/" rel="noopener noreferrer"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://www.twitter.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>api</category>
      <category>youtube</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How To Build A Star Rating Project Using Vanilla JavaScript (For Beginners)</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Wed, 25 Sep 2024 22:34:10 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-build-a-star-rating-project-using-vanilla-javascript-for-beginners-jch</link>
      <guid>https://dev.to/emmykolic/how-to-build-a-star-rating-project-using-vanilla-javascript-for-beginners-jch</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As you use most Applications/Websites there’ll be a time they’ll ask you to rate the App/Site, making this possible they’ll display a set of stars, and then you’ll click to your test according to your satisfaction on the App or website. &lt;/p&gt;

&lt;p&gt;This is what we’ll be accomplishing in this tutorial, you’ll be able to use Vanilla Javascript to make star rating possible in the site/app.&lt;/p&gt;

&lt;p&gt;Without wasting your precious time! Let's dive into this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;Here are the things you need to know before being able to build the star rating project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step By Step Approach To Building A Star Rating Project
&lt;/h2&gt;

&lt;p&gt;We will start first by creating a simple HTML page. That will contain the icons of the star itself, this HTML page is the interface that you're able to see.&lt;/p&gt;

&lt;p&gt;Below is the code that you’ll write on your index.html page.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In this HTML code snippet page, apart from the document's basic structure, there’s a procedure of span tag that contains the &lt;code&gt;onclick&lt;/code&gt;, attribute! and it is named simultaneously, eg! &lt;code&gt;gfg(1),&lt;/code&gt; &lt;code&gt;gfg(2),&lt;/code&gt; etc… This Span tag also includes HTML entities characters for displaying a star shape with the text content of the span tag.&lt;/p&gt;

&lt;p&gt;Below is the view you’ll see after completing the above snippet. &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%2Fdz4r5mk2mqke18haludd.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%2Fdz4r5mk2mqke18haludd.png" alt="Interface"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s time to style the interface above, the snippet below should be added to your style.css page &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Be certain the classes are well-targeted, then you’ll get a new interface like the one below.&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%2Fy3us9qjieyi03vgfes4a.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%2Fy3us9qjieyi03vgfes4a.png" alt="After Adding The CSS Here’s What You’ll Get!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the next thing is to make the star icon a rating once you click it. So therefore we’ll make use of a JavaScript Event called &lt;code&gt;**Onclick**&lt;/code&gt; this event helps you to interact with the JavaScript. &lt;/p&gt;

&lt;p&gt;Name the onclick like this, &lt;code&gt;**onclick="gfg()"**&lt;/code&gt; on your HTML page as shown above. Then you go to your JavaScript, call the onclick function gfg(), and write your code like the one you see below.  This is the functionality of the star you see.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Note the JavaScript will be an external script meaning, you’ll write it in a separate file just like the &lt;code&gt;**index.html**&lt;/code&gt;, &lt;code&gt;**style.css**&lt;/code&gt;, and &lt;code&gt;**script.js**&lt;/code&gt; then link properly as it’s done in the &lt;code&gt;**index.html**&lt;/code&gt; as seen below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- index.html --&amp;gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
        &amp;lt;link rel="stylesheet" href="styles.css" /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
        &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This link shows that the pages are external.&lt;/p&gt;

&lt;p&gt;After applying all these snippets on the tutorial, here’s the Interface you’ll get on your screen, and then you’ll know what you did is correct. The star will change color according to each click!&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%2Fr3jmfb4nhfjdgvv9vmug.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr3jmfb4nhfjdgvv9vmug.gif" alt="Interface Of  JavaScript Star Rating!"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;In conclusion, adding a Star Rating functionality in the site FAQs is a modern web application development. And a Javascript beginner can adapt this technique to his/her development skill &lt;/p&gt;

&lt;p&gt;Building a star-rating project using vanilla JavaScript is a great way for beginners to enhance their understanding of core JavaScript concepts while working with real-world projects. Following this tutorial, you learned how to create dynamic and interactive star ratings, which can be incorporated into various web applications.&lt;/p&gt;

&lt;p&gt;Through this project, you gained hands-on experience with event listeners, DOM manipulation, and CSS styling to create a seamless user experience. Additionally, you explored how to handle user input by capturing and storing rating data.&lt;/p&gt;

&lt;p&gt;This project serves as a foundation to explore more advanced topics in web development, such as data validation, server-side integration, and user feedback systems. As you continue to practice and build more projects, your JavaScript skills will improve, enabling you to take on more complex challenges. Keep experimenting and expanding on this project to make it more robust and adaptable to different applications.&lt;/p&gt;

&lt;p&gt;I hope you found this tutorial incredibly valuable! Until next time, goodbye.&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt;&lt;/a&gt; has &lt;code&gt;4+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;/p&gt;

&lt;p&gt;His stacks include &lt;code&gt;ReactJs&lt;/code&gt; &lt;code&gt;Laravel&lt;/code&gt; &lt;code&gt;PHP&lt;/code&gt; &lt;code&gt;JavaScript,&lt;/code&gt; and other languages and frameworks.&lt;/p&gt;

&lt;p&gt;As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;br&gt;
If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please follow him on his &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://facebook.com/Emmykolic/" rel="noopener noreferrer"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://github.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/" rel="noopener noreferrer"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://www.twitter.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How To Use PHP As A Backend Using React For Frontend</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Tue, 09 Jul 2024 10:30:52 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-use-php-as-a-backend-using-react-for-frontend-3dca</link>
      <guid>https://dev.to/emmykolic/how-to-use-php-as-a-backend-using-react-for-frontend-3dca</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Developing dynamic and interactive web apps is crucial in the dynamic and ever-changing world of web development. The speed and versatility of React, a JavaScript toolkit for creating user interfaces, have led to its great popularity. However, PHP is still a strong option for server-side programming. This tutorial will show you how to easily combine the functionality of a PHP backend and React front-end to utilize their respective strengths fully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Distinct Roles of PHP and React
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What Is PHP
&lt;/h2&gt;

&lt;p&gt;The term PHP is an acronym for Hypertext Preprocessor. It is a server-side scripting language that is used for web development. It can be easily embedded with HTML files. HTML codes can also be written in a PHP file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merits Of PHP
&lt;/h2&gt;

&lt;p&gt;Below are a few Merits of PHP&lt;br&gt;
&lt;strong&gt;Ease of Learning and Use&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP is known for its straightforward syntax, which is relatively easy for beginners. This simplicity helps new developers start building web applications quickly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Wide Adoption and Community Support&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP has a large and active community. This means extensive documentation, numerous tutorials, and a wealth of online resources. Community support also translates into a vast pre-written code, frameworks, and plugin library.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Integration Capabilities&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP integrates seamlessly with various databases (such as MySQL, PostgreSQL, SQLite), web servers (like Apache and Nginx), and other services. This makes it a versatile choice for web development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Open Source&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP is free to use and distribute. This lowers the cost of development, especially for small businesses and startups.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cross-Platform Compatibility&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP can run on multiple platforms, including Windows, Linux, and macOS. This flexibility ensures that PHP applications can be deployed in diverse environments without compatibility issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demerits Of PHP
&lt;/h2&gt;

&lt;p&gt;Below are a few Demerits of PHP.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inconsistent Function Naming and Parameter Order&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One of the common criticisms of PHP is its inconsistent function naming conventions and parameter order. For example, functions may have different naming patterns (&lt;code&gt;str_replace&lt;/code&gt; vs. &lt;code&gt;strpos&lt;/code&gt;) and parameter orders (&lt;code&gt;array_filter($array, $callback)&lt;/code&gt; vs. &lt;code&gt;array_map($callback, $array)&lt;/code&gt;). This inconsistency can lead to confusion and errors, especially for new developers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Historical Security Issues&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP has had a history of security vulnerabilities, partly due to its widespread use and partly due to the way it was designed. While modern PHP has significantly improved in terms of security features, legacy codebases and bad practices from earlier versions can still pose security risks.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance Compared to Other Languages&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;While PHP has made great strides in improving performance (especially with PHP 7 and later), it can still be slower compared to some other languages like Node.js or Go for certain tasks. This can be a drawback for applications requiring extremely high performance and low latency.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Weak Typing&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP’s weak typing system, which allows implicit type conversions, can lead to unexpected behavior and bugs that are difficult to track down. For example, comparing a string to a number may yield unexpected results (&lt;code&gt;"123" == 123&lt;/code&gt; is true, but &lt;code&gt;"123" === 123&lt;/code&gt; is false). This can be problematic, especially for large, complex codebases.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Over-Reliance on Older, Procedural Code&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Many PHP applications and tutorials still use older, procedural programming techniques rather than modern, object-oriented, or functional programming practices. This can lead to less maintainable and harder-to-read code. While modern frameworks encourage better practices, the legacy of procedural code can still be a significant issue.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Is React
&lt;/h2&gt;

&lt;p&gt;React JS is a declarative, efficient, and flexible JavaScript library for building user interfaces. It’s ‘V’ in MVC. ReactJS is an open-source, component-based front-end library, responsible only for the view layer of the application. It is maintained by Facebook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merits Of React Js
&lt;/h2&gt;

&lt;p&gt;Below are a few Merits of React Js.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Component-Based Architecture&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React follows a component-based architecture, which allows developers to build reusable UI components. This modularity leads to cleaner, more maintainable, and scalable code. Components can be reused across different parts of an application, reducing redundancy and improving development efficiency.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Virtual DOM for Improved Performance&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React uses a Virtual DOM (Document Object Model) to optimize rendering performance. When the state of an application changes, React updates the Virtual DOM first, which then efficiently updates the actual DOM only where necessary. This minimizes direct manipulation of the DOM, leading to faster and more efficient updates, particularly beneficial for complex applications with frequent UI changes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Declarative UI&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React's declarative approach to building UIs makes code more predictable and easier to debug. Developers describe what the UI should look like for a given state, and React takes care of updating the actual UI based on state changes. This simplifies the process of developing interactive user interfaces and makes the code more readable.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rich Ecosystem and Community Support&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React has a vast ecosystem with numerous libraries, tools, and extensions that enhance its functionality. The strong community support ensures that developers have access to extensive resources, tutorials, and third-party components. Additionally, the backing of Facebook and contributions from a large number of developers worldwide ensure React remains up-to-date and continuously improving.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Strong Support for JSX&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React uses JSX (JavaScript XML), a syntax extension that allows HTML to be written within JavaScript. JSX simplifies the process of creating React components and makes the code more readable by visually separating the structure (HTML) from the logic (JavaScript). This tight integration of markup with logic enhances development efficiency and reduces context switching for developers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Demerits Of React Js
&lt;/h2&gt;

&lt;p&gt;Below are a few Demerits of React Js.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Steep Learning Curve&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React's flexibility and the wide array of tools and libraries in its ecosystem can make the learning curve steep for beginners. Understanding concepts like JSX, components, state management, and the intricacies of the Virtual DOM can be challenging for new developers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Boilerplate and Complexity&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up a React project often involves considerable boilerplate code and configuration. Tools like Create React App simplify the initial setup, but as projects grow, the complexity can increase, requiring additional configuration and understanding of build tools like Webpack and Babel.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rapidly Changing Environment&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The React ecosystem evolves quickly, with frequent updates and new tools emerging regularly. Keeping up with the latest best practices, updates, and libraries can be overwhelming for developers. This fast pace of change can also lead to issues with outdated documentation and compatibility between different libraries and versions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Poor SEO&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By default, React renders applications on the client side, which can lead to poor SEO performance because search engine crawlers might have difficulty indexing the dynamic content. Although solutions like server-side rendering (SSR) with frameworks like Next.js exist, implementing them adds complexity to the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;State Management Complexity&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Managing state in large React applications can become complex. While React's built-in state management works well for small applications, scaling up requires more sophisticated state management solutions like Redux, MobX, or the Context API. These solutions add another layer of complexity and require additional learning and setup.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Synergy Between PHP and React in Modern Web Applications
&lt;/h2&gt;

&lt;p&gt;The synergy between PHP and React in modern web applications leverages the strengths of both technologies to create robust, dynamic, and scalable applications. Here’s an in-depth look at how these technologies complement each other and the benefits of combining them:&lt;/p&gt;

&lt;h2&gt;
  
  
  5 Benefits of using PHP with React
&lt;/h2&gt;

&lt;p&gt;Note: the benefits are more than five but here are the listed few!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Full-Stack Versatility
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Frontend and backend integration:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Seamless Data Handling:&lt;/strong&gt; React effectively manages the front end, while PHP can handle server-side logic and data exchanges, resulting in a coherent development environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API-Driven Development:&lt;/strong&gt; By supplying data to the React frontend via GraphQL or RESTful endpoints, PHP may function as a potent backend API, allowing for a clear division of responsibilities.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Efficiency of Development:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Parallel Development:&lt;/strong&gt; Teams working on front-end and back-end projects simultaneously can speed up development and eliminate bottlenecks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;reused Components:&lt;/strong&gt; Frontend development is more modular and manageable because of React's component-based design, which guarantees that UI elements are reused.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Scalability
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Managing a Higher Load:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Effective Backend: PHP frameworks like Laravel are designed to manage massive amounts of data and user requests effectively, handling intricate and scalable backend processes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Frontend Optimisation: Even with intricate and data-intensive apps, React's virtual DOM and effective diffing technique guarantee quick and responsive UI changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Architecture of Microservices:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modular Approach:&lt;/strong&gt; Different services can scale independently when PHP is included in a microservices architecture. React facilitates scalability by allowing it to use these services as required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Burden Distribution:&lt;/strong&gt; The program as a whole can manage more traffic skillfully by dividing the burden between PHP, which handles server-side operations, and React, which handles client-side interactions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Performance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Quick load times:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-Side Rendering (SSR):&lt;/strong&gt; Initial HTML may be pre-rendered by PHP and sent to the client, thereafter React can hydrate it. This method boosts the user experience and speeds up the initial load time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Asynchronous Data Fetching:&lt;/strong&gt; By using React, data may be fetched from the PHP backend asynchronously, maintaining a responsive user interface and effective handling of data changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Enhanced Communication:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Effective State Management:&lt;/strong&gt; React's state management features, such as context and hooks, enable better handling of UI state changes, which minimizes the need for pointless re-renders.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Caching and Optimisation:&lt;/strong&gt; PHP can use server-side caching techniques to speed up the serving of static material and lower database demand, therefore improving performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Rich User Interfaces
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;UIs that are interactive and dynamic:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Component-Based design:&lt;/strong&gt; React's component-based design enables programmers to create complex, interactive user interfaces that are simple to update and expand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-Time Updates:&lt;/strong&gt; React is capable of handling dynamic content changes and real-time updates with efficiency, making for a smooth and interesting user experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Improved User Experience:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Contemporary UI Libraries:&lt;/strong&gt; React works nicely with contemporary UI libraries and frameworks (such as Material-UI and Ant Design), enabling programmers to design aesthetically pleasing and intuitive user interfaces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Building responsive&lt;/strong&gt; and adaptable user interfaces (UIs) that function effectively on a variety of devices and screen sizes is made simple using React.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. SEO-Friendly
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Better Optimisation for Search Engines:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-Side Rendering (SSR):&lt;/strong&gt; Pre-rendering HTML content using PHP before providing it to the client guarantees better search engine indexing and SEO.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Meta Tags and Dynamic material:&lt;/strong&gt; Using information from the PHP backend, React can dynamically manage and update meta tags, titles, and other SEO-relevant material.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Better Crawlability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Static Site Generation (SSG):&lt;/strong&gt; React may produce static pages at build time, improving the application's SEO while retaining PHP for dynamic content, by utilizing solutions like Next.js, which supports both SSR and SSG.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;URL Structure:&lt;/strong&gt; React can handle routing and navigation, making sure that visitors and search engines can explore the site with ease, while PHP can manage clear, SEO-friendly URL structures.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers may construct robust, scalable, and performance-optimized online apps with rich user experiences and search engine optimization by integrating PHP with React. Because of their synergy, frontend and backend technologies may be combined to create a strong and adaptable development process.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Creating a PHP and React Development Environment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;At this point, we are about to start an actual project using React.js and PHP as the front end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;There are things you need to know as a developer or things you need to have to be able to make php work as a backend with React. Here is the essential list!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have Basic Knowledge of PHP&lt;/li&gt;
&lt;li&gt;Know your React.Js&lt;/li&gt;
&lt;li&gt;Make Sure Node.js accompanied by npm is installed on your machine.&lt;/li&gt;
&lt;li&gt;Have PHP installed in your system Apache or Nginx&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step By Step Process On How To Use PHP As a Backend Using React As A Front-end
&lt;/h2&gt;

&lt;p&gt;The step to use PHP as a backend alongside React is quite simple and it’s as follows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building The Frontend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Open your terminal and run the following command below:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note: before running this command, you have to cd into the directory where you want your react folder to be! the way to  cd to your desired directory is by adding this command to your terminal&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;After this, you’ll wait for your React app to be created.&lt;/p&gt;

&lt;p&gt;Step 2: Navigate to your project folder:&lt;br&gt;
The project you just created needs to be visited in the terminal&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd my-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Step 3: Start the development server:&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Building the PHP Backend&lt;/strong&gt;&lt;br&gt;
It's time to construct the PHP backend now that your React application is operational:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a new folder for your PHP files within your React app directory.&lt;br&gt;
to achieve this, run the following command on your terminal&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;By running this command you’ll see a folder named php_backend&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%2Fh5n4ro4labl1l60zds2f.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%2Fh5n4ro4labl1l60zds2f.png" alt="For Emphasis's sake!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Inside the php-backend folder, create a file named &lt;code&gt;index.php&lt;/code&gt;. &lt;br&gt;
Note: you’re free to call it any name, in my case I decided to use the index.php.&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%2Flshi2at3k3ht5zdbe8gw.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%2Flshi2at3k3ht5zdbe8gw.png" alt="For Emphasis's sake!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; In the &lt;code&gt;index.php&lt;/code&gt; you can start defining your PHP endpoints and logic.&lt;br&gt;
Below is what is written in my &lt;code&gt;php-backend/index.php&lt;/code&gt; if you’re a PHP developer you’ll be familiar with this syntax.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?PHP 
$serverName="localhost";
$userName="root";
$password="";
$databaseName="react_php";
$conn = mysqli_connect($serverName, $userName, $password, $databaseName);

$recText = $_POST['text'];

$query = ("INSERT INTO react_php (texts) VALUES('$recText')");

if (mysqli_query($conn, $query)) {
  echo "Data has been inserted successfully";
}else {
  echo "Error";
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now the next thing to do is go to the React Code you created earlier and open the folder in your code editor you’ll see a folder like  &lt;code&gt;src/App.js&lt;/code&gt;  and add this syntax below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Component } from 'react';
 // import logo from './logo.svg';
import axios from 'axios'; //Import Axios
import './App.css';

class App extends Component{
state = {
  text : ""
}
handleAdd = async e =&amp;gt;{
 await this.setState({
   text : e.target.value
 }) 
}
handleSubmit = e =&amp;gt;{
 e.preventDefault();
 console.log(this.state.text);
 let formData = new FormData();
 formData.append("text", this.state.text);
 const url = "http://localhost:80/react-backend/"
 axios.post(url,formData)
 .then(res=&amp;gt; console.log(res.data))
 .catch(err=&amp;gt; console.log(err))
}
render(){
  return(
    &amp;lt;div className="App-header"&amp;gt;
     &amp;lt;input 
       onChange={this.handleAdd}
       className="form-control" 
       // value={this.state.text}
       type="text" 
       id='text' 
       placeholder='Enter Some Text!'/&amp;gt; 
       &amp;lt;br/&amp;gt;
       &amp;lt;button 
        onClick={this.handleSubmit}
        className="btn btn-success" 
        id='submit'&amp;gt;  Save&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;export default App;&lt;/p&gt;

&lt;p&gt;Note: what allows the PHP to work is the &lt;code&gt;**Axios**.&lt;/code&gt; Look at the code snippet below you’ll see how we used it! &lt;/p&gt;

&lt;p&gt;In the public folder of your project, you’ll see an &lt;code&gt;index.html&lt;/code&gt; file in that file I added a bootstrap cdn as a framework I'm using,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So Here’s a little styling. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.App {
  text-align: center;
}

.App-logo {
  height: 40vmin;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .App-logo {
   animation: App-logo-spin infinite 20s linear;
  }
}

 .App-header {
   background-color: #282c34;
   min-height: 100vh;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   font-size: calc(10px + 2vmin);
   color: white;
 }

 .App-link {
   color: #61dafb;
 }

 @keyframes App-logo-spin {
 from {
  transform: rotate(0deg);
 }
 to {
  transform: rotate(360deg);
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After trying all these here’s the view it will give to you.&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%2F8s4lrums0fk2p9gzwen4.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%2F8s4lrums0fk2p9gzwen4.png" alt="View of what you’ll see!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Her is the database controlling the backend. once you fill in the text and click save the text will display in the database automatically.&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%2Fzer180snseyg7out87qx.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%2Fzer180snseyg7out87qx.png" alt="The Database Table."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;hereafter I wrote &lt;code&gt;**Freddie**&lt;/code&gt; and I clicked on &lt;strong&gt;Browse,&lt;/strong&gt; in the top right corner of the image displayed below. Once you see this know that you have done the right thing.&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%2Fvw9p2l9roadz7bhmmhug.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%2Fvw9p2l9roadz7bhmmhug.png" alt="Sample Of what the front looks like"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s the step I used in React and PHP in a single application. &lt;/p&gt;

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

&lt;p&gt;In conclusion, integrating PHP as a backend with React as a frontend offers a robust and versatile solution for modern web application development. As discussed, this combination leverages the strengths of PHP's server-side capabilities and React's dynamic, component-based architecture to create scalable, high-performance applications. PHP efficiently handles server-side logic, database interactions, and API creation, while React ensures a rich, responsive user interface and seamless data handling. &lt;/p&gt;

&lt;p&gt;This synergy between PHP and React not only enhances the development process but also results in web applications that are interactive, engaging, and SEO-friendly. Embracing this powerful integration empowers developers to build comprehensive and user-centric web applications with ease and efficiency.&lt;/p&gt;

&lt;p&gt;I hope you found this tutorial incredibly valuable! Until next time, goodbye.&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; has &lt;code&gt;4+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;/p&gt;

&lt;p&gt;His stacks include &lt;code&gt;ReactJ&lt;/code&gt;, &lt;code&gt;Laravel&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;, and other languages and frameworks.&lt;br&gt;
As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;/p&gt;

&lt;p&gt;If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please go to and follow him on his &lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://facebook.com/Emmykolic/" rel="noopener noreferrer"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://github.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/" rel="noopener noreferrer"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://www.twitter.com/emmykolic" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>php</category>
      <category>frontend</category>
      <category>backend</category>
    </item>
    <item>
      <title>POV: What Is The Weirdest Thing You Know About The Framework LARAVEL</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Fri, 15 Mar 2024 09:08:34 +0000</pubDate>
      <link>https://dev.to/emmykolic/pov-what-is-the-weirdest-thing-you-know-about-the-framework-laravel-1bjl</link>
      <guid>https://dev.to/emmykolic/pov-what-is-the-weirdest-thing-you-know-about-the-framework-laravel-1bjl</guid>
      <description>&lt;p&gt;As we all know, Laravel is one of the most popular PHP frameworks but here’s what I feel, I feel it has lots of Weird abilities as a framework around it! &lt;/p&gt;

&lt;p&gt;I want you to share your opinion on why laravel is weird!&lt;/p&gt;

&lt;p&gt;Me: What I Find weird is the too many Upgrades, Before you master the use of Version 9, version 10 is out! and now version 11.&lt;/p&gt;

&lt;p&gt;So this is what I find Weird. Share your Thoughts!&lt;/p&gt;

&lt;p&gt;I Remain &lt;strong&gt;[Emmykolic]&lt;/strong&gt;(&lt;a href="https://emmykolic.github.io" rel="noopener noreferrer"&gt;https://emmykolic.github.io&lt;/a&gt;) ****you can always reach out to me! Till next time Bye&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>trend</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How To Use WebRTC With Laravel</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Thu, 01 Feb 2024 23:33:52 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-use-webrtc-with-laravel-34m6</link>
      <guid>https://dev.to/emmykolic/how-to-use-webrtc-with-laravel-34m6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Real-time communication has become a basic need in the ever-changing world of web development to create interesting and interactive user experiences. Developers may now create seamless audio, video, and data-sharing applications thanks to WebRTC (Web Real-Time Communication), a potent technology that enables peer-to-peer communication directly within web browsers. The well-liked PHP web application framework Laravel offers a solid framework for developing feature-rich, scalable web applications.&lt;/p&gt;

&lt;p&gt;To integrate WebRTC features into Laravel apps, use this instructional series, "How To Use WebRTC With Laravel," as your go-to resource. We will start our quest to comprehend the fundamentals of WebRTC in this first section and set the stage for a smooth integration with Laravel. By the time this series ends, you will have the know-how to add real-time communication functionality to your Laravel applications, making them dynamic and engaging user experiences. Let's explore WebRTC with Laravel together to uncover the possibilities for improved user interaction and teamwork.&lt;/p&gt;

&lt;p&gt;Without wasting much of your time, let's dive into this tutorial!&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the exciting world of WebRTC integration with Laravel, it's essential to ensure that you have the following prerequisites in place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Laravel Installed&lt;/strong&gt;: Verify that Laravel is installed and operational on your development computer. For installation instructions, go to the official Laravel documentation at &lt;a href="https://laravel.com/docs"&gt;https://laravel.com/docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composer:&lt;/strong&gt; Composer is used by Laravel for dependency management. Verify that Composer is installed on your computer. Composer is available for download and installation at &lt;a href="https://getcomposer.org/"&gt;https://getcomposer.org/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js and npm:&lt;/strong&gt; Frontend development is frequently involved in WebRTC apps, and asset compilation is typically accomplished using Laravel Mix, a webpack wrapper. Make sure npm and Node.js are installed. These are available for download and installation at &lt;a href="https://nodejs.org/"&gt;https://nodejs.org/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text Editor or IDE:&lt;/strong&gt; Install and set up your preferred code editor or integrated development environment (IDE) for Laravel development. Popular options include PHPStorm, Sublime Text, and Visual Studio Code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Have a Basic Understanding of Laravel:&lt;/strong&gt; Learn the fundamentals of Laravel, including views, controllers, and routing. Consider watching the introductory lessons on the Laravel documentation if you are unfamiliar with Laravel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebRTC Basics:&lt;/strong&gt; Although it's not required, it will help to have a basic understanding of WebRTC principles like media streams, peer connections, and signaling. For an overview, you can consult the official WebRTC documentation at &lt;a href="https://webrtc.org/"&gt;https://webrtc.org/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Setup(if needed):&lt;/strong&gt; Ensure that your Laravel application's database setup is configured appropriately, taking into account the requirements of your particular project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These requirements must be satisfied for you to effectively integrate WebRTC capabilities into your Laravel application and follow the subsequent instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is WebRTC
&lt;/h2&gt;

&lt;p&gt;WebRTC, which stands for Web Real-Time Communication, is an open-source project that enables real-time communication directly between web browsers. It provides a set of APIs (Application Programming Interfaces) and communication protocols that allow web applications to establish peer-to-peer connections for various types of media, including audio, video, and data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features Of WebRTC&lt;/strong&gt;&lt;br&gt;
       &lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Peer Connection:&lt;/strong&gt; WebRTC eliminates the need for middle servers by enabling direct browser-to-browser communication. A collection of protocols for signaling, negotiating, and creating a secure connection are used to create this peer-to-peer connection.&lt;br&gt;
      &lt;strong&gt;2.&lt;/strong&gt; &lt;strong&gt;getUserMedia:&lt;/strong&gt; This API makes it possible for web apps to access a user's microphone and camera, allowing them to record audio and video feeds. It is an essential component in developing real-time audio and video communication applications.&lt;br&gt;
      &lt;strong&gt;3.&lt;/strong&gt; &lt;strong&gt;RTCPeerConnection:&lt;/strong&gt; At the heart of WebRTC, this API controls peer-to-peer communication, taking care of things like codec negotiation, security, and data, video, and audio transmission.&lt;br&gt;
      &lt;strong&gt;4.&lt;/strong&gt; &lt;strong&gt;RTCDataChannel:&lt;/strong&gt; This API allows peers to communicate any kind of data in real-time. Applications requiring the conveyance of non-media information will find it very helpful.&lt;br&gt;
    &lt;strong&gt;5&lt;/strong&gt;. &lt;strong&gt;Signaling:&lt;/strong&gt; Signalling: Before establishing a connection, WebRTC peers must exchange information using a signaling mechanism. Coordinating communication, exchanging session descriptions, and negotiating parameters are under the purview of signaling.&lt;br&gt;
    &lt;strong&gt;6&lt;/strong&gt;. &lt;strong&gt;STUN and TURN Servers:&lt;/strong&gt; To overcome network address translation (NAT) problems and create connections even when peers are behind firewalls or routers, WebRTC makes use of STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays across NAT) servers.&lt;/p&gt;

&lt;p&gt;A wide range of real-time communication applications, such as online games, audio calls, video conferences, live streaming, and collaboration tools, are frequently built using WebRTC. For developers creating dynamic and captivating online apps, its open architecture, standardized APIs, and broad browser compatibility (supporting Chrome, Firefox, Safari, and Edge) make it a potent and easily obtainable technology.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To Implement WebRTC In Your Laravel Project
&lt;/h2&gt;

&lt;p&gt;The process of integrating the frontend and backend components required for real-time client communication in a Laravel project is known as WebRTC implementation. This is a detailed how-to for integrating WebRTC into your Laravel project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Set Up a New Laravel Project:&lt;/strong&gt;&lt;br&gt;
Use Composer to start a new Laravel project if you don't already have one:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer create-project laravel/laravel your-project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Navigate to your project directory:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd your-project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Install Necessary Packages:&lt;/strong&gt;&lt;br&gt;
Use npm to install Laravel Mix and other frontend dependencies:&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Set Up a Vue Component for WebRTC:&lt;/strong&gt;&lt;br&gt;
Create a Vue component to handle the frontend part of your WebRTC implementation. This component will be responsible for capturing media streams, establishing peer connections, and handling real-time communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Install Simple-Peer Library:&lt;/strong&gt;&lt;br&gt;
Use npm to install the &lt;code&gt;simple-peer&lt;/code&gt; library, which simplifies the WebRTC peer connection process:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install simple-peer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;5. Create WebRTC Methods in Vue Component:&lt;/strong&gt;&lt;br&gt;
In your Vue component, create methods to handle WebRTC functionality. This includes capturing audio and video, establishing a peer connection, handling signaling, and managing data channels.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Example methods in your Vue component
methods: {
  async startWebRTC() {
    // Code to initiate WebRTC
    // Capture audio and video, establish peer connection, etc.
  },

  handleSignalingData(data) {
    // Code to handle signaling data
    // Exchange offer, answer, and ICE candidates
  },

  // Other WebRTC-related methods
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;6. Set Up WebRTC Signaling in Laravel:&lt;/strong&gt;&lt;br&gt;
Create Laravel routes and controllers to handle WebRTC signaling. This involves setting up endpoints for exchanging offers, answers, and ICE candidate information between clients.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php
// Example routes/web.php
Route::post('/offer', 'WebRTCController@offer');
Route::post('/answer', 'WebRTCController@answer');
Route::post('/ice-candidate', 'WebRTCController@iceCandidate');
php
// Example app/Http/Controllers/WebRTCController.php
class WebRTCController extends Controller {
    public function offer(Request $request) {
        // Handle offer signaling data
    }

    public function answer(Request $request) {
        // Handle answer signaling data
    }

    public function iceCandidate(Request $request) {
        // Handle ICE candidate signaling data
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Database Setup (Optional):&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Establish a database connection and perform any necessary migrations if your application calls for room management or user authentication.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Use HTTPS:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To comply with WebRTC security standards, make sure your application is provided over HTTPS.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Turning on and off servers:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To manage NAT traversal, take into consideration installing STUN and TURN servers. Use servers that are accessible to the public or create your own.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Examining&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Make sure you test your WebRTC solution thoroughly in a variety of browsers. For troubleshooting, use resources like the WebRTC internals of Google Chrome.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Record-keeping:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep a record of your WebRTC implementation, including information on peer connection management, signaling protocol, and other pertinent aspects.&lt;br&gt;
You should be able to successfully integrate WebRTC and enable real-time communication capabilities in your Laravel project by following these instructions. Hold on to&lt;/p&gt;

&lt;h2&gt;
  
  
  Things That WebRTC Can Be Used To Achieved
&lt;/h2&gt;

&lt;p&gt;Numerous real-time communication and collaboration functions in online apps may be achieved with the help of WebRTC (online Real-Time Communication), a potent technology. The following are some examples of use cases and tasks that WebRTC may perform:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Video Conferencing:&lt;/strong&gt; Create apps that enable real-time group collaboration on discussions, virtual meetings, and video conferences among several people.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Voice Calling:&lt;/strong&gt; Provide people the option to make phone calls straight from their web browsers, without requiring any extra software or plugins.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating systems for &lt;strong&gt;live-streaming&lt;/strong&gt; events, seminars, games, and other material with real-time audio and video capabilities is known as live streaming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;File Sharing:&lt;/strong&gt; Enable users to safely transfer files directly between their browsers by implementing peer-to-peer file-sharing features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Screen Sharing:&lt;/strong&gt; To improve collaboration and communication, allow screen sharing for presentations, remote help, and group projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaborative Tools:&lt;/strong&gt; Provide real-time collaboration for numerous users by developing collaborative tools like code pairing, interactive whiteboards, and document editing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Online Education:&lt;/strong&gt; Provide interactive learning environments, live virtual classrooms, and one-on-one tutoring as features for your online education platforms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gaming:&lt;/strong&gt; Real-time communication tools, such as audio and video chat between participants, can improve multiplayer online gaming experiences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customer help:&lt;/strong&gt; By incorporating live chat, audio, or video help straight into websites or applications, you may enhance your customer support offerings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Healthcare Applications:&lt;/strong&gt; Develop telemedicine applications that enable video conversations between patients and medical professionals at a distance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Internet of Things (IoT):&lt;/strong&gt; WebRTC integration allows objects to communicate in real time, facilitating remote monitoring and control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Social networking:&lt;/strong&gt; Incorporate capabilities such as live streaming video, video calls, and instantaneous user interactions into social networking platforms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Virtual Events:&lt;/strong&gt; Organise online conferences, trade exhibitions, or events where attendees may interact with one another.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Virtual Events:&lt;/strong&gt; Organise online conferences, trade exhibitions, or events where attendees may communicate with one another via chat, audio, and video.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Webinars and Workshops:&lt;/strong&gt; Hold interactive webinars and workshops that let attendees and presenters have in-the-moment conversations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security Surveillance:&lt;/strong&gt; Use real-time video surveillance software to keep an eye on and secure real estate or areas.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Real-Time Translation Services:&lt;/strong&gt; Make real-time translation services available so that users may converse in many languages while using automatic translation tools.&lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, exploring the integration of WebRTC into your Laravel project opens up a world of possibilities for real-time communication and collaboration. As discussed, WebRTC empowers developers to implement features like video conferencing, voice calling, live streaming, collaborative tools, and much more directly within web browsers. The combination of Laravel's robust backend capabilities and WebRTC's versatility on the front end creates a powerful synergy for building interactive and engaging web applications.&lt;/p&gt;

&lt;p&gt;We’ll call it a day here, we’ll look at &lt;strong&gt;How To Use WebRTC To Build Something!&lt;/strong&gt; &lt;br&gt;
&lt;strong&gt;Read Carefully!!!&lt;/strong&gt;&lt;br&gt;
Hope you’ve gained tons of value from this tutorial! Till next time bye.&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; has &lt;code&gt;2+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;/p&gt;

&lt;p&gt;His stacks include &lt;code&gt;ReactJ&lt;/code&gt;, &lt;code&gt;Laravel&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;, and other languages and frameworks.&lt;br&gt;
As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;/p&gt;

&lt;p&gt;If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please go to and follow him on his &lt;a href="https://dev.to/emmykolic/%%20embed%20https://emmykolic.github.io%"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://facebook.com/Emmykolic/%"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://github.com/emmykolic%"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://www.linkedin.com/in/emmanuel-okolie-435588238/%"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://dev.to/emmykolic/%%20embed%20https://www.twitter.com/emmykolic%"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>programming</category>
      <category>webrtc</category>
    </item>
    <item>
      <title>How To Make Car Game Using Vanilla JavaScript (Beginners)</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Sun, 03 Dec 2023 22:35:16 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-make-car-game-using-vanilla-javascript-beginners-2m0a</link>
      <guid>https://dev.to/emmykolic/how-to-make-car-game-using-vanilla-javascript-beginners-2m0a</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Growing up as a child, I've always wanted to make games. Especially the car game! I love car games, so as a developer I found out that you can be a beginner in Programming with little knowledge of some programming languages and be able to build a simple car game.&lt;/p&gt;

&lt;p&gt;In this tutorial, we are going to see the step-by-step way, to make a car game using HTML, CSS, and JavaScript! And we will be precise.&lt;/p&gt;

&lt;p&gt;Without wasting Your time, Let's Jump into this Guide!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisites&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The prerequisites for making a car game using vanilla JavaScript are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML &amp;amp; CSS: You need to know this base! cause it’s the view that people see and interact with. so before jumping on the guide, you should the basic programming languages HTML And CSS.&lt;/li&gt;
&lt;li&gt;Vanilla JavaScript: Here you need to know how to use plain JavaScript that doesn’t contain OOP. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: You should at least be conversant with functions using vanilla Js. Once you've met these requirements, you may go on to proceed and make your car using vanilla JavaScript:&lt;/p&gt;

&lt;p&gt;Now you are good to go!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step By Step On How To Make A Car Game&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Make An HTML Page&lt;/strong&gt;&lt;br&gt;
Now The first thing to do is this, have an index.html page. &lt;br&gt;
Note: This is the first page to run when you load it on your browser. so in the index page, you’ll create links using the link tag &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; to link to other pages in the folder such as the style.css page, etc. The remaining code snippet will be the view, it contains classes and ID’s used for easy targeting of the CSS and JavaScript classes. The index.html has the following code snippet below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;!doctype html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="css/fontawesome/css/all.min.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="css/style.css"&amp;gt;
    &amp;lt;title&amp;gt;3D Car Drive!&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body onload="done()"&amp;gt;
    &amp;lt;div id="scoreDiv"&amp;gt;
      &amp;lt;span id="score"&amp;gt;0&amp;lt;/span&amp;gt;
      &amp;lt;img src="https://image.ibb.co/jRAp0y/coin.png" id="cn"&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="gameHome" id="startPage"&amp;gt;
      &amp;lt;div id="gameTitle"&amp;gt;3D Car Drive!&amp;lt;/div&amp;gt;
      &amp;lt;button onclick="ld()" id="playBtn"&amp;gt;
          &amp;lt;span style="font-size:18px"&amp;gt;Loading Assets&amp;lt;br&amp;gt;Please Wait...&amp;lt;br&amp;gt;This may take a few seconds for first time&amp;lt;/span&amp;gt;
      &amp;lt;/button&amp;gt;&amp;lt;br&amp;gt;
      &amp;lt;div id="ldc"&amp;gt;&amp;lt;div id="loading"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;p&amp;gt;Rotate your phone &amp;amp; tilt left/right or tap left/right side of screen to move the car&amp;lt;br&amp;gt;Use left/right arrow key on your PC&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div id="mainContainer" style="background:#0f0" &amp;gt;
        &amp;lt;img id="city" src="https://image.ibb.co/jCGU0y/cty.jpg"&amp;gt;
        &amp;lt;canvas id="myCanvas" style="/*background:#9de732*/" &amp;gt;&amp;lt;/canvas&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;img class="aImg" id="t1" src="https://image.ibb.co/dZi5Ly/t1.png"&amp;gt;
    &amp;lt;img class="aImg" id="t2" src="https://image.ibb.co/jajjDJ/t2.png"&amp;gt;
    &amp;lt;img class="aImg" id="t3" src="https://image.ibb.co/it4jDJ/t5.png"&amp;gt;
    &amp;lt;img class="aImg" id="t4" src="https://image.ibb.co/ksy0nd/t4.png"&amp;gt;
    &amp;lt;img class="aImg" id="c1" src="https://image.ibb.co/f4v7YJ/c2.png"&amp;gt;


    &amp;lt;script src="js/script.js"&amp;gt;&amp;lt;/script&amp;gt;

  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After Running the HTML snippet what you’ll see in the view after refreshing your web browser would look like this!&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%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701558539125_Screenshot%2B78.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%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701558539125_Screenshot%2B78.png" alt="HTML View From Emmykolic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So without wasting time the next thing is to write the CSS code for the HTML. After writing the CSS code, the above view won’t be seen until you’ve added the JavaScript!  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Make A CSS Page&lt;/strong&gt;&lt;br&gt;
Secondly, what you should do is create a page and call it style.css what this page does it’s responsible for the beautification of our Car Game. and it is the page that holds the ID’s and classes in the index.html, then it’s targeted in the style.css.&lt;br&gt;
Below is the code snippet for the style.css&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body{
    margin:0;
    height:100vh;
    width:100vw;
}

#mainContainer {
    position:absolute;
    top:0;
    left:0;
    transform-origin:0% 0%;
    width:100%;
    transform:  translateX(0px) rotate(0deg);
    overflow: hidden;
}

#city {
    position:absolute;
    top:0;
    left:0;
    height:30vw;
    width:100%;
    z-index:-1;
    display: block;
}

#myCanvas {
    background:transparent;
    z-index: 100;
}

.aImg {
    display:none;
}

#mainContainer {
    display:none;
}

#scoreDiv {
    position:absolute;
    right:0;
    background:transparent;
    display:inline-block;
    border:3px solid red;
    padding:3px 50px 3px 10px;
    border-radius:20px;
    font-weight:700;
    font-size:24px;
    height:30px;
    margin:10px;
    z-index:1000;
    transform-origin:100% 0%;
}

#cn {
    height:52px;
    width:52px;
    background:red;
    position:absolute;
    right:-8px;
    top:-8px;
    border-radius:50%;
}

.gameHome {
    position:absolute;
    top:0;
    left:0;
    background:#fff;
    height:100vh;
    width:100vw;
    transform-origin:0% 0%;
    text-align:center;
}

#gameTitle {
    text-align:center;
    font-family:cursive;
    font-size:35px;
    margin-top:50px;
    font-weight:800;
}

#playBtn {
    font-size:20px;
    display:inline-block;
    background:#1642ea;
    color:#fff;
    padding:3px 25px;
    margin-top: 100px;
    border:none;
    border-radius:10px;
    box-shadow:3px 4px #000;
    outline:none;
}

#gameConf {
    width:50%;
    height:100%;
    background:red;
}

#gameDifficulty {
    width:100%;
    height:50%;
    background:blue;
    padding:0;
    margin:0;
}

.diffOpt {
    background:green
    font-family:cursive;
    font-size:20px;
    text-align:center;
}

#loading {
    height:60px;
    width:60px;
    background:transparent;
    display:inline-block;
    border:10px solid transparent;
    border-bottom-color:red;
    border-left-color:red;
    border-radius:50%;
    animation:ld 1s linear infinite;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After running the CSS code Snippet below is the View you’ll see.&lt;/p&gt;

&lt;p&gt;&lt;a href="/static/img/pixel.gif" class="article-body-image-wrapper"&gt;&lt;img src="/static/img/pixel.gif" alt="CSS View From Emmykolic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason for this view is that CSS works hand-in-hand with JavaScript. In this case, no matter how you click on that button it won’t respond because there’s no JavaScript yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Make A JavaScript Page&lt;/strong&gt;&lt;br&gt;
Lastly, create a page and name it script.js script.js will contain a lot of JavaScript that will work with the ID’s and classes as well! This Javascript plays a vital role in the accomplishment of this car game. Below is the JavaScript code snippet.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function(){
    "use strict"
    var hw = window.innerWidth || 360;
    var hh = window.innerHeight || 560;
    var gameHome = document.getElementById("startPage");
    var scoreDiv = document.getElementById("scoreDiv");
    if(hh &amp;gt; hw){
        gameHome.style.height = hw+"px";
        gameHome.style.width = hh+"px";
        gameHome.style.transform = "translateX("+hw+"px) rotate(90deg)";
        scoreDiv.style.bottom = 0;
        scoreDiv.style.transform = "rotate(90deg) translateX(40px)";
    }
})();

var ld;
var loaded = false;

function done(){
    document.getElementById("ldc").innerHTML="";
    document.getElementById("ldc").style.display = "none";
    document.getElementById("playBtn").innerHTML = "PLAY";
    loaded = true;
}

(function(){
    var w = window.innerWidth || 360;
    var h = window.innerHeight || 560;

    if(h &amp;gt; w){
        var nh = h;
        h = w;
        w = nh;
        document.getElementById("mainContainer").style.transform = "translateX("+(h)+"px) rotate(90deg)";
    }
    document.getElementById("mainContainer").style.width = w+"px";
    document.getElementById("mainContainer").style.height = h+"px";

    document.getElementById("city").style.height = h*.3+"px";
    document.getElementById("city").style.width = w+"px";

    var c = document.getElementById("myCanvas");
    c.height = h;
    c.width = w;

    var ctx = c.getContext("2d");

function loadGame(){
    "use strict";

    var roadWidth = 5*w/36;
    var roadTop = h-h*0.7;
    var roadLeft = (w-roadWidth)/2;
    var roadConstant = roadLeft/(h-roadTop);
    var score = 0;
    var scoreC = document.getElementById("score");
    function updateScore(ds){
        score+=ds;
        scoreC.textContent = score;
    }
    updateScore(0);

    var rso = [];
    var ratio = 0.8;
    var totalRso = 20;
    var maxHF = h*(1-ratio)/(2.25*(1-Math.pow(ratio,totalRso)));
    var maxH = maxHF;
    var totalHeight = 0.7*h;
    var minWidth = 1;
    var maxWidth = 26;
    var dif = maxWidth - minWidth;
    var changedHeight = totalHeight-maxH*ratio;
    var cnst1 = Math.pow(ratio,totalRso)/(1-ratio);
    var stp = h-totalHeight;
    var tMaxH = h*20/36;
    var treeCnst = tMaxH/roadLeft;

    var gameDifficulty = 100;



    function TreeBuilder(src,src2,start,left){
        this.src = treeSrc[src];
        this.src2 = treeSrc[src2];
        this.y = start;
        this.x = 0;
        this.h = 0;
        this.w = 0;
        this.dy = 0.01;
        this.r = 1.009;
        this.left = left;
    }

    TreeBuilder.prototype.draw = function(){
        this.y += this.dy;
        this.dy *= this.r;
        this.x = (h-this.y)*roadConstant - this.w - this.w*this.left;
        this.h = (roadLeft-this.x-this.w*this.left)*treeCnst;
        this.w = this.h*2/3;

        ctx.drawImage(this.src,this.x,this.y-this.h,this.w,this.h);
        ctx.drawImage(this.src2,w-this.x-this.w,this.y-this.h,this.w,this.h);

        if(this.y &amp;gt;= h){
            this.y = stp;
            this.h = 0;
            this.w = 0;
            this.left = Math.random()*3;
            this.dy = 0.5;
        }
    }

    function _i(x){
        return document.getElementById(x);
    }
    var treeSrc = [_i("t1"),_i("t2"),_i("t3"),_i("t4")];

    var trees = [];
    for(var n = 0; n &amp;lt; ((h*0.7)/50-2); n++){
        trees.push(new TreeBuilder(Math.floor(Math.random()*4),Math.floor(Math.random()*4),stp+n*50,2));
    }


    var carWCnst = roadLeft*2/totalHeight;
    var carW = (w &amp;gt; 560) ? 120 : 90;
    var carH = carW*2/3;

    function CarBuilder(src,start,lane){
        this.src = carSrc[src];
        this.y = start;
        this.x = 0;
        this.h = 0;
        this.w = 0;
        this.dy = 0.5;
        this.lane = lane;
    }

    CarBuilder.prototype.draw = function(){
        this.dy *= 1.01;
        this.y += this.dy;
        this.x = (carWCnst/2)*(h-this.y)+(w-(carWCnst*(h-this.y)))*this.lane/8;
        this.w = carW-carW*carWCnst*(h-this.y)/w;
        this.h = 1.7*this.w/3;

        ctx.drawImage(this.src,this.x,this.y-this.h,this.w,this.h);
        if(this.y &amp;gt;= h-20){
            if(Math.abs(this.x-cx) &amp;lt;= carH &amp;amp;&amp;amp; Math.abs(this.y-h+carH) &amp;lt;= carH){
                clearInterval(intv);
                setTimeout(function(){
                    document.getElementById("mainContainer").style.display = "none";
                    document.getElementById("startPage").style.display = "block";
                },1000);
            }
        }
        if(this.y &amp;gt;= h+100){
            this.y = stp;
            this.h = 0;
            this.w = 0;
            this.left = Math.random()*3;
            this.dy = 0.5;
            this.lane = 1+Math.random()*5;
        }
    }

    var carSrc = [_i("c1"),_i("c1"),_i("c1")];

    var cars = [];
    for(var n = 0; n &amp;lt; ((h*0.7+100)/gameDifficulty); n++){
        cars.push(new CarBuilder(Math.floor(Math.random()*3),stp+n*gameDifficulty,1));
    }

    //Coin.....
    var coinW = (w &amp;gt; 560) ? 75 : 60;
    function CoinBuilder(start,lane){
        this.src = coinSrc;
        this.y = start;
        this.x = 0;
        this.h = 0;
        this.w = 0;
        this.dy = 0.5;
        this.lane = lane;
    }

    CoinBuilder.prototype.draw = function(){
        this.dy *= 1.01;
        this.y += this.dy;
        this.x = (carWCnst/2)*(h-this.y)+(w-(carWCnst*(h-this.y)))*this.lane/8;
        this.w = coinW-coinW*carWCnst*(h-this.y)/w;
        this.h = this.w;

        ctx.drawImage(this.src,this.x,this.y-this.h,this.w,this.h);
        if(this.y &amp;gt;= h-20){
            if(Math.abs(this.x-cx) &amp;lt;= coinW &amp;amp;&amp;amp; Math.abs(this.y-h+coinW) &amp;lt;= coinW){
                this.y = stp;
                this.h = 0;
                this.w = 0;
                this.left = Math.random()*3;
                this.dy = 0.5;
                this.lane = Math.floor(1+Math.random()*5);
                updateScore(1);
            }
        }
        if(this.y &amp;gt;= h+100){
            this.y = stp;
            this.h = 0;
            this.w = 0;
            this.left = Math.random()*3;
            this.dy = 0.5;
            this.lane = Math.floor(1+Math.random()*5);
        }
    }

    var coinSrc = _i("cn");

    var coins = [];
    for(var n = 0; n &amp;lt; ((h*0.7+100)/(gameDifficulty-50)); n++){
        coins.push(new CoinBuilder(stp+n*(gameDifficulty-50),6));
    }



    //End Coin...



    function rectPoints(n,ho){
        n = totalRso-n-1;
        var y1 = stp+maxH*cnst1*(Math.pow(1/ratio,n)-1);
        var x1 = roadLeft-roadConstant*(y1-stp);
        var y2 = y1;
        var x2 = x1 + minWidth+(y1-stp)*dif/totalHeight;
        var y3 = y1 + maxH*cnst1*(Math.pow(1/ratio,n+1)-1);
        var x3 = roadLeft-roadConstant*(y3-stp);
        var y4 = y3;
        var x4 = x3 + minWidth+(y3-stp)*dif/totalHeight;

        return [x1,y1,x2,y2,x4,y4,x3,y3];
    }


    for(var n = 0; n &amp;lt; totalRso; n++){
        rso.push(rectPoints(n,h));
        rso\[n\][8] = (n%2==0) ? "#000" : "#fff";
    }

    function draw(){
        ctx.beginPath();
        ctx.moveTo((w-roadWidth)/2,stp);
        ctx.lineTo((w-roadWidth)/2+roadWidth,stp);
        ctx.lineTo(w,h);
        ctx.lineTo(0,h);
        ctx.fillStyle="#555";
        ctx.fill();
        ctx.closePath();
        for(var n = 0; n &amp;lt; totalRso; n++){
            ctx.beginPath();
            ctx.moveTo(rso\[n\][0],rso\[n\][1]);
            ctx.lineTo(rso\[n\][2],rso\[n\][3]);
            ctx.lineTo(rso\[n\][4],rso\[n\][5]);
            ctx.lineTo(rso\[n\][6],rso\[n\][7]);
            ctx.lineTo(rso\[n\][0],rso\[n\][1]);
            ctx.lineWidth = 2;
            ctx.fillStyle = rso\[n\][8];//"rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
            ctx.fill();
            ctx.closePath();

            ctx.beginPath();
            ctx.moveTo(w-rso\[n\][0],rso\[n\][1]);
            ctx.lineTo(w-rso\[n\][2],rso\[n\][3]);
            ctx.lineTo(w-rso\[n\][4],rso\[n\][5]);
            ctx.lineTo(w-rso\[n\][6],rso\[n\][7]);
            ctx.lineTo(w-rso\[n\][0],rso\[n\][1]);
            ctx.lineWidth = 2;
            ctx.fillStyle = rso\[n\][8];//"rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
            ctx.fill();
            ctx.closePath();


        }

    }

    var cx = (w-carW)/2;
    var cl = false, cr = false;
    var car = _i("c1");
    var ms = 3*w/560;
    function drawCar(){
        if(cl) if(cx+carW+50 &amp;lt; w) cx+=ms;
        if(cr) if(cx-50 &amp;gt; 0) cx-=ms;
        ctx.drawImage(car,cx,h-carH,carW,carH);
    }


    var m = 0;
    var intv = setInterval(function(){
        try{
        ctx.clearRect(0,0,w,h);
        maxH+=0.5;
        changedHeight = maxH*cnst1*(Math.pow(1/ratio,totalRso-1)-1);//maxH*(1-Math.pow(ratio,totalRso-5))/(1-ratio);
        if(changedHeight &amp;gt;= totalHeight){
            maxH = maxHF;
            m++;
        }
        for(var n = 0; n &amp;lt; totalRso; n++){
            rso[n]=rectPoints(n,h-totalHeight+changedHeight);
            if(m%2==0) rso\[n\][8] = (n%2==0) ? "#000" : "#fff";
            else rso\[n\][8] = (n%2==1) ? "#000" : "#fff";
        }
        draw();
        for(var n = 0; n &amp;lt; trees.length; n++){
            trees[n].draw();
        }

        for(var n = 0; n &amp;lt; coins.length; n++){
            coins[n].draw();
        }

        for(var n = 0; n &amp;lt; cars.length; n++){
            cars[n].draw();
        }


        drawCar();
        }catch(err){

        }

    },10)
    //draw();

    //Game Control

    //Touch
    function getTouch(e){
        e.preventDefault();
        var to = e.changedTouches[0];
        var ty = parseInt(to.clientY);
        if(ty&amp;gt;(h/2)){
            cl = true;
        }
        else{
            cr = true;
        }
    }
    function getTouchEnd(){
        cl = false;
        cr = false;
    }

    c.removeEventListener("touchstart",getTouch);
    c.removeEventListener("touchend",getTouchEnd);
    c.addEventListener("touchstart",getTouch);
    c.addEventListener("touchend",getTouchEnd);
    //Key..
    function getKey(e){
        e.preventDefault();
        var ty = e.keyCode;
        if(ty===39){
            cr = false;
            cl = true;
        }
        else if(ty===37){
            cl = false;
            cr = true;
        }
    }
    function getKeyEnd(e){
        var ty = e.keyCode;
        if(ty === 39) cl = false;
        else if(ty === 37) cr = false;
    }

    document.body.removeEventListener("keydown",getKey);
    document.body.removeEventListener("keyup",getKeyEnd);
    document.body.addEventListener("keydown",getKey);
    document.body.addEventListener("keyup",getKeyEnd);
    //Accelarometre

    function driveCar(e){
        var y = e.accelerationIncludingGravity.y;

        if(y &amp;gt; 0){
            if(cx+carW+50 &amp;lt; w) cx += y*ms;
        }
        else{
            if(cx-50 &amp;gt; 0) cx += y*ms;
        }
    }

    if(window.DeviceMotionEvent){
        window.removeEventListener("devicemotion",driveCar)
           window.addEventListener("devicemotion",driveCar,false)
    }
    //End
}
ld = function(){
    if(loaded){
        document.getElementById("startPage").style.display = "none";
        document.getElementById("mainContainer").style.display = "block";
        loadGame();
    }
}
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Below is the view you'll see immediately after you apply the JavaScript Snippet above. But the difference between this view and the previous one is that the button is now clickable.&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%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701637301941_Screenshot%2B80.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%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701637301941_Screenshot%2B80.png" alt="View From Emmykolic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So After implementing this code correctly Below is what you’ll see on your screen.&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%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701639144860_Animation.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropboxusercontent.com%2Fs_3C4E0894647978479906D60DC518D5C4A92986FEDB25BBB501683A733C594351_1701639144860_Animation.gif" alt="A Short video of the car game"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Wow, we have come to the end of this Guide. Hope you’ve gained a measure of value from it. Briefly, we have seen the step-by-step way, to build a car game.&lt;/p&gt;

&lt;p&gt;Note: the entire JavaScript code is called vanilla JavaScript cause I didn’t use any Library or Framework to write any line!&lt;/p&gt;

&lt;p&gt;Please follow me on my various social media platforms, and feel free to send me an email when necessary!&lt;/p&gt;

&lt;p&gt;Without wasting much of your time till next time, bye.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;About The Author&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; has &lt;code&gt;2+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;/p&gt;

&lt;p&gt;His stacks include &lt;code&gt;ReactJ&lt;/code&gt;, &lt;code&gt;Laravel&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;, and other languages and frameworks.&lt;br&gt;
As a freelancer, he creates websites for clients and writes technical guides to show people how to do what he does.&lt;/p&gt;

&lt;p&gt;If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please go to and follow him on his &lt;a href="https://dev.to/emmykolic/%%20embed%20https://emmykolic.github.io%"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://facebook.com/Emmykolic/%"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://github.com/emmykolic%"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://dev.to/emmykolic/%%20embed%20https://www.linkedin.com/in/emmanuel-okolie-435588238/%"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://dev.to/emmykolic/%%20embed%20https://www.twitter.com/emmykolic%"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>gamedev</category>
      <category>porgramming</category>
    </item>
    <item>
      <title>Efficient API Interaction And Consumption With Laravel: A Beginner's Guide</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Thu, 21 Sep 2023 21:12:04 +0000</pubDate>
      <link>https://dev.to/emmykolic/efficient-api-interaction-and-consumption-with-laravel-a-guide-1ghk</link>
      <guid>https://dev.to/emmykolic/efficient-api-interaction-and-consumption-with-laravel-a-guide-1ghk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Laravel is a popular PHP framework for developing and building web applications and API. As a developer, there will come a time when you will need to create your API or Consume an External API, and Interact with it. this is one phase you can’t run away from, so as a Laravel Developer There are ways to consume and interact with an API which is what we will be looking at.&lt;br&gt;
API is an acronym that stands for Application Programming Interface. API does Cool things and That is one reason developers accept it.&lt;br&gt;
So without wasting much of Your Time, jump straight into This Tutorial.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;The prerequisites for creating and interacting with an API are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PHP: Make sure you know PHP and how to use OOP to be precise. Laravel is a framework of PHP so you need to have PHP installed on your system. Note: you should have a PHP version greater than version 7.8 installed in your system.&lt;/li&gt;
&lt;li&gt;Composer: A PHP dependency management is called Composer. It is used to manage and install the dependencies that Laravel needs. The composer must be set up on your computer.&lt;/li&gt;
&lt;li&gt;Web Server: To serve your Laravel application, you'll need a web server like Xampp OR Wamp server. Both servers enable you to use MySQL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you've met these requirements, you may go on to proceed and interact with an API in Laravel:&lt;br&gt;
Now you are good to go!&lt;/p&gt;
&lt;h2&gt;
  
  
  Steps By Step Process: Interact And Consume an API using Laravel
&lt;/h2&gt;

&lt;p&gt;To interact and consume an API using Laravel, there are two steps which I will show you below:&lt;br&gt;
Two Steps to Consume An API**&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first step is to consume a free API, using the &lt;code&gt;routes/web.php&lt;/code&gt; to interact and consume the API. Below are Steps to achieve that.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 1: Install Laravel&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal and run the following command to create a new Laravel project:&lt;/li&gt;
&lt;li&gt;composer create-project --prefer-dist laravel/laravel my-API-project&lt;/li&gt;
&lt;li&gt;Change to the project directory:&lt;/li&gt;
&lt;li&gt;cd my-api-project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 2: Get your API.&lt;br&gt;
For the Sake of this project, we’ll be using Free API Which I got from &lt;a href="https://apipheny.io/free-api/" rel="noopener noreferrer"&gt;&lt;strong&gt;Free API&lt;/strong&gt;&lt;/a&gt; *****&lt;strong&gt;&lt;em&gt;so you can get yours from there or any free API site. The API we are using is a&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://official-joke-api.appspot.com/random_joke" rel="noopener noreferrer"&gt;&lt;em&gt;Random Joke API&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;*&lt;br&gt;
Step 3: Visit the web.php&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit your &lt;code&gt;routes/web.php&lt;/code&gt; in the project you just created:&lt;/li&gt;
&lt;li&gt;Create a view using the &lt;code&gt;Route::get()&lt;/code&gt; to interact and consume the API. We will be using the&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;welcome page to view the outcome of our API.&lt;br&gt;
Below is the code snippet that you will code in your &lt;code&gt;**routes/web.php**&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    use Illuminate\Support\Facades\Route;
    use Illuminate\Support\Facades\Http;

    Route::get('/', function(){
      $response = Http::get('https://official-joke-api.appspot.com/random_joke');
      $data = $response-&amp;gt;json();

       return view('welcome', 
        ["type" =&amp;gt; $data['type']],
        ["setup"=&amp;gt; $data['setup']],
        );
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In summary, this code defines a route that, when accessed, requests an API to fetch a random joke. It then renders a view called "welcome" and passes the retrieved joke data to the idea for display or further processing. Note an API returns &lt;strong&gt;Extensible Markup Language (XML)&lt;/strong&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;strong&gt;JavaScript Object Notation(JSON).&lt;/strong&gt;&lt;br&gt;
Step4: Display The API In Your View&lt;br&gt;
Now to view this API, my view is &lt;code&gt;**welcome.blade.php**&lt;/code&gt; We will echo the value of the API in an HTML tag it will display the resource of the API on the browser. Let’s have an example of what I’m saying without wasting much of your time.&lt;br&gt;
In your &lt;code&gt;**views/welcome.blade.php**&lt;/code&gt; Below is the following code snippet to output what we wrote previously in the &lt;code&gt;**routes/web.php**&lt;/code&gt; file. We used the &lt;code&gt;**{{ }}**&lt;/code&gt; syntax to output the value of the variable in the generated HTML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;!DOCTYPE html&amp;gt;
    &amp;lt;html lang="{{ str_replace('_', '-', app()-&amp;gt;getLocale()) }}"&amp;gt;
        &amp;lt;head&amp;gt;
            &amp;lt;meta charset="utf-8"&amp;gt;
            &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;

            &amp;lt;title&amp;gt;API&amp;lt;/title&amp;gt;

            &amp;lt;!-- Fonts --&amp;gt;
            &amp;lt;link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&amp;amp;display=swap" rel="stylesheet"&amp;gt;
            &amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"&amp;gt;

        &amp;lt;/head&amp;gt;
          &amp;lt;body class="antialiased"&amp;gt;

            &amp;lt;div class="container my-3"&amp;gt;
              &amp;lt;div class="row justify-content-center"&amp;gt;
                &amp;lt;div class="col-lg-6"&amp;gt;
                  &amp;lt;div class="card shadow" style="width: 18rem;"&amp;gt;
                    &amp;lt;div class="card-body"&amp;gt;
                      &amp;lt;h3 class="fw-bold text-uppercase"&amp;gt;{{ $type }}&amp;lt;/h3&amp;gt;
                      &amp;lt;p class="card-text lead text-muted"&amp;gt;{{ $setup }}&amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;

            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: in the above code snippet we used Bootstrap 5 to have a better view, whenever you refresh the page in the browser the output will change. Below is how what we’ve done looks like.&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%2Fpaper-attachments.dropboxusercontent.com%2Fs_37C0A1F6915E270C437EEEAE51C10709AD03F81CE12281BDF2FD23B99D1434ED_1688387599896_Screenshot%2B2023-07-03%2Bat%2B13-32-08%2BApi%2BTesting.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%2Fpaper-attachments.dropboxusercontent.com%2Fs_37C0A1F6915E270C437EEEAE51C10709AD03F81CE12281BDF2FD23B99D1434ED_1688387599896_Screenshot%2B2023-07-03%2Bat%2B13-32-08%2BApi%2BTesting.png" alt="An Output Of The entire code snippet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Second way is to consume an API with a key using the &lt;code&gt;**app\Http\controllers\**&lt;/code&gt; to interact and consume the API. Below are Steps to achieve this.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First, visit the &lt;code&gt;**routes/web.php**&lt;/code&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Create a route that will take you to your desired controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you visit the web.php file you’ll write a line of code that’s the route that will be interacting with the Controller and API at the same time.&lt;br&gt;
Below is the code snippet that you will code in your &lt;code&gt;**routes/web.php**&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    use Illuminate\Support\Facades\Route;
    use App\Http\Controllers\ConsumeController;

    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider and all of them will
    | be assigned to the "web" middleware group. Make something great!
    |
    */

    Route::get('/consume', [ConsumeController::class,'index']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Code Above code snippet was named in my way, so you are free to use your naming conventions.&lt;br&gt;
To make your Controller, you’ll write:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:controller ConsumeController
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Then visit the &lt;code&gt;**app\http\controllers\ConsumeController**&lt;/code&gt; on your folder directory, then you’ll see a file named &lt;code&gt;**ConsumeController.php**&lt;/code&gt; Open the file you’ll see a code snippet like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    class ConsumeController extends Controller
    {
      //
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So because we’re going to be interacting with the API In this Controller what we need to do is to add a little code snippet above. The code snippet we’ll add above is the code, that will allow us to use the &lt;code&gt;Http&lt;/code&gt; class from the &lt;code&gt;Illuminate\Support\Facades&lt;/code&gt; namespace in your code.&lt;br&gt;
Below is the code snippet to place above, before your class controller name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    use Illuminate\Support\Facades\Http;

So far here’s how your code will look like

    &amp;lt;?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Http;
    class ConsumeController extends Controller
    {
      //
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Secondly, you’ll create a function that will house all the API interactions. In this case, we will use the &lt;code&gt;**index**&lt;/code&gt; naming convention for the naming of our process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Http;
    class ConsumeController extends Controller
    {
      public function index(){
         //   
      }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the next thing to do is to get the API and API Keys and store them in a variable.&lt;br&gt;
The name of our variable is &lt;code&gt;**$apiKey**&lt;/code&gt; and &lt;code&gt;**$apiUrl**&lt;/code&gt; Below is how to store the API in a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $apiKey = 'test_tf5WlMc5yVwKWk6dsQoeS4Qmz9mCkk8rZVnzCjjZ';
    $apiUrl = 'https://api.nettoolkit.com/v1/account/test-api-keys';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main purpose of storing your API in a variable is so you’ll be able to call the severally.&lt;br&gt;
We’re going to get the HTTP of the API, what this does is that it enables you to link to the specified API and apiKey from your laravel project.&lt;br&gt;
Below is an example of what I explained not too long ago!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $response = Http::get($apiUrl, [
        'api_key' =&amp;gt; $apiKey,
        // Add other parameters as needed
    ]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We saved the &lt;code&gt;**HTTP**&lt;/code&gt; class in a variable called &lt;code&gt;**$reponse**&lt;/code&gt; so we want to get the variable where our API is stored. &lt;br&gt;
After getting it, we’ll do something like this!&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$data = $reponse-&amp;gt;json();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This implies Structured data from an HTTP &lt;code&gt;**$response**&lt;/code&gt; is assigned to the variable &lt;code&gt;**$data**&lt;/code&gt; in this code, and the JSON format is translated and processed into a useful object or array for further manipulation and processing.&lt;br&gt;
Then we redirect to where we want the API to display, in our case the *&lt;em&gt;**`&lt;/em&gt;&lt;em&gt;view/consume.blade.php&lt;/em&gt;&lt;em&gt;&lt;code&gt; to redirect to this page by using the return &lt;/code&gt;&lt;/em&gt;&lt;em&gt;keyword&lt;/em&gt;*` below is an example.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return view('consume', ['data' =&amp;gt; $data]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;All that we’ve discussed in this section is just the entire controller, Decided to break it bit by bit.&lt;br&gt;
Below is the code snippet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Http;
    class ContentController extends Controller
    {
        public function index() {
            $apiKey = 'test_tf5WlMc5yVwKWk6dsQoeS4Qmz9mCkk8rZVnzCjjZ';
            $apiUrl = 'https://api.nettoolkit.com/v1/account/test-api-keys';
            $response = Http::get($apiUrl, [
                'api_key' =&amp;gt; $apiKey,
                // Add other parameters as needed
            ]);
            $data = $response-&amp;gt;json();
            return view('consume', ['data' =&amp;gt; $data]);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running this code, you’ll go to the view and look for the &lt;code&gt;**consume.blade.php**&lt;/code&gt; inside it add the code snippet below to be able to view something in your browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;h1&amp;gt;API Data:&amp;lt;/h1&amp;gt;
    &amp;lt;pre&amp;gt;
        {{ json_encode($data, JSON_PRETTY_PRINT) }}
    &amp;lt;/pre&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After accomplishing the above task, refresh the page you’ll see the below content right on your screen.&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%2Fpaper-attachments.dropboxusercontent.com%2Fs_37C0A1F6915E270C437EEEAE51C10709AD03F81CE12281BDF2FD23B99D1434ED_1692112675691_Screenshot%2B20.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%2Fpaper-attachments.dropboxusercontent.com%2Fs_37C0A1F6915E270C437EEEAE51C10709AD03F81CE12281BDF2FD23B99D1434ED_1692112675691_Screenshot%2B20.png" alt="The Output of The API From ConsumeController"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We’ll talk more about API’s seat tight.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is Laravel API?&lt;/strong&gt;&lt;br&gt;
when we speak approximately &lt;code&gt;Laravel API,&lt;/code&gt; we talk roughly about the API (software Programming Interface) improvement gear that the Laravel framework gives. a set of routes and strategies that permit interaction among outside programs and Laravel software is referred to as an API inside the context of Laravel.&lt;br&gt;
&lt;strong&gt;What is RESTFUL API?&lt;/strong&gt;&lt;br&gt;
The architectural layout method called a RESTful API (Representational state switch API) is used to create networked programs. it's a method for creating web offerings that follow particular suggestions and boundaries resulting in web offerings that might be scalable, stateless, and simple to apply. Assets, which are things or entities the API can access, are the foundation of RESTful APIs.&lt;br&gt;
RESTful APIs are popular because they are smooth to apply, scalable, and adaptable to many clients. They now function as the de facto enterprise general for creating net offerings, making an allowance for compatibility throughout diverse systems and operating systems.&lt;br&gt;
&lt;strong&gt;What's the difference between JSON and XML?&lt;/strong&gt;&lt;br&gt;
even though XML and JSON are both commonly used facts transfer codecs, they range in phrases of syntax and functionality. JSON is a JavaScript item notation XML is an eXtensible Markup Language. &lt;br&gt;
be aware: there are masses of variations, however, we’ll say few of them.&lt;br&gt;
Subsequent are the principle variations between JSON and XML:**&lt;br&gt;
&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;clarity:&lt;/strong&gt; JSON has a clean and recognizable shape just like JavaScript items, so it tends to be less complicated for human beings to recognize. due to its tag-based structure, XML can be more verbose and complex once in a while, making it tougher to read.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;statistics types:** handiest a small wide variety of statistics kinds, which include strings, numbers, booleans, arrays, objects, and null values, are supported through JSON. By way of default, XML translates all information as text and necessitates explicit type definitions.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Finally, We have come to the end of this Tutorial. Hope you were able to grab tons of value from it. Briefly, we have seen how to set up our laravel project and interact with API. &lt;br&gt;
Note! Laravel provides a powerful framework for creating and interacting with APIs, offering developers a seamless and efficient way to build robust web applications.&lt;br&gt;
With its comprehensive set of features and intuitive syntax, Laravel simplifies the process of designing, implementing, and managing APIs. Using Laravel, developers can effortlessly create API routes, define controllers, and handle HTTP requests and responses.&lt;br&gt;
The framework's built-in authentication and authorization mechanisms ensure secure access to API endpoints, granting developers fine-grained control over user permissions.&lt;br&gt;
Till next time, bye.&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; has &lt;code&gt;2+&lt;/code&gt; years of experience in software development. He has developed full-fledged skills by combining software development, writing, and instructing others in what he does.&lt;br&gt;
His stacks include &lt;code&gt;ReactJ&lt;/code&gt;, &lt;code&gt;Laravel&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;, and other languages and frameworks.&lt;br&gt;
He creates websites for clients as a freelancer and writes technical guides to show people how to do what he does.&lt;br&gt;
If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please go to and follow him on his &lt;strong&gt;&lt;a href="%%20embed%20https://emmykolic.github.io%"&gt;website&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="%%20embed%20https://facebook.com/Emmykolic/%"&gt;Facebook&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="%%20embed%20https://github.com/emmykolic%"&gt;Github&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="%%20embed%20https://www.linkedin.com/in/emmanuel-okolie-435588238/%"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;a href="%%20embed%20https://www.twitter.com/emmykolic%"&gt;Twitter&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>programming</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Cookies-Based Authentication Vs Session-Based Authentication</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Fri, 17 Mar 2023 21:48:43 +0000</pubDate>
      <link>https://dev.to/emmykolic/cookies-based-authentication-vs-session-based-authentication-1f6</link>
      <guid>https://dev.to/emmykolic/cookies-based-authentication-vs-session-based-authentication-1f6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If There’s one thing I would like to know previously, it is the entire way Authentication works, session authentication and cookie authentication are both types of token-based authentication. So we will be talking about Cookie-Based and Session-Based Authentication. As a developer, there will come a time when you will see the need of using authentication in your web application.&lt;/p&gt;

&lt;p&gt;What images do you have in mind when you hear the terms sessions and cookies? Cookies are kept on the client directly (Browser). Whereas sessions make use of a cookie as a kind of key to link with the information kept on the server side. Because the actual values are concealed from the client and the developer has control over when the data expires, sessions are preferred by the majority of developers.&lt;/p&gt;

&lt;p&gt;Without wasting your time let’s jump straight into this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Authentication
&lt;/h2&gt;

&lt;p&gt;Verifying a user or entity's identity to access a system, network, or application is known as authentication. It entails confirming that the user's or an entity's identity credentials, such as a username and password, a security token, biometric information, or a digital certificate, are accurate.&lt;/p&gt;

&lt;p&gt;To ensure that only authorized parties or individuals are given access to sensitive data and resources, authentication is a crucial component of security. To offer a secure and dependable access control system, it is frequently used in conjunction with other security measures including authorization, encryption, and multi-factor authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Session Authentication
&lt;/h2&gt;

&lt;p&gt;When a user logs into an application or website, session authentication, a sort of token-based authentication, creates a special session ID for them. The server-side storage of this session ID is used to verify user requests made after that point.&lt;/p&gt;

&lt;p&gt;The server generates a fresh session ID and links it to the user's account each time they log in. The user's browser then receives this session ID as a cookie, which is saved on the user's device. With each successive request, the user's browser subsequently sends the session ID back to the server, enabling it to confirm the user's identity and grant access to secured resources.&lt;/p&gt;

&lt;p&gt;Web apps and websites frequently utilize session authentication to provide users access to their accounts without requiring them to enter their passwords again each time they change pages or do other actions. It frequently works in tandem with other security measures like multi-factor authentication and encryption to offer a strong and dependable access control solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pron Of Session-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Session-based authentication has advantages, below are the advantages while using Session-Based authentication.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Security: By asking the user to enter login information for each session, session-based authentication aids in preventing unwanted access to a user's account. As a result, it becomes more challenging for attackers to access a user's account because they would need to be aware of the login information for each session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User Experience: Since a user only needs to log in once and their session is kept active for a while, session-based authentication can make using the system easier (e.g. 30 minutes or an hour). This indicates that the user can go between pages of the website or application without repeatedly entering their login information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: As the server just needs to keep track of active sessions rather than keeping login information for each user, session-based authentication can be readily scaled up to handle huge numbers of users.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cons Of Session-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Session-Based Authentication's drawbacks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;One of the largest threats to session-based authentication is session hijacking, in which an attacker takes control of a user's session and assumes their identity. Using safeguards like SSL encryption, secure session cookies, and session timeouts can help to mitigate this.
## &lt;/li&gt;
&lt;li&gt;Session Fixation: This potential flaw in session-based authentication occurs when a user's session ID is established by an attacker before the user logs in, giving the attacker control of the user's session after the user logs in. By creating a fresh session ID after the user logs in, this can be avoided.
## &lt;/li&gt;
&lt;li&gt;Resource Consumption: Because the server must keep track of all active sessions, session-based authentication can be very resource-intensive. This is because this procedure uses a lot of memory and processing power. By putting in place restrictions like session timeouts and a cap on the number of active sessions per user, this can be lessened.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Are Cookies Authentication
&lt;/h2&gt;

&lt;p&gt;Websites and web apps employ cookies authentication as a user authentication technique. After a person logs in to a website, little text files known as cookies are used and kept on their device.&lt;/p&gt;

&lt;p&gt;A cookie with a special identifier linked to the user's account is created by the website when a user checks in. The user's device then receives and stores this cookie in their browser. The website may recognize the user and authenticate them without them having to log in again by sending the cookie back to the website on subsequent visits.&lt;/p&gt;

&lt;p&gt;As users do not need to log in repeatedly to access their accounts, cookies authentication can be used to offer a simple and seamless user experience. To avoid jeopardizing the security of the user's account, it is crucial to make sure that the cookies used for authentication are safe and difficult to manipulate. Also, because it could not always offer enough security, cookie authentication might not be appropriate for all websites or applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pron Of Cookies-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Cookies-Based Authentication's Advantages&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Convenience: Cookies-based authentication makes it easier for users to access the website or application since they don't need to continuously enter their login information after closing their browser or powering off their device.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: Because the server only needs to keep track of each user's active sessions, cookies-based authentication may be scaled up to handle enormous numbers of users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Personalization: By collecting users' preferences and behavior on the website or app, cookies-based authentication enables websites or applications to tailor the user experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cons Of Cookies-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Negative aspects of cookies-based authentication&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Security Risks: Cross-site scripting (XSS) attacks and session hijacking are two security vulnerabilities that cookies-based authentication may be subject to. Session timeouts, SSL encryption, and the use of secure cookies are among the countermeasures that can be used to lessen this risk.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cookies-based authentication can present privacy issues because the website or application may be gathering and storing personal information about the user. By putting policies in place like making clear privacy policies and receiving explicit user agreements for data collecting, this can be lessened.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users who share devices or use public computers might not have the optimal user experience using cookies-based authentication because other users may be able to access their login information if it is kept on the device. Using safeguards like giving users the choice to log out of the session and erasing the cookies when a user signs out can help to mitigate this.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Difference Between Cookies-Based Authentication And Session-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Common methods for preserving user authentication over numerous requests in web applications include cookies-based authentication and session-based authentication.&lt;/p&gt;

&lt;p&gt;Cookies-based authentication involves putting authentication data in a cookie that is saved on the user's browser, including their login credentials. To identify the user and preserve their authorized state, the server sends this cookie along with every subsequent request the user makes to the web application.&lt;/p&gt;

&lt;p&gt;On the other hand, session-based authentication includes saving the authentication data on the server side. An exclusive session ID is generated and linked to an account when a user checks in. This session ID is then provided to the server with each subsequent request and saved on the user's browser as a cookie. The user's authentication details can then be looked up by the server using the session ID, which helps to keep the user in an authenticated state.&lt;/p&gt;

&lt;p&gt;The location of the authentication data storage is the primary distinction between cookies-based authentication and session-based authentication. Although session-based authentication stores the authentication data on the server, cookies-based authentication stores it on the user's browser.&lt;/p&gt;

&lt;p&gt;In general, cookies-based authentication is simpler to implement because the server doesn't need to keep track of any session data, which is a benefit. Cookies-based authentication is more susceptible to security threats, like cookie theft and session hijacking, though.&lt;/p&gt;

&lt;p&gt;As the authentication data is retained on the server and inaccessible to the user, session-based authentication is typically thought to be more secure. Nevertheless, because the server must manage session timeouts and expiration as well as session information, session-based authentication might be trickier to implement.&lt;/p&gt;

&lt;p&gt;In the end, the web application's demands and requirements will determine whether to use cookies-based authentication or session-based authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one should I use?
&lt;/h2&gt;

&lt;p&gt;Every developer is entitled to His/Her opinion on which authentication to use. But my advice is to use session-based authentication because it’s safer. While building your site or application, you may need to go for any of them. Below are the use cases for Session and Cookies authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case for Cookies Authentication&lt;/strong&gt;&lt;br&gt;
When a person registers to a website, cookies authentication is frequently used. The server creates a distinct session ID after verifying the user's credentials once they submit their username and password. The user's browser's cookie then contains the session ID. Each time the user makes a new request to the server, the cookie is sent along with it, enabling the server to recognize the user and deliver customized information. Because it is reasonably simple to implement and is widely supported by web browsers, cookies authentication is a popular option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case for Session Authentication&lt;/strong&gt;&lt;br&gt;
When a user interacts with a web application that necessitates repeated requests to complete a job, session authentication is frequently used. To place an order on an e-commerce website, for instance, a user may need to add items to their cart, enter shipping details, and enter payment information. The server constructs a session object linked to the user's login credentials to preserve the state of the order across multiple requests. An individual session ID is delivered in a cookie to the user's browser along with this session object, which is saved on the server. The server can obtain the session object and keep track of the order's status because each future request from the user includes the session ID. To enable safe, stateful interactions between the user and the web application, session authentication is frequently combined with cookie authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Cookies-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Authentication Using Cookies: Best Practices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;With the HttpOnly and Secure flags set, use secure cookies.&lt;/li&gt;
&lt;li&gt;Consider the sensitivity of the data and the user's behavior when setting the cookie expiration time.&lt;/li&gt;
&lt;li&gt;To prevent tampering, encrypt the cookie contents using powerful encryption methods.&lt;/li&gt;
&lt;li&gt;To stop replay attacks, give each cookie a special identification number.&lt;/li&gt;
&lt;li&gt;In stateless apps or other situations where cookies are inappropriate, take into account utilizing a token-based strategy as an alternative to cookies for authentication.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Best Practices for Session-Based Authentication
&lt;/h2&gt;

&lt;p&gt;Session-based authentication best practices&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use a private, random session identification and save it on the server.&lt;/li&gt;
&lt;li&gt;To lessen the chance of a session being hijacked, limit the session's lifespan.&lt;/li&gt;
&lt;li&gt;Use secure session archiving techniques, such as an encrypted file or database system.&lt;/li&gt;
&lt;li&gt;To protect the session data while it is in transit, use SSL/TLS encryption.&lt;/li&gt;
&lt;li&gt;When logging out or after a predetermined amount of inactivity, invalidate the session.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In both situations, it is crucial to routinely evaluate and audit the authentication procedures to spot and fix any potential security flaws. Users must also be instructed about best practices, such as not disclosing their login information to others and staying away from public computers when conducting sensitive business.&lt;/p&gt;

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

&lt;p&gt;Finally, we’re done with this guide, hope you’ve gained a ton of value! Going through this guide entirely you will learn the basics of Cookies and Sessions authentication, and learn more about authentication itself.&lt;/p&gt;

&lt;p&gt;We also saw a lot of differences between them, you’ll bet me that going through this guide was a waste. Feel free to drop a comment in the comment section, like this guide, and follow me for More.&lt;/p&gt;

&lt;p&gt;Thanks, till next time!!!&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;Full-stack Laravel developer &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; has &lt;code&gt;2+&lt;/code&gt; years of experience working in the software development sector. By combining software development, writing, and instructing others in what he does, he has developed full-fledged skills. &lt;br&gt;
His stacks include &lt;code&gt;ReactJs&lt;/code&gt;, &lt;code&gt;Laravel&lt;/code&gt;, &lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;, and other languages and frameworks.&lt;/p&gt;

&lt;p&gt;He creates websites for clients as a freelancer and writes technical guides to show people how to do his work.&lt;/p&gt;

&lt;p&gt;If given the chance, &lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would enjoy speaking with you. Please go to and follow him on his &lt;a href="https://emmykolic.github.io"&gt;&lt;strong&gt;website&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://facebook.com/Emmykolic/"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://twitter.com/emmykolic"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/"&gt;&lt;strong&gt;LinkedIn&lt;/strong&gt;&lt;/a&gt;, and &lt;a href="https://www.twitter.com/emmykolic"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>authentication</category>
      <category>php</category>
      <category>webdev</category>
      <category>backend</category>
    </item>
    <item>
      <title>How To Build Random Quotes Project Using Vanilla JavaScript</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Thu, 23 Feb 2023 22:52:51 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-build-random-quotes-project-using-vanilla-javascript-5278</link>
      <guid>https://dev.to/emmykolic/how-to-build-random-quotes-project-using-vanilla-javascript-5278</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;What comes to your mind when you hear the word random quote using vanilla JavaScript? As far as I'm concerned, anything may be the case. And there may be another scripting language that can make random quotes, but one of the most distinguished of them is using JavaScript to make a random quote. &lt;/p&gt;

&lt;p&gt;You might have seen some social media apps that display people’s posts, but you must keep scrolling to see more posts. But according to what we will be building, you will have to click on a button to view a new quote.&lt;/p&gt;

&lt;p&gt;Note: in this tutorial we will make use of an API, the API is used to fetch the quotes randomly acrross the web. By just clicking on the button the API fetches a new quotes.   &lt;/p&gt;

&lt;p&gt;So without wasting much of your time, let's dive into this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; You need to have basic knowledge of HTML&lt;/li&gt;
&lt;li&gt;You need to have basic knowledge of CSS&lt;/li&gt;
&lt;li&gt;You need to have basic knowledge of JavaScript&lt;/li&gt;
&lt;li&gt;Also have a code editor(Sublime or VS code) etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step-by-step JavaScript Random Quote Generator&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A random quote pulls quotes randomly from an API or an array. In this article, we'll use JavaScript to produce quotes from an array as we design a random quote generator from scratch using HTML, CSS, and JavaScript only.&lt;/p&gt;

&lt;p&gt;Below is a step-by-step guide to going through to accomplish the random quote task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Is Making a New Project&lt;/strong&gt; &lt;br&gt;
The project you’re about to build contains three pages: HTML, CSS, and JavaScript. so you’ll name the various pages will be named like this. index.html, style.css, script.js. After doing this you’re ready to move on to the next step. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Constructing the framework&lt;/strong&gt;&lt;br&gt;
This step will enable you to add a few HTML codes that will give your project structure. &lt;br&gt;
Note: This section is probably the first thing to do after creating the folder and the files as stated above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset="utf-8"&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;!--META information--&amp;gt;
   &amp;lt;meta name="description" content="Random Quote Generator"&amp;gt;
   &amp;lt;meta name="keywords" content="HTML,CSS,JavaScript, Quotes, API"&amp;gt;
   &amp;lt;meta name="author" content="EmmyKolic"&amp;gt;
   &amp;lt;!--End of META information--&amp;gt;
   &amp;lt;title&amp;gt;Random Quotes&amp;lt;/title&amp;gt;
   &amp;lt;!--LINK CUSTOM CSS FILE--&amp;gt;
   &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
   &amp;lt;!--FONTAWESOME CDN--&amp;gt;
   &amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="crossorigin="anonymous"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;!-- Quote Container --&amp;gt;
    &amp;lt;div class="container"&amp;gt;
      &amp;lt;!-- Quote to be Displayed Here --&amp;gt;
      &amp;lt;h1&amp;gt;
        &amp;lt;i class="fas fa-quote-left"&amp;gt;&amp;lt;/i&amp;gt;
        &amp;lt;span class="quote" id="quote"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;i class="fas fa-quote-right"&amp;gt;&amp;lt;/i&amp;gt;
      &amp;lt;/h1&amp;gt;
      &amp;lt;!-- Author to be Displayed Here --&amp;gt;
      &amp;lt;p class="author" id="author"&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;hr /&amp;gt;
      &amp;lt;div class="button"&amp;gt;
        &amp;lt;!--Button to tweet the quote --&amp;gt;
        &amp;lt;a class="twitter" id="tweet" href="https://twitter.com/intent/tweet?text=Greetings" data-size="large" target="_blank" rel="noopener noreferrer"&amp;gt;&amp;lt;i class="fab fa-twitter"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;

        &amp;lt;!--Add an onclick event on 'next quote' button. Upon the click of a button, a new random quote is generated--&amp;gt;
        &amp;lt;button class="next" onclick="getNewQuote()"&amp;gt;Next quote&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!--LINK CUSTOM JS FILE--&amp;gt;
    &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Adding Styles for the Classes&lt;/strong&gt;&lt;br&gt;
In this section, we will be adding styles to the code using CSS, to build the quote generator. Note: This section is the next thing to do after creating the index.html file, you will create another file named style.css the style.css file will be linked to the HTML file. &lt;/p&gt;

&lt;p&gt;Then you to style the layout of the HTML. Here’s the CSS code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  transition: 0.5s;
  transition-timing-function: ease-in;
  background-image: linear-gradient(
    to right bottom,
    rgb( 51, 255, 141 ),
    #acc9ffa8
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  box-shadow: 0 4px 10px rgba(27, 245, 235 , 0.5);
  border-radius: 15px;
  width: 600px;
  background-color: rgba(255, 255, 255, 0.3);
  margin: 10px;
}
.fa-quote-left,
.fa-quote-right {
  font-size: 35px;
  color: rgb(170, 0, 0);
}
.quote {
  text-align: center;
  font-size: 40px;
  font-weight: bold;
}
.author {
  margin: 10px;
  text-align: right;
  font-size: 25px;
  font-style: italic;
  font-family: cursive;
}
hr {
  margin: 10px 0;
  width: 100%;
  border: 1px solid black;
  background-color: black;
}
.button {
  width: 100%;
  display: flex;
  padding: 10px;
  justify-content: space-between;
  align-items: center;
  margin: 9px;
}
.twitter {
  border: 1px solid rgb(102, 179, 255);
  border-radius: 4px;
  background-color: rgb(102, 179, 255);
  color: white;
  padding-bottom: 15px;
  text-align: center;
  font-size: 1.8em;
  width: 60px;
  height: 35px;
  line-height: 40px;
}
.next {
  font-size: 18px;
  border-radius: 5px;
  cursor: pointer;
  padding: 10px;
  margin-top: 5px;
  font-weight: bold;
  color: white;
  background-image: linear-gradient(
    to right bottom,
    rgb(22, 210, 248),
    #bcd7ffa8
  );
}
.container:hover {
  box-shadow: 0 10px 10px rgb(0, 180, 230);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Incorporate a few lines of JavaScript code.&lt;/strong&gt;&lt;br&gt;
In this step, we will incorporate some JavaScript code to build the quote generator. Note: This section is an essential part of this tutorial, Now you’ll create another file call it script.js.&lt;br&gt;
Go through the code below you’ll see what was done clearly, We interacted with an API by using a link and saving inside a variable named url. &lt;/p&gt;

&lt;p&gt;To make this guide brief, go through the script.js you’ll notice a comment before each section. Here’s the JavaScript code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const text = document.getElementById("quote");
const author = document.getElementById("author");
const tweetButton = document.getElementById("tweet");

const getNewQuote = async () =&amp;gt; {
  //api for quotes
  var url = "https://type.fit/api/quotes";

  // fetch the data from api
  const response = await fetch(url);
  console.log(typeof response);
  //convert response to json and store it in quotes array
  const allQuotes = await response.json();

  // Generates a random number between 0 and the length of the quotes array
  const indx = Math.floor(Math.random() * allQuotes.length);

  //Store the quote present at the randomly generated index
  const quote = allQuotes[indx].text;

  //Store the author of the respective quote
  const auth = allQuotes[indx].author;

  if (auth == null) {
    author = "Anonymous";
  }

  //function to dynamically display the quote and the author
  text.innerHTML = quote;
  author.innerHTML = "~ " + auth;

  //tweet the quote
  tweetButton.href =
    "https://twitter.com/intent/tweet?text=" + quote + " ~ " + auth;
};

getNewQuote();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;We’ve come to the end of this tutorial, hopefully, you’ve gained a ton of value. On how to build random quotes project using vanilla JavaScript.&lt;/p&gt;

&lt;p&gt;We’ve seen how to interact with an API, although that's not the only way or should I say best way to interact with an API. and how to tweet a quote from our JS code to your Twitter account.&lt;/p&gt;

&lt;p&gt;Just discussing this tutorial has shown us a lot. So feel free to drop a comment! And if you want more &lt;a href="https://dev.to/emmykolic"&gt;&lt;strong&gt;tutorials&lt;/strong&gt;&lt;/a&gt;, please follow me.&lt;/p&gt;

&lt;p&gt;Till next time, Enjoy your day!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;About The Author&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; is a full-stack laravel developer with &lt;code&gt;2+&lt;/code&gt; years of experience in the software development industry. He has built full-fledged skills by fusing software development, writing, and teaching others what he does. His stacks are &lt;code&gt;ReactJs,&lt;/code&gt; &lt;code&gt;Laravel,&lt;/code&gt; &lt;code&gt;PHP,&lt;/code&gt; &lt;code&gt;JavaScript,&lt;/code&gt; and more.&lt;/p&gt;

&lt;p&gt;He works as a freelancer, building websites for clients and writing technical manuals to instruct others on how to carry out his work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; would welcome the opportunity to speak with you. Kindly visit and follow him on &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/"&gt;&lt;strong&gt;Linked-In&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://facebook.com/Emmykolic/"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://twitter.com/emmykolic"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://www.twitter.com/emmykolic"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; or his &lt;a href="https://emmykolic.github.io"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Use Mod_Rewrite To Remove Your (.PHP) Extension From Your Work</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Tue, 07 Feb 2023 20:20:31 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-use-modrewrite-to-remove-your-php-extension-from-your-work-nfc</link>
      <guid>https://dev.to/emmykolic/how-to-use-modrewrite-to-remove-your-php-extension-from-your-work-nfc</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;There was a time I wanted to remove my (.PHP) extension from my project URL it became an extreme challenge for me, and I was bored cause I wished my .php not to show, then I stumbled into mod_rewrite. Ever since then, I have appreciated mod_rewrite functionality. &lt;/p&gt;

&lt;p&gt;How I was able to achieve remove my extension in my project was the use of my .htaccess. this tutorial will explain everything you should know about removing the php extension. &lt;/p&gt;

&lt;p&gt;Before then, if you have no idea about php mod_rewrite I’ll advise you to read my tutorial titled: &lt;a href="https://dev.to/emmykolic/what-you-should-know-about-php-modrewrite-and-modsecurity-2154"&gt;&lt;strong&gt;What You Should Know About PHP Mod_Rewrite And Mod_Security.&lt;/strong&gt;&lt;/a&gt; it will help you have an idea about Mod rewrite, and having this idea will make this tutorial more understandable for you.&lt;/p&gt;

&lt;p&gt;Now, without wasting much of your time, let’s jump right into this guide!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a .htaccess
&lt;/h2&gt;

&lt;p&gt;the .htaccess is a file used for configuration by the apache web server to control the behavior of the websites. It is frequently used to handle error pages, redirect online traffic, enforce security regulations, limit access to a website, and carry out other website-related duties. &lt;/p&gt;

&lt;p&gt;Note: the root directory of a website is where the .htaccess file is stored and it’s typically hidden from view. The .htaccess file can be edited with a text editor and all the changes will take effect immediately, which makes the file a flexible and powerful tool for web administrators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features Of The .htacess File
&lt;/h2&gt;

&lt;p&gt;Below are the things the .htaccess file enables you to do&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL Redirection:&lt;/strong&gt; Users can be redirected from an outdated URL to a new URL using the .htaccess file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Password Protection:&lt;/strong&gt; A website, directory, or particular file can be password-protected using the .htaccess file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Restricting Access to Specific Files and Directories:&lt;/strong&gt; The .htaccess file may be used to limit access to specific files or directories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom Error Pages:&lt;/strong&gt; You may make custom error pages for HTTP error codes like 404 (Not Found) and 500 using the .htaccess file (Internal Server Error).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rewrite Rules:&lt;/strong&gt; To make URLs more user- or SEO-friendly, rewrite them using the .htaccess file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MIME Types:&lt;/strong&gt; You may define the MIME type of a file in the .htaccess file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevent Hotlinking:&lt;/strong&gt; You may stop other websites from creating hotlinks to your photos and other media assets by using the .htaccess file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Activate Compression:&lt;/strong&gt; The .htaccess file may be used to activate GZIP compression, which can accelerate a website's loading time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compel HTTPS:&lt;/strong&gt; The .htaccess file may be used to force HTTPS encryption for all traffic to a website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block Spam Bots:&lt;/strong&gt; To stop spam bots from visiting a website, the .htaccess file may be used to block particular IP addresses or user agents.&lt;/p&gt;

&lt;p&gt;In this tutorial, we’ll be focusing only on &lt;strong&gt;rewriting URLs&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Removing The .php Extension
&lt;/h2&gt;

&lt;p&gt;You must first enable mod rewrite on the Apache web server before moving on. The procedures to activate mod_rewrite (.htaccess) on the Apache web server are listed below first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Open htaccess File&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the following command in a terminal window to view the .htaccess file. Please modify the file path of the .htaccess file according to your needs.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano /var/www/html/.htaccess
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Eliminating the.php Extension from the URL&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To remove the .php extension from the URL of your website, you can use the following code in your .htaccess file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With the help of this code, the Apache web server will be instructed to drop the .php extension from the URL while still serving the proper .php file. For instance, the Apache web server will deliver the file page.php without displaying the.php suffix in the URL if a user attempts to visit the URL &lt;code&gt;http://example.com/page.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; Before making changes, always create a backup of your .htaccess file. Your website may malfunction or become unavailable if you make incorrect modifications to the .htaccess file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Restart the Apache web server&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Apache server may be restarted using the following command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl restart httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or you can do the restarting on your xampp as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a trailing slash at the end
&lt;/h2&gt;

&lt;p&gt;Many people asked me how to add a trailing slash at the end, for instance: &lt;code&gt;yoursite.com/page/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Put the code below in and disregard the first snippet. The removal of the extension is addressed in the first four lines, and the insertion of the trailing slash and redirection is addressed in the remaining lines.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Server-side redirects:&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apache:&lt;/strong&gt; You can use the &lt;code&gt;.htaccess&lt;/code&gt; file to add a rewrite rule to redirect the URL. Here is an example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nginx:&lt;/strong&gt; You can use the following configuration in your &lt;code&gt;nginx.conf&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    location / {
        if (!-e $request_filename){
            rewrite ^(.*)$ /$1/ permanent;
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Redirects that happen on the client side:&lt;/strong&gt; You can use JavaScript to change the URL in the browser. Here's an illustration:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (location.pathname.substr(-1) !== '/') {
        location.pathname = location.pathname + '/' + location.search + location.hash;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Depending on your unique use case and configuration, you should apply the approaches stated above.&lt;/p&gt;

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

&lt;p&gt;We’ve come to the end of this tutorial, hopefully, you’ve been enlightened on How to use mod_rewrite to remove your (.php) extension from your URL.&lt;/p&gt;

&lt;p&gt;We’ve learned how to remove the extensions using mod_rewrite in the .htaccess file. And how to add a trailing slash and lots more.&lt;/p&gt;

&lt;p&gt;We’ve seen a lot by just talking about this tutorial. So feel free to drop a comment! And if you want more &lt;a href="https://dev.to/emmykolic"&gt;&lt;strong&gt;instructions&lt;/strong&gt;&lt;/a&gt;, please follow me.&lt;/p&gt;

&lt;p&gt;Till next time, have a wonderful day!&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; is a full-stack laravel developer with &lt;code&gt;2+&lt;/code&gt; years of experience in the software development industry. Combining software development, writing, and teaching others what he does, he has developed full-fledged capabilities. His stacks contain &lt;code&gt;ReactJs,&lt;/code&gt; &lt;code&gt;Laravel,&lt;/code&gt; &lt;code&gt;PHP,&lt;/code&gt; &lt;code&gt;JavaScript,&lt;/code&gt; and more.&lt;/p&gt;

&lt;p&gt;He works as a freelancer, creating websites for customers and creating technical guides to show others how to accomplish what he does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; is ready and willing to talk with you. Kindly visit and follow him on &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/"&gt;&lt;strong&gt;Linked-In&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://facebook.com/Emmykolic/"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://twitter.com/emmykolic"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://www.twitter.com/emmykolic"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; or his &lt;a href="https://emmykolic.github.io"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>coding</category>
      <category>advanced</category>
    </item>
    <item>
      <title>How To Master JavaScript DOM: Beginners Guide</title>
      <dc:creator>Emmanuel C. Okolie</dc:creator>
      <pubDate>Fri, 27 Jan 2023 12:33:52 +0000</pubDate>
      <link>https://dev.to/emmykolic/how-to-master-javascript-dom-beginners-guide-353c</link>
      <guid>https://dev.to/emmykolic/how-to-master-javascript-dom-beginners-guide-353c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;There is one functionality JavaScript has, which is the DOM. the Dom is a vital aspect of JavaScript programming that shouldn’t be neglected. As far as I’m concerned you can’t achieve much in JavaScript without knowing what the DOM is all about. JavaScript is widely growing and becoming versatile the use of the DOM becomes more Essential and strongly needed. &lt;/p&gt;

&lt;p&gt;in this tutorial, I'm going to walk you through the things you should know about the DOM. I promise you that if you stick with me until the end and practice all that I write about, the whole DOM thing won't be an issue for you ever again.&lt;/p&gt;

&lt;p&gt;Without wasting much of your time, let’s jump straight in.&lt;/p&gt;

&lt;h2&gt;
  
  
  DOM Definition and Fundamental Principles
&lt;/h2&gt;

&lt;p&gt;The DOM is an acronym which stands for Document Object Model. The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the structure of a document as a tree of objects, with each object representing a part of the document, such as an element, attribute, or text node. &lt;/p&gt;

&lt;p&gt;JavaScript can be used to interact with the DOM, allowing developers to create dynamic web pages that can update and respond to user input. The JavaScript DOM allows you to manipulate and access the elements, attributes, and content of an HTML or XML document, changing the structure, layout, and content of a web page without reloading it.&lt;/p&gt;

&lt;p&gt;the image below explains what the DOM trees look like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--852Axmyb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674597992201_javascript8_1.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--852Axmyb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674597992201_javascript8_1.webp" alt="Tree Structure of JavaScript DOM image gotten from Guru99" width="614" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The document object is shown here. This serves as the DOM's foundation and core. You must first gain access to the document object in order to carry out any kind of DOM modification.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;HTML&lt;/code&gt; root element, a subclass of the document object, comes next.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;body&lt;/code&gt;and &lt;code&gt;head&lt;/code&gt;elements, which are cousins and offspring of the &lt;code&gt;HTML&lt;/code&gt; element, are listed next.&lt;/p&gt;

&lt;p&gt;You may probably agree that the title element, which is located underneath the head element, is the parent of the text node “my text” and a child of the head element.&lt;/p&gt;

&lt;p&gt;Two components (&lt;code&gt;a&lt;/code&gt; tag and an &lt;code&gt;h1&lt;/code&gt; tag) that are siblings and offspring of the body element are located immediately underneath the body element.&lt;/p&gt;

&lt;p&gt;Last but not least, the tag's descendants include the &lt;code&gt;href&lt;/code&gt; property and the text node “my link.” The text node “My header” belongs to the &lt;code&gt;h1&lt;/code&gt; element in the same exact way.&lt;/p&gt;

&lt;p&gt;If you're just getting started, this could seem a little difficult, but it always gets easier (with the practice of course).&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Select Elements in the DOM
&lt;/h2&gt;

&lt;p&gt;You must choose that specific element in the DOM before you can make changes to it. We have four main approaches to choosing components, which is fortunate for us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Use the getElementById Method to Choose DOM Elements&lt;/strong&gt;&lt;br&gt;
Using the element's id is the most used method of accessing an HTML element.&lt;/p&gt;

&lt;p&gt;The getElementById() function in the example below utilized the parameter id="master" to locate the element.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p id="controller"&amp;gt;i'm a javascript lover&amp;lt;/p&amp;gt;

 &amp;lt;script&amp;gt;
const controllerEl = document.getElementById('controller')
console.log(controllerEl) //&amp;lt;p id="controller"&amp;gt;i'm a javascript lover&amp;lt;/p&amp;gt; 
 &amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The ID takes the case into account. For instance, the ids &lt;code&gt;"master"&lt;/code&gt; and &lt;code&gt;"Master"&lt;/code&gt; are completely different.&lt;/p&gt;

&lt;p&gt;After choosing an element, you may modify its properties, apply styles to the element, and navigate to its parent and child elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ucrrzPk0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674726519191_Screenshot%2B2023-01-25%2Bat%2B22-28-28%2BCodeSandbox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ucrrzPk0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674726519191_Screenshot%2B2023-01-25%2Bat%2B22-28-28%2BCodeSandbox.png" alt="The View of the above code snippet" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing Elements within the DOM using the getElementsByClassName() Technique.&lt;/strong&gt;&lt;br&gt;
This function returns a collection of all the document components that belong to the given class.&lt;/p&gt;

&lt;p&gt;Our HTML page below, for instance, has three components with the &lt;code&gt;class="master2&lt;/code&gt;&lt;code&gt;"&lt;/code&gt; attribute, and I chose the button with the id of &lt;code&gt;btn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you click the button, all the elements with the class name &lt;code&gt;master2&lt;/code&gt; are selected, and the innerHTML of the third element is changed.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;p class="master2"&amp;gt;i'm a javascript lover&amp;lt;/p&amp;gt;
      &amp;lt;p class="master2"&amp;gt;i love react too well&amp;lt;/p&amp;gt;
      &amp;lt;h1 class="master2"&amp;gt;i want a remote job&amp;lt;/h1&amp;gt;

        &amp;lt;button id="btn"&amp;gt;click me&amp;lt;/button&amp;gt;

 &amp;lt;script&amp;gt;

 const btn = document.getElementById('btn')

        btn.addEventListener('click', function master(){
            var master = document.getElementsByClassName("master2");
            master[2].innerHTML = 'i need a remote job';
        })

&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;You see the following before the button is clicked:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fIGWaTOE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674727455253_Screenshot%2B2023-01-25%2Bat%2B22-30-51%2BCodeSandbox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fIGWaTOE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674727455253_Screenshot%2B2023-01-25%2Bat%2B22-30-51%2BCodeSandbox.png" alt="Before you click the button The above interface is what you will see." width="733" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking the button results in the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xUtZndGS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674727595530_Screenshot%2B2023-01-26%2Bat%2B10-53-58%2BCodeSandbox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xUtZndGS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674727595530_Screenshot%2B2023-01-26%2Bat%2B10-53-58%2BCodeSandbox.png" alt="Then here’s the interface you will see after you’ve clicked the button" width="721" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing DOM elements using the getElementsByTagName() method&lt;/strong&gt;&lt;br&gt;
This function takes a tag name as an input and returns every element of the given tag name in the order in which they occur in the document.&lt;/p&gt;

&lt;p&gt;The following code retrieves all of the &lt;code&gt;p&lt;/code&gt; elements on the page and modifies the content of the second element to demonstrate the syntax of the &lt;code&gt;getElementsByTagName()&lt;/code&gt; function.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;GitHub&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;Firebase&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;HTML&amp;lt;/p&amp;gt;
&amp;lt;button id="btn"&amp;gt;click me&amp;lt;/button&amp;gt;

  const btn = document.getElementById("btn");
btn.addEventListener("click", function master() {
  let master = document.getElementsByTagName("p");
  let masterEl = (master[1].innerHTML = "Code editors");
  console.log(masterEl); //Code editors
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;How to Use CSS Selectors to Choose DOM Elements&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;. querySelector()&lt;/strong&gt;&lt;br&gt;
This gives back the first value that matches the specified selection. By accepting all CSS style selectors, this approach enables selection by tag, class, or ID.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id=master&amp;gt;i am a frontend developer&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
const master = document.querySelector("#master") 
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The first element that matches the CSS selector is returned by the method above, which only accepts one input, a selection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.querySelectorAll()&lt;/strong&gt;&lt;br&gt;
Similar to the previous method, this one also provides a node list collection of all matched items.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     &amp;lt;p class="director"&amp;gt;Coffee Script&amp;lt;/p&amp;gt;
     &amp;lt;p class="director"&amp;gt;Typescript&amp;lt;/p&amp;gt;
     &amp;lt;p class="director"&amp;gt;Next.js&amp;lt;/p&amp;gt;

&amp;lt;script&amp;gt;
const director = document.querySelectorAll(".director") 
console.log(director[1])  //&amp;lt;p class="master"&amp;gt;Typescript&amp;lt;/p&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Overview of How to Choose DOM Elements&lt;/strong&gt;&lt;br&gt;
There are four alternative approaches to doing a certain task (selecting an element or elements) when you need to select a DOM element.&lt;/p&gt;

&lt;p&gt;So you use the second if you can't recall the first. And you still have alternatives 3 and 4 if you somehow forget both. Does JavaScript really make our life simpler, or is that just me?&lt;/p&gt;

&lt;p&gt;Personally, I advise sticking with Option 1 or Option 4a (querySelector with an Id). When you first started learning HTML, you probably realized that elements shouldn't have the same id; an element's id is a unique identifier within a page.&lt;/p&gt;

&lt;p&gt;In light of this, choosing an element based on its id is a "safe bet" as you can't apply the same "modification" to several items at once (unless perhaps that's what you want to do in which case feel free to utilize other possibilities).&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Around the Document
&lt;/h2&gt;

&lt;p&gt;Hopefully, at this point, you've realized that every node in an HTML document is a node. Additionally, text nodes are what makeup HTML components' text.&lt;/p&gt;

&lt;p&gt;With the HTML DOM, you may access nodes in the tree using the node relationships we discussed previously (parent, child(ren), sibling(s), etc.) and browse the node tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A little review&lt;/strong&gt;&lt;br&gt;
Except for the top node, each node has exactly one parent (which has no parent).&lt;br&gt;
More than one kid can be born to a node.&lt;br&gt;
Brothers and sisters are nodes that share the same parent.&lt;/p&gt;

&lt;p&gt;This section will demonstrate how to obtain an element's parent element, siblings, and offspring. To accomplish these goals, I'll be using the following node properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;parent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node youngsters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;firstElementChild last Nodes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;next ElementChild&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;prior ElementSibling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ElementSibling&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Furthermore, I'll simply utilize the HTML page below to demonstrate how to use each of these node features. I'll also demonstrate how to alter the DOM using the information from part 4 above.&lt;/p&gt;

&lt;p&gt;This article's goal is to teach the reader how to alter the DOM. If you don't know how to control the DOM, it doesn't really matter if you can pick elements and navigate them. Understanding how to add CSS style, make and add elements, set innerHTML, and manage events is crucial.&lt;/p&gt;

&lt;p&gt;Please stick with me because it is the article's main point. Let's go on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ```&amp;lt;div id="parent"&amp;gt;
        &amp;lt;div id="firstchild"&amp;gt;i am a first child&amp;lt;/div&amp;gt;
        &amp;lt;p id="secondchild"&amp;gt;i am the second child&amp;lt;/p&amp;gt;
        &amp;lt;h4&amp;gt;i am alive&amp;lt;/h4&amp;gt;
        &amp;lt;h1&amp;gt;hello world&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;i am the last child&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

    const parent = document.getElementById('parent').lastElementChild
    console.log(parent) //&amp;lt;p&amp;gt;i am the last child&amp;lt;/p&amp;gt;

    const parent2 = document.getElementById('parent').children[3]
    console.log(parent2) //&amp;lt;h1&amp;gt;hello world&amp;lt;/h1&amp;gt;

    const secondchild = document.getElementById('secondchild')
    console.log(secondchild) //&amp;lt;p id="secondchild"&amp;gt;i am the second child&amp;lt;/p&amp;gt;

    console.log(secondchild.parentNode) //&amp;lt;div id="parent"&amp;gt;...&amp;lt;/div&amp;gt;

    console.log(secondchild.nextElementSibling) //&amp;lt;h4&amp;gt;i am alive&amp;lt;/h4&amp;gt;

    console.log(secondchild.previousElementSibling) //&amp;lt;div id="firstchild"&amp;gt;i am a first child&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  How to Manipulate Elements in the DOM
&lt;/h2&gt;

&lt;p&gt;We will examine the following in this section:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ways to make components&lt;/li&gt;
&lt;li&gt;How to modify an element's innerHTML/text content&lt;/li&gt;
&lt;li&gt;How to add a component&lt;/li&gt;
&lt;li&gt;Putting one element before another: How to do it&lt;/li&gt;
&lt;li&gt;Replace a child element with this&lt;/li&gt;
&lt;li&gt;Getting rid of a child element&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;div id="parent"&amp;gt;
            &amp;lt;div id="firstchild"&amp;gt;i am a first child&amp;lt;/div&amp;gt;
            &amp;lt;p id="secondchild"&amp;gt;i am the second child&amp;lt;/p&amp;gt;
            &amp;lt;h4&amp;gt;i am alive&amp;lt;/h4&amp;gt;
            &amp;lt;h1&amp;gt;hello world&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;i am the last child&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;  

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to Create Elements&lt;/strong&gt;&lt;br&gt;
A parent element and five children elements are displayed in the code above. Let's imagine that we wish to use JavaScript to create another div tag. We would undoubtedly need to use the createElement() function to create a new element, like in:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const createEl = document.createElement('div')
 console.log(createEl) //&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to Set innerHTML&lt;/strong&gt;&lt;br&gt;
Despite the fact that we successfully built a div element, it does not yet have a text node. To add its text node, we'll utilize the &lt;code&gt;.innerHTML()&lt;/code&gt;  attribute.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const innerhtml = createEl.innerHTML = 'i am a frontend developer'
console.log(createEl) //&amp;lt;div&amp;gt;i am a frontend developer&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  How to Add Styling with CSS
&lt;/h2&gt;

&lt;p&gt;We learned how to build an element and add it to the designated parent element from the examples before.&lt;/p&gt;

&lt;p&gt;Therefore, we must add a CSS class to an element in order for it to have a style. In this instance, JavaScript will be used.&lt;/p&gt;

&lt;p&gt;I'll demonstrate more than just how to add a class. I'll also demonstrate how to delete a class and switch between classes.&lt;/p&gt;

&lt;p&gt;Relax; it's not tough. Every step of the way, I'm here to help you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Add a CSS Class&lt;/strong&gt;&lt;br&gt;
Currently, there is no style given to a standard HTML button with the id "master." Look at the picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z3wzlJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674820394847_Screenshot%2B2023-01-26%2Bat%2B22-27-07%2BCodeSandbox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z3wzlJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674820394847_Screenshot%2B2023-01-26%2Bat%2B22-27-07%2BCodeSandbox.png" alt="Here’s how the Button looks like when we haven’t styled it" width="746" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CSS style for the button will be created as our first task.&lt;/p&gt;

&lt;p&gt;In order for JavaScript to automatically apply the CSS style with the class of "button" when you click the button, I will next add an event listener to the button in our JavaScript.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
body {
  background-color: blue;
  display: flex;
  margin: 30%;
  justify-content: center;
  align-items: center;
}
.button {
  background-color: blueviolet;
  width: 200px;
  border: none;
  font-size: 2rem;
  padding: 0.5rem;
  border-radius: 5px;
  cursor: pointer;
}
&amp;lt;/style&amp;gt;

&amp;lt;button id="master"&amp;gt;Click me&amp;lt;/button&amp;gt;

&amp;lt;script&amp;gt;
const buttonEl = document.getElementById('master')
buttonEl.addEventListener('click', addFunction)
 function addFunction(){
     buttonEl.classList.add('button')
  }
  &amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You'll see the following after clicking the button. Wonderful, huh?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4bq-MiKV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674820650087_Screenshot%2B2023-01-26%2Bat%2B22-57-30%2BCodeSandbox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4bq-MiKV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://paper-attachments.dropboxusercontent.com/s_14075E8C6CDA852222CE7404A978C7CB701CF9F11030AE3A68807DB03D1D8A91_1674820650087_Screenshot%2B2023-01-26%2Bat%2B22-57-30%2BCodeSandbox.png" alt="Now Here’s what you will see after you’ve added the style and script" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Remove a Class&lt;/strong&gt;&lt;br&gt;
The CSS style will be eliminated using the same example as earlier, but this time we'll use JavaScript's classList.remove() function. Most likely, you already knew what would occur.&lt;/p&gt;

&lt;p&gt;Yes, the button will return to its original condition.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const buttonEl = document.getElementById('master')
buttonEl.addEventListener('click', addFunction)

function addFunction(){
    buttonEl.classList.remove('button')
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to Toggle a Class&lt;/strong&gt;&lt;br&gt;
Let's imagine you don't want the CSS style to be fully removed. Toggling between the stylized and unstyled button is what you need.&lt;/p&gt;

&lt;p&gt;You may do it using the JavaScript function &lt;code&gt;classList.toggle()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Most social media networks, including Twitter, commonly employ the classList.toggle() function. It gives you the option to always like and dislike posts using the same button.&lt;/p&gt;

&lt;p&gt;JavaScript then determines if the button has the CSS class.&lt;/p&gt;

&lt;p&gt;If the class is present and you click the button, it is RELEASED. When you click the button if the class is missing, it is added.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const buttonEl = document.getElementById('master')&lt;br&gt;
buttonEl.addEventListener('click', addFunction)

&lt;p&gt;function addFunction(){&lt;br&gt;
    buttonEl.classList.toggle('button')&lt;br&gt;
 }&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Event handling&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What are HTML events?&lt;/strong&gt;&lt;br&gt;
HTML events are "things" that happen to HTML components, such as a button being clicked, the text being entered into a text box, etc. You may write JavaScript code, which we refer to as an event handler, that will be performed when an event like the one mentioned above happens.&lt;/p&gt;

&lt;p&gt;JavaScript functions are used as these event handlers. As a result, the handler function is called whenever an event happens on an element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event listeners&lt;/strong&gt;&lt;br&gt;
So far, we have used event listeners in pretty much all of the examples given. This ought to demonstrate the significance of event listeners in DOM manipulation.&lt;/p&gt;

&lt;p&gt;We need a method called addEventListener in order to add an event listener to an element or any other DOM object (). This approach is preferred to the previous one, in which the event to be handled was included in the HTML markup.&lt;/p&gt;

&lt;p&gt;This separates JavaScript from HTML markup, making the code simpler and easier to comprehend.&lt;/p&gt;

&lt;p&gt;If you're like me and appreciate the notion of separate JS, separate CSS, and so on, you'll like this event listener.&lt;/p&gt;

&lt;p&gt;A listener for events accepts three parameters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first is the category of the event, such as "click" and so on.&lt;/li&gt;
&lt;li&gt;The function will be used as the second parameter.&lt;/li&gt;
&lt;li&gt;A boolean value indicating whether to employ event capturing or event bubbling is the third argument. This element is not required.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Wow! Finally, we have come to the end of this tutorial hope you’ve learned a lot from this tutorial. Knowing how to manipulate the DOM is an essential part of JavaScript that is necessary and you going through this tutorial will help you achieve it.&lt;/p&gt;

&lt;p&gt;You might be able to create small JS applications if you comprehend the examples and pictures I provided above. The value of developing projects cannot be emphasized enough if you want to be a skilled developer.&lt;/p&gt;

&lt;p&gt;Till next time Enjoy!&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Author
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; is a full-stack laravel developer with &lt;code&gt;2+&lt;/code&gt; years of experience in the software development industry.&lt;/p&gt;

&lt;p&gt;He has grown full-blown skills in combining Software Development, Writing, and Teaching others what he does. His stacks include &lt;code&gt;JavaScript,&lt;/code&gt; &lt;code&gt;PHP,&lt;/code&gt; &lt;code&gt;ReactJs,&lt;/code&gt; &lt;code&gt;Laravel,&lt;/code&gt; and more.&lt;/p&gt;

&lt;p&gt;He is currently freelancing, building websites for clients, and writing technical tutorials teaching others how to do what he does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emmanuel Okolie&lt;/strong&gt; is open and available to hear from you. Kindly visit and follow him on &lt;a href="https://www.linkedin.com/in/emmanuel-okolie-435588238/"&gt;&lt;strong&gt;Linked-In&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://facebook.com/Emmykolic/"&gt;&lt;strong&gt;Facebook&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://twitter.com/emmykolic"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://www.twitter.com/emmykolic"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; or his &lt;a href="https://emmykolic.github.io"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

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