<?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: Omotosho toheeb</title>
    <description>The latest articles on DEV Community by Omotosho toheeb (@toheebcodes).</description>
    <link>https://dev.to/toheebcodes</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%2F1155098%2Fb3d82f4a-8ec3-47aa-a5fd-c8cd30e9a910.jpg</url>
      <title>DEV Community: Omotosho toheeb</title>
      <link>https://dev.to/toheebcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toheebcodes"/>
    <language>en</language>
    <item>
      <title>JavaScript Basics: Understanding Syntax and Data Types</title>
      <dc:creator>Omotosho toheeb</dc:creator>
      <pubDate>Mon, 11 Sep 2023 07:16:15 +0000</pubDate>
      <link>https://dev.to/toheebcodes/javascript-basics-understanding-syntax-and-data-types-3ac7</link>
      <guid>https://dev.to/toheebcodes/javascript-basics-understanding-syntax-and-data-types-3ac7</guid>
      <description>&lt;p&gt;JavaScript is a versatile programming language that powers dynamic and interactive web content. To dive into JavaScript programming, it's essential to understand its fundamental building blocks. In this article, we will explore the basic syntax, data types, and operators that form the foundation of JavaScript programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
JavaScript syntax refers to the rules and structure that indicate how code is written in the language. Let's cover a few essential elements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Statements:&lt;/strong&gt;&lt;br&gt;
JavaScript code is composed of statements that perform specific actions. Each statement typically ends with a semicolon ( ; ), although it is sometimes optional.&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 = 5; 

console.log(x);

const name = "Programmer";
//This are all different types of statements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Comments:&lt;/strong&gt;&lt;br&gt;
Comments are non-executable lines used for adding notes or explanations to your code. In JavaScript, single-line comments start with "//", while multi-line comments are enclosed between "/" and "/".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This is a single-line comment

/*
   This is a multi-line comment
   that covers multiple lines.
*/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Variables:&lt;/strong&gt;&lt;br&gt;
Variables are like containers that store data and allow us to refer to that data by a name. In JavaScript, you can declare variables using the let, const, or var keywords. Variables hold various types of data, such as numbers, strings, or objects. The recommended way is to use let and const as they have more predictable behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Declaration and Assignment:&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;let age; // Variable declaration
age = 25; // Variable assignment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;b. Combining Declaration and Assignment:&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;let name = 'John';
const pi = 3.14;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember, let allows you to change the value of the variable, while const creates a constant (unchangeable) reference to a value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Variable Naming Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A variable name must start with a letter (a-z, A-Z) or an underscore (_).&lt;/p&gt;

&lt;p&gt;It can contain letters, numbers, or underscores.&lt;/p&gt;

&lt;p&gt;JavaScript is case-sensitive, so age and Age are different variables.&lt;/p&gt;

&lt;p&gt;Whenever a variable name consists of more than one word, it is better to enable writing conventions like camelCase or snake_case,&lt;/p&gt;

&lt;p&gt;i. camelCase is a naming convention where compound words or &lt;br&gt;
phrases are written without spaces, and each word's initial     letter is capitalized except for the first word. The resulting &lt;br&gt;
word looks like the humps on a camel's back, hence the name     "camel case."&lt;/p&gt;

&lt;p&gt;ii. In snake_case, compound words are written in lowercase     letters, and each word is separated by an underscore (_). The     resulting identifier resembles the shape of a snake.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nameOfStudent = "Toheeb" // CamelCase

let name_of_student = "Toheeb" // snake_case
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Data Types:&lt;/strong&gt;&lt;br&gt;
JavaScript is a loosely typed language, meaning variables can hold values of different data types. Here are some essential data types:&lt;/p&gt;

&lt;p&gt;Data types can be categorized into two main groups: primitive data types and non-primitive (also known as reference) data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitive Data Types:&lt;/strong&gt; Primitive data types are simple and unchangeable data types. They are directly stored in memory and are represented by their actual value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-Primitive (Reference) Data Types:&lt;/strong&gt; Non-primitive data types are more complex and changeable. Instead of storing the actual value directly, they store a reference (memory address) to the location where the value is stored.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--stZF6Chn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b6gqb1sanofe9jsxmraw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--stZF6Chn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b6gqb1sanofe9jsxmraw.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Numbers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript includes support for numeric data, both integers and floating-point numbers. Mathematical operations like addition, subtraction, multiplication, and division can be performed on number variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let age = 25; // Integer
let price = 19.99; // Float (decimal)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;b. Strings:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Strings represent sequences of characters enclosed within single quotes ('') or double quotes (" "). They are used to store and manipulate text-based data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = 'Toheeb'; // Single or double quotes can enclose strings
let message = "Hello, World!";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;c. Booleans:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Booleans represent logical values, either "true" or "false". They are commonly used in conditional statements and control structures to make decisions based on certain conditions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let isProgrammer = true; // Represents true or false values
let isPainter = false;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;d. Undefined and Null:&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;let undefinedValue = undefined; // Represents an uninitialized variable
let nullValue = null; // Represents an intentional absence of any value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;e. Arrays:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arrays are ordered collections of values. They can store multiple data types, including numbers, strings, objects, or even other arrays. Arrays are useful for storing and manipulating lists of related data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruits = ['apple', 'banana', 'orange']; // Ordered list of elements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;f. Objects:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Objects are containers for key-value pairs and represent more complex data structures. They allow you to group related data and functions. Objects are defined using curly braces ( { } ) and consist of properties and methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let person = { 
    name: 'Toheeb',
    age: 24,
    isStudent: true
}; // Collection of key-value pairs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;g. Functions:&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;function greet(name) {
    return `Hello, ${name}!`;
} // Reusable blocks of code that can be called with arguments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Operators:&lt;/strong&gt;&lt;br&gt;
Operators are symbols or keywords that allow you to perform operations on variables and values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Arithmetic Operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These operators (+, -, *, /, %) perform basic mathematical calculations on numeric data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let num1 = 10;
let num2 = 5;

let sum = num1 + num2; // Addition
let difference = num1 - num2; // Subtraction
let product = num1 * num2; // Multiplication
let quotient = num1 / num2; // Division
let remainder = num1 % num2; // Modulus (remainder of division)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;b. Comparison Operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Comparison operators (==, ===, !=, !==, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=) compare two values and return a Boolean value indicating the result. *Remember that Boolean simply refers to either true or false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = 10;
let b = 5;

console.log(a &amp;gt; b); // Greater than
console.log(a &amp;lt; b); // Less than
console.log(a &amp;gt;= b); // Greater than or equal to
console.log(a &amp;lt;= b); // Less than or equal to
console.log(a === b); // Equal to (strict equality)
console.log(a !== b); // Not equal to
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;c. Logical Operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logical operators (&amp;amp;&amp;amp;, ||, !) are used to combine or negate Boolean values, enabling you to make complex logical decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. Assignment Operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Assignment operators (=, +=, -=, *=, /=) are used to assign values to variables and update their contents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e. String Operators:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript uses the "+" operator for string concatenation, which allows you to combine multiple strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let greeting = "Hello, ";
let name = "Programmer";

console.log(greeting + name);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding the basic syntax, data types, and operators in JavaScript is fundamental to writing effective code. With a strong grasp of these building blocks, you have a solid foundation for exploring more advanced concepts and building dynamic web applications. Keep practicing, experimenting, and exploring the vast world of JavaScript programming!&lt;/p&gt;

&lt;p&gt;Remember, learning JavaScript is an iterative process, and continuous practice will enhance your skills. Don't hesitate to refer back to this article as a quick reference whenever you need to refresh your understanding of these core concepts.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to center a div</title>
      <dc:creator>Omotosho toheeb</dc:creator>
      <pubDate>Wed, 06 Sep 2023 17:31:31 +0000</pubDate>
      <link>https://dev.to/toheebcodes/how-to-center-a-div-4e46</link>
      <guid>https://dev.to/toheebcodes/how-to-center-a-div-4e46</guid>
      <description>&lt;p&gt;Achieving accurate div centering is a common challenge faced by web developers when it comes to creating balanced layouts. Fortunately, several effective methods in HTML and CSS can help you achieve div centering with ease. In this guide, we will explore various techniques for centering a div element, providing step-by-step instructions and accompanying examples to empower you with the knowledge to master this essential skill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Using the CSS Margin property:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;margin: auto;&lt;/code&gt; method is one of the simplest ways to center a div horizontally within its parent container. By applying auto margins to the left and right sides of the div, you can achieve center alignment effortlessly. Here's 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;&amp;lt;div class="container"&amp;gt;

    &amp;lt;div class=centered-div"&amp;gt;
        &amp;lt;!-- Your content here --&amp;gt;
    &amp;lt;/div&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;.container {
    display: flex;
}

.centered-div {
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    margin-bottom: 0;
}

/* or you can use the shorthand property */

.centered-div {
    margin: 0 auto;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*By using the shorthand method, we set the top and bottom margins to 0 each, and both the left and right margins to auto.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Applying Flexbox properties&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flexbox is a powerful layout module in CSS that provides flexible and different ways to align and position elements. We'll show you how to create a flex container and use flexbox properties to center a div both horizontally and vertically.&lt;/p&gt;

&lt;p&gt;Here's 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;&amp;lt;div class="container"&amp;gt;

    &amp;lt;div class="centered-div"&amp;gt;
        &amp;lt;!-- Your content here --&amp;gt;
    &amp;lt;/div&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;.container {
    display: flex;
    justify-content: center;
    align-items: center;
}
.centered-div {
 /* Additional styles for the div */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You use &lt;code&gt;display: flex;&lt;/code&gt; to create a flex container for centering, then you declare &lt;code&gt;justify-content: center;&lt;/code&gt; to place the div in the center of the main axis horizontally, while the &lt;code&gt;align-items: center;&lt;/code&gt; declaration is to place it in the center of the main axis vertically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Using the CSS Grid property.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CSS Grid property offers a grid system that enables accurate control over element placement. We'll demonstrate how to create a grid container and apply grid properties to center a div within the grid.&lt;/p&gt;

&lt;p&gt;Here's 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;&amp;lt;div class="container"&amp;gt;

    &amp;lt;div class="centered-div"&amp;gt;
        &amp;lt;!-- Your content here --&amp;gt;
    &amp;lt;/div&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;.container {
    display: grid;
    place-items: center;
    height: 100vh;
}

.centered-div {
    /* Additional styles for the div */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we set a declaration of display: grid; for the container to create a grid container and enable us to use the needed grid properties, then we apply the declaration place-items: center; to place it in the center. *Note that the place-items: center; declaration is a shorthand for justify-items: center and align-items: center;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Absolute Positioning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Absolute positioning allows you to precisely position elements within their parent containers. We'll explain how to use absolute positioning to center a div and guide you through the use of elements translation and negative margin percentage to achieve the perfect center alignment. Here's 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;&amp;lt;div class="container"&amp;gt;

    &amp;lt;div class="centered-div"&amp;gt;
        &amp;lt;!-- Your content here --&amp;gt;
    &amp;lt;/div&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;.container {
    position: relative;
}

.centered-div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Positioning a div with &lt;code&gt;position: absolute;&lt;/code&gt; works by taking the div out of the normal document flow, allowing it to be placed precisely within its closest positioned ancestor (that is why we set &lt;code&gt;position: relative;&lt;/code&gt; for the container, so it remains in the container flow). Once positioned, we set the &lt;code&gt;top: 50%;&lt;/code&gt; to move the div halfway to the top, then we set the &lt;code&gt;left: 50%;&lt;/code&gt; to set it halfway to the left.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;transform: translate(-50%, -50%)&lt;/code&gt; declaration works by translating (moving) the element by the specified percentage of its width and height along both the horizontal and vertical axes.&lt;/p&gt;

&lt;p&gt;When you apply &lt;code&gt;transform: translate(-50%, -50%);&lt;/code&gt; to an element, it shifts the element's position exactly by half of its width and half of its height in the opposite direction of the specified percentage. This has the effect of centering the element both horizontally and vertically within its parent container. For example, to center a square div with a width and height of 100px, the translate function will move the div 50px to the left and 50px up, centering it within its container. The percentage values are relative to the dimensions of the element itself, which means the technique works regardless of the element's size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Centering Inline Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While divs are block-level elements, centering inline elements like spans or text within a div is also important. We'll show you how to apply text alignment and line-height properties to center inline content within a div. Here's 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;&amp;lt;div class="container"&amp;gt;

    &amp;lt;span class="centered-span"&amp;gt;Centered Text&amp;lt;/span&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;.container {
    text-align: center;
}

.centered-span {
    line-height: 200px;
    /* Additional styles for the span */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, we can place the text at the center of the container and increase the line height i.e. the horizontal gap between lines, to 200px.&lt;/p&gt;

&lt;p&gt;Mastering div centering is a valuable skill for web developers, enabling them to create visually appealing and balanced layouts. In this guide, we explored various techniques for achieving div centering using HTML and CSS. With step-by-step instructions, accompanied by examples, you now have a complete guide at your disposal. By applying these techniques with precision and considering responsive design principles, you can create visually stunning and well-aligned div layouts that enhance the overall user experience.&lt;/p&gt;

</description>
      <category>css</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
