<?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: kareem_sulaimon</title>
    <description>The latest articles on DEV Community by kareem_sulaimon (@kareemsulaimon).</description>
    <link>https://dev.to/kareemsulaimon</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%2F993368%2F368ee388-46be-4774-afb6-8709540e0258.jpeg</url>
      <title>DEV Community: kareem_sulaimon</title>
      <link>https://dev.to/kareemsulaimon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kareemsulaimon"/>
    <language>en</language>
    <item>
      <title>Create a Movie App With React and TMDB API</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Sun, 24 Sep 2023 13:28:28 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/create-a-movie-app-with-react-and-tmdb-api-aeo</link>
      <guid>https://dev.to/kareemsulaimon/create-a-movie-app-with-react-and-tmdb-api-aeo</guid>
      <description>&lt;p&gt;In this tutorial, we will walk you through the process of creating a movie app using React.js and the TMDB API, ensuring a beginner-friendly and well-explained approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table Of Contents:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is TMDB API&lt;/li&gt;
&lt;li&gt;Install React and Set up React App&lt;/li&gt;
&lt;li&gt;Generate TMDB API&lt;/li&gt;
&lt;li&gt;Create .env file&lt;/li&gt;
&lt;li&gt;
Create context folder and stateContext.jsx file
6.0Create Navbar.jsx and paste this code&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. What is TMDB API
&lt;/h3&gt;

&lt;p&gt;The TMDB API provides a comprehensive list of available methods for movies, TV shows, actors, and images. For more information about the API, &lt;a href="https://developer.themoviedb.org/reference/intro/getting-started"&gt;click here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Install React and Set up React App
&lt;/h3&gt;

&lt;p&gt;a. Create a React app using Vite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx create-vite your_app_name &lt;span class="nt"&gt;--template&lt;/span&gt; react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once created, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install &lt;/span&gt;react-icons &lt;span class="nt"&gt;--save&lt;/span&gt;
   npm i react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access the final code on &lt;a href="https://github.com/KareemSulaimon/movieApp"&gt;GitHub - KareemSulaimon/movieApp&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Generate TMDB API
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Follow this &lt;a href="https://developer.themoviedb.org/reference/intro/getting-started"&gt;link&lt;/a&gt; and sign up for an account.&lt;/li&gt;
&lt;li&gt;Choose JavaScript as your preferred language and click "Get API Key."&lt;/li&gt;
&lt;li&gt;Continue, input your data and URL path (GitHub or personal website link).&lt;/li&gt;
&lt;li&gt;Check your notifications for your API Key.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  4. Create .env file
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Outside the src folder, in your root directory, create
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;touch&lt;/span&gt; .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the .env file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   VITE_REACT_APP_API_URL=https://api.themoviedb.org/3/
   VITE_REACT_APP_API_KEY=put your generated API key here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: We are starting the naming with VITE_REACT because we created it with a React app. It would have been REACT_ .... if we created it for React only.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Create context folder and stateContext.jsx file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;context/stateContext.jsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Context provides a way to pass data through the component tree without having to pass props down manually at every level. Read more here: &lt;a href="https://react.dev/reference/react/createContext"&gt;React Context&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In your 'stateContext.jsx' file, copy and paste this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StateContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;baseImageUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://image.tmdb.org/t/p/original&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VITE_REACT_APP_API_URL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VITE_REACT_APP_API_KEY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt;
      &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;baseImageUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;apiUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;apiKey&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useStateContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6.Create Navbar.jsx and paste this code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { BiSearch } from 'react-icons/bi';
import menu from '../assets/menu.png';
import logo from '../assets/logo.png';
import { useStateContext } from '../context/StateContext';
import { Link, Form } from 'react-router-dom';

function Navbar() {
  const { handleFormSubmit , query, handleInputChange } = useStateContext();

  return (
    &amp;lt;div className="flex flex-col sm:flex-row w-full justify-center sm:justify-around gap-4 items-center z-20 absolute top-10" data-testid="navbar"&amp;gt;
          &amp;lt;Link to={"/"} className='flex items-center' data-testid="logo-link"&amp;gt;
              &amp;lt;img src={logo} alt="logo icon" data-testid="logo-img" /&amp;gt;
          &amp;lt;/Link&amp;gt;
          &amp;lt;Form onSubmit={handleFormSubmit } className="flex w-3/5 sm:w-2/5 h-4 items-center border-white border-2 p-4 rounded-lg shadow-md" data-testid="search-bar"&amp;gt;
            &amp;lt;input
              type="text"
              placeholder="What do you want to watch?"
              value={query}
              onChange={handleInputChange}
              className="w-full placeholder-white bg-transparent border-none outline-0 text-sm text-white sm:text-lg"
              data-testid="search-input"
            /&amp;gt;
            &amp;lt;BiSearch className="text-white font-bold" data-testid="search-icon" /&amp;gt;
    &amp;lt;/Form&amp;gt;
    &amp;lt;div className="flex items-center" data-testid="menu-icon"&amp;gt;
      &amp;lt;img src={menu} alt="menu icon" /&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  );
}

export default Navbar;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in &lt;code&gt;Navbar.jsx&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The images are located in the assets folder.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Form&lt;/code&gt; and the &lt;code&gt;Link&lt;/code&gt; components are imported from &lt;code&gt;react-router-dom&lt;/code&gt;, which was previously installed. When the &lt;code&gt;Form&lt;/code&gt; is submitted, the &lt;code&gt;onSubmit&lt;/code&gt; method calls &lt;code&gt;handleFormSubmit&lt;/code&gt;, a function that will be defined later in &lt;code&gt;stateContext.jsx&lt;/code&gt;. Likewise, the &lt;code&gt;onChange&lt;/code&gt; method calls &lt;code&gt;handleInputChange&lt;/code&gt; whenever a change is made to the query value.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>What is BEM ?</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Sat, 22 Apr 2023 23:46:23 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/what-is-bem--1of7</link>
      <guid>https://dev.to/kareemsulaimon/what-is-bem--1of7</guid>
      <description>&lt;p&gt;As a front-end developer,have you ever heard of BEM? &lt;br&gt;
What comes to mind when you first heard it? Some kind of complicated principle? No isn't. &lt;br&gt;
 In this write-up, I will be taking you through the basics ofBEM, which stands for Block, Element, Modifier, is a methodology for naming and organizing CSS classes that have gained popularity among front-end developers in recent years. The goal of BEM is to create a more structured, maintainable, and scalable codebase that is easier to understand and work with.&lt;/p&gt;

&lt;p&gt;At its core, BEM is a simple concept. It is a naming convention that describes the relationship between different parts of an HTML element. The three parts of the BEM naming convention are as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block&lt;/strong&gt;: The block is the highest level of the BEM hierarchy. It represents a self-contained unit of functionality or content on a web page. Examples of blocks could be a header, a menu, or a footer. Blocks are named using a single word or phrase that describes their function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Element&lt;/strong&gt;:  element is part of a block that performs a specific function or has a specific role. Examples of elements could be a button, a title, or a logo. Elements are named using the block name, followed by two underscores (__), and then the element name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modifier&lt;/strong&gt;:  modifier is a variation of a block or element. It is used to change the appearance or behavior of a block or element without changing its basic structure. Examples of modifiers could be a disabled button or a highlighted menu item. Modifiers are named using the block or element name, followed by two hyphens (--), and then the modifier name.&lt;br&gt;
Here is an example of how BEM can be applied to an HTML element:&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 class="block"&amp;gt;
  &amp;lt;h2 class="block__element"&amp;gt;Title&amp;lt;/h2&amp;gt;
  &amp;lt;button class="block__element--modifier"&amp;gt;Button&amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="block"&amp;gt;
  &amp;lt;h2 class="block__title"&amp;gt;Title&amp;lt;/h2&amp;gt;
  &amp;lt;ul class="block__list"&amp;gt;
    &amp;lt;li class="block__list-item"&amp;gt;Item 1&amp;lt;/li&amp;gt;
    &amp;lt;li class="block__list-item block__list-item--featured"&amp;gt;Item 2&amp;lt;/li&amp;gt;
    &amp;lt;li class="block__list-item block__list-item--highlighted"&amp;gt;Item 3&amp;lt;/li&amp;gt;
  &amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="detail"&amp;gt;  
        &amp;lt;span class="detail_frame_3 frame--3"&amp;gt;
                &amp;lt;h5&amp;gt;{{post._embedded["author"][0].name}} &amp;lt;/h5&amp;gt;
                &amp;lt;small&amp;gt;{{ post.date.slice(0,10) }}&amp;lt;/small&amp;gt;
        &amp;lt;/span&amp;gt;

        &amp;lt;div class="detail_frame-9 frame-9"&amp;gt;
         &amp;lt;h5&amp;gt;{{ post.title.rendered }} &amp;lt;/h5&amp;gt;
         &amp;lt;div class="detail_frame-9_paragraph paragraph "&amp;gt;
            &amp;lt;div&amp;gt;
                {{ selectedParagraph }}
            &amp;lt;/div&amp;gt;
         &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

    &amp;lt;div class="detail_image"&amp;gt;
      &amp;lt;img :src="post._embedded['wp:featuredmedia'][0]?.source_url" &amp;gt;
   &amp;lt;/div&amp;gt;


    &amp;lt;div class="detail_paragraph paragraph " v-for="(paragraph, index) in paragraphs" :key="index" &amp;gt; 
      {{ paragraph}}
        &amp;lt;/div&amp;gt;



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

&lt;/div&gt;



&lt;p&gt;In this example, "block" is the highest-level container, "element" is a part of the "block," and "modifier" is a variation of the "element." By using this naming convention, it becomes easy to understand the structure of the HTML element and to make changes to the CSS styles that are applied to it.&lt;/p&gt;

&lt;p&gt;One of the key benefits of using BEM is that it helps to create more maintainable and scalable CSS code. By following a consistent naming convention, developers can more easily understand how different parts of the code relate to each other and avoid creating duplicate styles or conflicting selectors. Additionally, the structure of BEM makes it easier to organize and manage large CSS codebases, making it ideal for complex projects.&lt;/p&gt;

&lt;p&gt;In conclusion, BEM is a powerful methodology that can help frontend developers create more maintainable, scalable, and understandable CSS code. By following a consistent naming convention, developers can create code that is easier to read, manage, and maintain over time, making it a valuable addition to any frontend development workflow.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>All You Need To Know About The Console Object Method</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Fri, 03 Mar 2023 09:27:44 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/all-you-need-to-know-about-the-console-object-method-aic</link>
      <guid>https://dev.to/kareemsulaimon/all-you-need-to-know-about-the-console-object-method-aic</guid>
      <description>&lt;p&gt;The console object is a powerful tool in the world of web development. It is a built-in object in JavaScript that provides developers with a way to interact with the browser console. The console object is used to log, display, and manipulate data in the console, making it an essential tool for debugging 🐞 and troubleshooting code.&lt;/p&gt;

&lt;p&gt;In this article, we will take a closer look at the console object and its various features, as well as some of its drawbacks.&lt;/p&gt;

&lt;p&gt;📌 The console.log() method can  accept argument or multiple arguments, making it possible to log several messages or variables at once.Here is an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("Hello, world 🌍!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is another example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = "John";
const age = 30;
console.log("My name is", name, "and I am", age, "years old.");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 console.assert() is a debugging tool that helps you find bugs in your code by asserting that a certain condition is true. If the condition is false, the assertion will throw an error and display a message in the console.Here is an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let numbers = [1, 2, 3, 4];
console.assert(numbers.length === 5, 'Numbers array should have a length of 5.');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 The console.clear()  clears the console.Here is an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setInterval(() =&amp;gt; {
  console.clear();
}, 5000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will clear the console every 5 seconds using setInterval(). This can be useful for keeping the console from getting too cluttered during long-running processes.&lt;/p&gt;

&lt;p&gt;📌 The console.warn() outputs a warning message ⚠️ to the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 10;
if (x &amp;gt; 5) {
  console.warn("The value of x is greater than 5");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, if the value of x is greater than 5, the console.warn() method will be called with the message "The value of x is greater than 5". This will log a warning message to the browser console, indicating that something unexpected or potentially problematic may have occurred in the code.&lt;/p&gt;

&lt;p&gt;📌 console.error log out error to the console. It is similar to console.log(), but it is typically used for logging error messages or exceptions.&lt;/p&gt;

&lt;p&gt;Here's an example of how to use console.error():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
  // some code that might throw an error
} catch (error) {
  console.error('An error occurred:', error);
}

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

&lt;/div&gt;



&lt;p&gt;In this example, the try block contains some code that might throw an error. If an error is thrown, the catch block will be executed and the error parameter will contain information about the error. The console.error() method is then used to log the error message to the console.&lt;/p&gt;

&lt;p&gt;📌 console.group() is a method of the console object that allows you to group related console messages together in a collapsed group. This can be helpful when you have a lot of console output and want to organize it in a more structured way.&lt;/p&gt;

&lt;p&gt;Here's an example of using console.group() to group related console messages together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.group("User Information");
console.log("Name: John Doe");
console.log("Email: john.doe@example.com");
console.log("Phone: 123-456-7890");
console.groupEnd();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 The console.info() method is used to log information to the console. It takes one or more arguments, which can be strings, numbers, or objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = "John";
const age = 25;
const job = "Developer";

console.info("Name:", name);
console.info("Age:", age);
console.info("Job:", job);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run this code in a browser console, you'll see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name: John
Age: 25
Job: Developer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 console.time() is a method in JavaScript that starts a timer ⏳ in the browser's console. It takes one argument, which is a string that will be used to label the timer while&lt;/p&gt;

&lt;p&gt;📌 console.timeEnd() is a method in JavaScript that is used to stop the timer ⌛ that was started by the console.time() method.&lt;/p&gt;

&lt;p&gt;Here is an example of how to use console.time() and console.timeEnd():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.time('myTimer');

// Code to be timed here
for (let i = 0; i &amp;lt; 1000000; i++) {
}
console.timeEnd('myTimer');

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

&lt;/div&gt;



&lt;p&gt;In this example, console.time('myTimer') starts the timer labeled "myTimer", and console.timeEnd('myTimer') stops the timer and outputs the elapsed time in milliseconds to the console.&lt;/p&gt;

&lt;p&gt;📌 console.count() is a method in JavaScript that allows you to count the number of times it has been called. It takes one argument, which is an optional label that will be used to identify the count in the console output.&lt;/p&gt;

&lt;p&gt;Here is an example of how to use console.count():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(name) {
  console.count('greetings');
  console.log(`Hello, ${name}!`);
}

greet('Alice');
greet('Bob');
greet('Charlie');
greet('Bob');

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Drawbacks of the Console Method&lt;/strong&gt;&lt;br&gt;
While console methods can be very useful for debugging and troubleshooting JavaScript code, there are a few drawbacks to consider:&lt;/p&gt;

&lt;p&gt;📌 Compatibility issues: Not all browsers and environments support the console object and its methods, and some may have limitations or differences in their implementation. This can make it difficult to rely on console methods for debugging in all situations.&lt;/p&gt;

&lt;p&gt;📌 Security concerns: It's important to be careful with the information that is logged to the console, as sensitive data such as passwords or authentication tokens can be exposed if not handled properly. In addition, console logs left in production code can make it easier for attackers to find and exploit vulnerabilities.&lt;/p&gt;

&lt;p&gt;📌 Overuse: While console methods can be helpful for debugging, excessive use of console.log() statements can clutter up the console and slow down the performance of the application. It's important to use console methods judiciously and only when necessary.&lt;/p&gt;

&lt;p&gt;📌 Inaccurate measurements: The accuracy of console.time() and console.timeEnd() can be affected by external factors such as network latency and system load. In addition, the time taken to execute a particular block of code can vary depending on the hardware and software environment, making it difficult to compare performance across different systems. Therefore, it's important to use console methods in conjunction with other profiling tools to get a more accurate picture of performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The console method is a feature in programming languages that allows developers to output messages and debug their code. Check out &lt;a href="https://www.w3schools.com/jsref/api_console.asp" rel="noopener noreferrer"&gt;w3school&lt;/a&gt; for more information on the console method. Thanks for reading &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>cybersecurity</category>
      <category>learning</category>
      <category>introduction</category>
    </item>
    <item>
      <title>How To Dynamically Import Image in Vue Vite</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Sat, 28 Jan 2023 03:37:06 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/how-to-dynamically-import-image-in-vue-vite-4g3a</link>
      <guid>https://dev.to/kareemsulaimon/how-to-dynamically-import-image-in-vue-vite-4g3a</guid>
      <description>&lt;p&gt;The JavaScript function below takes a parameter name and returns a URL for an image file with the specified name. It uses the URL constructor to create a new URL object, with the first argument being the path to the image file, which is constructed by concatenating the directory name "./dir/", the name passed as a parameter, and the file extension ".png". The second argument passed to the URL constructor is import.meta.url, which is a property that contains the base URL of the current module.&lt;/p&gt;

&lt;p&gt;You can read more about importing statics assets at&lt;br&gt;
&lt;a href="https://vitejs.dev/guide/assets.html"&gt;https://vitejs.dev/guide/assets.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function getImageUrl(name) {&lt;br&gt;
     return new URL(&lt;/code&gt;../assets/images/${name}&lt;code&gt;, import.meta.url).href&lt;br&gt;
      }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By calling the href property of the returned URL object, the function will return a string containing the full URL of the image file, including the protocol (e.g. "https:"), the hostname (e.g. "&lt;a href="http://www.example.com"&gt;www.example.com"&lt;/a&gt;), and the path to the file.&lt;/p&gt;

&lt;p&gt;This function can be used in your Vue component to set the image url. For example, you can create a computed property that returns the import statement for the image you want to use as the background, and then bind that property to the "style" binding of a div element.&lt;br&gt;
Here is an example for static image:&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;template&amp;gt;
      &amp;lt;img :src="getImageUrl(img )"&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
 setup() {
const getImageUrl{
    new URL(`../assets/images/image.jpg`, import.meta.url)
      } 
return {
getImageUrl 
}
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is an example for dynamic image using option api:&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;template&amp;gt;
  &amp;lt;div id="bg" 
     :style="{background:`url(${getImageUrl(ImageNow) })` + `no-repeat center  center/cover`}"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
  export default {
    data () {
      return {
        images: ['city.jpg', 'house3.jpg','family.jpg'],
         currentImage: 0,
         interval: null
 }
},

  methods: {
  changeImage () {
  this.interval = setInterval(() =&amp;gt; {
  this.currentImage++
  }, 10000);
    },

   getImageUrl(name) {
     return new URL(`../assets/images/${name}`,import.meta.url).href
      }
  },
 computed: {
      ImageNow () {
      return this.images[Math.abs(this.currentImage)% this.images.length] 
      }
  } 
}
&amp;lt;/script&amp;gt;`

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

&lt;/div&gt;



&lt;p&gt;With Dynamic URL &amp;amp; absolute Path using composition api:&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;template&amp;gt;
 &amp;lt;div class="gallery"&amp;gt;
        &amp;lt;img v-for="img in gallery" :key="img " :src=" getImageUrl(img )"&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import {ref} from 'vue';

export default {
 setup() {
 const gallery= ref([
  'gallery1.jpg' ,'gallery2.jpg',
 'gallery3.jpg','gallery 4.jpg',
 'gallery5.jpg' ,'gallery6.jpg',
    ] ) ,

function getImageUrl(name) {
     return new URL(`../assets/images/${name}`, import.meta.url).href
      } ,

return {
getImageUrl , summary 
}
}
}
&amp;lt;/script&amp;gt;

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

&lt;/div&gt;



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

&lt;p&gt;It's important to declare the  getIamgeUrl function in script. Then pass parameters from data. The parameters(image URL) can either be loop using Vue v-for, computed or pass directly incase of single image path.&lt;br&gt;
Read more about handling statics assets at&lt;br&gt;
&lt;a href="https://vitejs.dev/guide/assets.html"&gt;https://vitejs.dev/guide/assets.html&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Import Dynamically Image in Vue Vite</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Fri, 27 Jan 2023 04:11:06 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/how-to-import-dynamically-image-in-vue-vite-38nk</link>
      <guid>https://dev.to/kareemsulaimon/how-to-import-dynamically-image-in-vue-vite-38nk</guid>
      <description>&lt;p&gt;This is a JavaScript function  takes a parameter name and returns a URL for an image file with the specified name. It uses the URL constructor to create a new URL object, with the first argument being the path to the image file, which is constructed by concatenating the directory name "./dir/", the name passed as a parameter, and the file extension ".png". The second argument passed to the URL constructor is import.meta.url, which is a property that contains the base URL of the current module.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function getImageUrl(name) {&lt;br&gt;
     return new URL(`../assets/images/${name}`, import.meta.url).href&lt;br&gt;
      }&lt;/code&gt;&lt;br&gt;
By calling the href property of the returned URL object, the function will return a string containing the full URL of the image file, including the protocol (e.g. "https:"), the hostname (e.g. "&lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com"&lt;/a&gt;), and the path to the file.&lt;/p&gt;

&lt;p&gt;This function can be used in your Vue component to set the image url. For example, you can create a computed property that returns the import statement for the image you want to use as the background, and then bind that property to the "style" binding of a div element.&lt;br&gt;
Here is an example for static image:&lt;br&gt;
 `&lt;br&gt;
      &lt;a href="" class="article-body-image-wrapper"&gt;&lt;img&gt;&lt;/a&gt;&lt;br&gt;
    &lt;br&gt;
&lt;/p&gt;

&lt;p&gt;setup() {&lt;br&gt;
const getImageUrl{&lt;br&gt;
    new URL(&lt;code&gt;../assets/images/image.jpg&lt;/code&gt;, import.meta.url)&lt;br&gt;
      } &lt;/p&gt;

&lt;p&gt;return {&lt;br&gt;
getImageUrl &lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
  
     :style="{background:`url(${getImageUrl(ImageNow) })` + `no-repeat center  center/cover`}"&amp;gt;&lt;br&gt;
&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;`&amp;lt;br&amp;gt;
  export default {&amp;lt;br&amp;gt;
    data () {&amp;lt;br&amp;gt;
      return {&amp;lt;br&amp;gt;
        images: [&amp;amp;#39;city.jpg&amp;amp;#39;, &amp;amp;#39;house3.jpg&amp;amp;#39;,&amp;amp;#39;family.jpg&amp;amp;#39;]&amp;lt;br&amp;gt;
 },&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;methods: {&amp;lt;br&amp;gt;
   getImageUrl(name) {&amp;lt;br&amp;gt;
     return new URL(&amp;lt;code&amp;gt;../assets/images/${name}&amp;lt;/code&amp;gt;,import.meta.url).href&amp;lt;br&amp;gt;
      }&amp;lt;br&amp;gt;
  },&amp;lt;br&amp;gt;
 computed: {&amp;lt;br&amp;gt;
      ImageNow () {&amp;lt;br&amp;gt;
      return this.images[Math.abs(this.currentImage)% this.images.length] &amp;lt;br&amp;gt;
      }&amp;lt;br&amp;gt;
  } &amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
`&lt;/p&gt;

&lt;p&gt;here  is  another example:&lt;br&gt;
`&lt;br&gt;
 &lt;br&gt;
        &lt;a href="" class="article-body-image-wrapper"&gt;&lt;img&gt;&lt;/a&gt;&lt;br&gt;
    &lt;/p&gt;



&lt;p&gt;import {ref} from 'vue';&lt;/p&gt;

&lt;p&gt;setup() {&lt;br&gt;
 const gallery= ref([&lt;br&gt;
  'gallery1.jpg' ,'gallery2.jpg',&lt;br&gt;
 'gallery3.jpg','gallery 4.jpg',&lt;br&gt;
 'gallery5.jpg' ,'gallery6.jpg',&lt;br&gt;
    ] ) &lt;/p&gt;

&lt;p&gt;function getImageUrl(name) {&lt;br&gt;
     return new URL(&lt;code&gt;../assets/images/${name}&lt;/code&gt;, import.meta.url).href&lt;br&gt;
      } &lt;/p&gt;

&lt;p&gt;return {&lt;br&gt;
getImageUrl , summary &lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

</description>
      <category>motivation</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Use Swiper JS in Vue Vite</title>
      <dc:creator>kareem_sulaimon</dc:creator>
      <pubDate>Wed, 18 Jan 2023 02:11:43 +0000</pubDate>
      <link>https://dev.to/kareemsulaimon/how-to-use-swiper-js-in-vue-vite-5doa</link>
      <guid>https://dev.to/kareemsulaimon/how-to-use-swiper-js-in-vue-vite-5doa</guid>
      <description>&lt;p&gt;Vue.js is a popular JavaScript framework for building web applications, and Vite is a lightweight development server that makes it easy to get started with Vue.js projects&lt;br&gt;
Swiper is a popular JavaScript library for building touch-enabled, mobile-first carousels and sliders. swiper document here. For more in depth info, click the the below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://swiperjs.com/vue" rel="noopener noreferrer"&gt;https://swiperjs.com/vue&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Create Vue Vite Application
&lt;/h2&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%2Fbu6ph50vbsc7ajltaalc.jpeg" 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%2Fbu6ph50vbsc7ajltaalc.jpeg" alt="Image description" width="345" height="146"&gt;&lt;/a&gt;&lt;br&gt;
In this section we will introduce how to scaffold a Vue Single Page Application on your local machine. The created project will be using a build setup based on Vite and allow us to use Vue Single-File Components (SFCs)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#npm init vue@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be presented with prompts for several optional features such as TypeScript and testing support.&lt;br&gt;
If you are unsure about an option, simply choose NO by hitting enter for now.&lt;br&gt;
Then follow the instructions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd &amp;lt;your-project-name&amp;gt;
npm install
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Installing Swiper
&lt;/h2&gt;

&lt;p&gt;Before we can start using Swiper, we need to install it in our project. &lt;br&gt;
We can install Swiper from NPM&lt;br&gt;
&lt;/p&gt;

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

 // import Swiper JS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Now that you have the Swiper library and its Vue.js wrapper installed, you need to configure your project to use them.&lt;br&gt;
You will have to import the library and the styles in your main.js file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {swiper, swiperSlide} from 'swiper/vue';
import swiperCore, (/* { default global options } */) from "swiper";

import "swiper/swiper.min.css";
import "swiper/css/ (/*{ default global options }*/)

swiperCore.use([/* default global options */])

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;In your template, you can now use the swiper component to create a slider. The swiper component accepts a number of props that allow you to customize the slider, such as options and slidesPerView.&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="app"&amp;gt;
    &amp;lt;swiper :options="swiperOptions" :slides-per-view="3"&amp;gt;
      &amp;lt;swiper-slide&amp;gt;Slide 1&amp;lt;/swiper-slide&amp;gt;
      &amp;lt;swiper-slide&amp;gt;Slide 2&amp;lt;/swiper-slide&amp;gt;
      &amp;lt;swiper-slide&amp;gt;Slide 3&amp;lt;/swiper-slide&amp;gt;
    &amp;lt;/swiper&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you can define the options in your script part as&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;script&amp;gt;
export default {
  name: 'App',
  data() {
    return {
      swiperOptions: {
        loop: true,
        pagination: {
          el: '.swiper-pagination',
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        autoplay: {
          delay: 5000,
        },
      },
    }
  },
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuring the Slider
&lt;/h2&gt;

&lt;p&gt;There are many options available for configuring the Swiper slider, including options for navigation, pagination, and autoplay. Here are a few examples of options that you can use to customize the slider:&lt;/p&gt;

&lt;p&gt;slidesPerView: This option sets the number of slides that are visible at one time.&lt;/p&gt;

&lt;p&gt;loop: This option enables the "loop" mode, which allows the slider to loop continuously.&lt;/p&gt;

&lt;p&gt;Pagination: This option enables the pagination feature, which allows users to navigate through the slides by clicking on a pagination button.&lt;/p&gt;

&lt;p&gt;autoplay: This option enables the autoplay feature, which automatically advances the slides at a set interval.&lt;/p&gt;

&lt;p&gt;speed: This option sets the duration of the transition between slides.&lt;/p&gt;

&lt;p&gt;You can check more here&lt;br&gt;
&lt;a href="https://swiperjs.com/vue" rel="noopener noreferrer"&gt;https://swiperjs.com/vue&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>music</category>
    </item>
  </channel>
</rss>
