<?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: Adijat Motunrayo Adeneye</title>
    <description>The latest articles on DEV Community by Adijat Motunrayo Adeneye (@motuncoded).</description>
    <link>https://dev.to/motuncoded</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%2F425699%2F654f2a9d-86a0-4ebf-a03c-270514d20e53.jpg</url>
      <title>DEV Community: Adijat Motunrayo Adeneye</title>
      <link>https://dev.to/motuncoded</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/motuncoded"/>
    <language>en</language>
    <item>
      <title>js</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Wed, 19 Feb 2025 11:26:44 +0000</pubDate>
      <link>https://dev.to/motuncoded/js-2dfb</link>
      <guid>https://dev.to/motuncoded/js-2dfb</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;HTML gives the web page structure and purpose&lt;/li&gt;
&lt;li&gt;CSS makes it looks aesthetic with styling&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JS makes the page dynamic and interactive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A lightweight, interpreted programming language.&lt;br&gt;
it run instantly as a soon it run instantly, it is interpreted and dynamic. it is popular&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programs written in JavaScript are called scripts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript allows you to implement complex interaction on Web pages. you add dynamic interaction with javascript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is the third layer of standard web technologies (HTML, CSS, JS).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript is different from Java programming language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the relationship between HTML, CSS and javascript is because they are standard of building a  website&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;it used .js file extension.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Uses of JavaScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;adds interactivity to web pages&lt;/li&gt;
&lt;li&gt;run codes in response to certain events&lt;/li&gt;
&lt;li&gt;javascript has a powerful application programming interface(API) hence access to numerous complex features e.g get location, mapping, 2d graphics.&lt;/li&gt;
&lt;li&gt;it is everywhere it can be run anywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Execution in Js
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;to run it, it can be run by a browser with javascript virtual machine to run js, the jvm can be in a browser(cos all browsers come with a jvm where it is chrome, Safari, mozilla, edge), mobile phone, a server. for chrome, opera and edge they have v8 machine because the v8 is maintained by chrome, for firefox their jvm is spiderMonkey, for internet explorer which is no longer in use theirs is called chakra, for apple we have squirrelfish.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to run javascript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Internal js / inline js to run javascript internally&lt;/li&gt;
&lt;li&gt;external js is tp add js in another file and reference it 
in the script tag
&lt;code&gt;&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;
the order is important&lt;/li&gt;
&lt;li&gt;to debug you use a developer console to check the debugging we have some section in the dev tools, element, network, console, sources, performance, memory.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A statement carry out an action&lt;br&gt;
&lt;code&gt;alert("click me")&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;comments in javascript thare human readable text that does not rendered on the page, it is ignored by the interpreter&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;// single line&lt;br&gt;
/&lt;/em&gt; &lt;em&gt;/ multi- line comments *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;variable is a name storage for a value or data
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let firstName = "Risisng"
let surname = "heloo"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Uses of JavaScript
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Adds interactivity to web pages&lt;/li&gt;
&lt;li&gt;Run codes in response to certain events&lt;/li&gt;
&lt;li&gt;JavaScript has a powerful Application Programming Interface (APIs), hence access to numerous complex features&lt;/li&gt;
&lt;li&gt;What is even more exciting however is the functionality built on top of the client-side JavaScript language. So-called Application Programming Interfaces (APIs) provide you with extra superpowers to use in your JavaScript code.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;APIs are ready-made sets of code building blocks that allow a developer to implement programs that would otherwise be hard or impossible to implement. They do the same thing for programming that ready-made furniture kits do for home building.&lt;br&gt;
There are two types of APIs available:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1.Browser APIs: Built and shipped with Browsers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2.Third party APIs: Not built into the browser by default, and you generally have to grab their code and information from somewhere on the Web. For example: Google maps API, Twitter API&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript can run on:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Browsers, using the JavaScript Virtual Machine (JVM).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Servers, using runtimes like Nodejs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Any devices that have the Javascript engine&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  JS Execution
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.&lt;/li&gt;
&lt;li&gt;The browser has an embedded engine sometimes called a “JavaScript virtual machine”. Different engines have different “names” for their JVM. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;The terms above are good to remember because they are used in developer articles on the internet. We’ll use them too. For instance, if “a feature X is supported by V8”, then it probably works in Chrome, Opera and Edge.&lt;br&gt;
Different platforms have different “names” for their JVM&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;V8 – in Chrome, Opera and Edge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SpiderMonkey – in Firefox.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chakra” for IE&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nitro” and “SquirrelFish” for Safari, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Embedding JS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript is applied to your HTML page in a similar manner to CSS. Whereas CSS uses &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; elements to apply external stylesheets and &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; elements to apply internal stylesheets to HTML, JavaScript only needs one friend in the world of HTML — the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Adding JavaScript to your Webpage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Internal JavaScript: JS code added inside HTML files&lt;/li&gt;
&lt;li&gt;External JavaScript: External JS code linked in HTML file&lt;/li&gt;
&lt;li&gt;Internal Javascript&lt;/li&gt;
&lt;li&gt;Write and run JS inline HTML by saving the file and loading in the browser.&lt;/li&gt;
&lt;li&gt;Order matters, so if you add the script before the button, you get an error. Show an example here&lt;/li&gt;
&lt;li&gt;Show an example of  the “DOMContentLoaded” event. Order does not matter here, as script code is executed after HTML content is loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  External Javascript
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;This is generally a good thing in terms of organizing your code and making it reusable across multiple HTML files. Plus, the HTML is easier to read without huge chunks of script dumped in it.&lt;/li&gt;
&lt;li&gt;Note the defer option? I does the same thing as the “DOMContentLoaded” &lt;/li&gt;
&lt;li&gt;Order matters when loading scripts. Show examples.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Statements are syntax constructs and commands that perform actions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We’ve already seen a statement, &lt;code&gt;alert(‘Hello, world!’)&lt;/code&gt;, which shows the message “Hello, world!”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can have as many statements in our code as we want. Statements can be separated with a semicolon.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A semicolon may be omitted in most cases when a line break exists.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript interprets the line break as an “implicit” semicolon. This is called an automatic semicolon insertion.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Comments
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Comments are used to describe code.&lt;/li&gt;
&lt;li&gt;As time goes on, programs become more and more complex. It becomes necessary to add comments which describe what the code does and why.&lt;/li&gt;
&lt;li&gt;Comments can be put into any place of a script. They don’t affect its execution because the engine simply ignores them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A variable is a “named storage” for values or data&lt;/li&gt;
&lt;li&gt;Use real-life analogy of a named ingredients in a kitchen&lt;/li&gt;
&lt;li&gt;JavaScript application needs to work with information. E.g Catalogue list holding shopping items, Chat application holding messages, names etc&lt;/li&gt;
&lt;li&gt;Create a variable using the let and const keyword. We’ll take about their difference later.&lt;/li&gt;
&lt;li&gt;Can declare multiple variables in single line separated by comma&lt;/li&gt;
&lt;li&gt;Talk about var and its availability in older script. Discourage it’s usage&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Variables (Naming conventions)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The name must contain only &lt;strong&gt;letters, digits, or the symbols&lt;/strong&gt; *&lt;em&gt;$ and _ *&lt;/em&gt;. Required&lt;/li&gt;
&lt;li&gt;The first character must not be a digit. Required&lt;/li&gt;
&lt;li&gt;Use camelCase when variables contain multiple words Optional
Case matters: Variables named apple and AppLE are two different variables.&lt;/li&gt;
&lt;li&gt;Reserved Names/Keyword cannot be used. E.g let let = 5; let return = 5; &lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Variables (const)
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared with const do not change and cannot be re-assigned&lt;/li&gt;
&lt;li&gt;It is a convention in JS to CAPITALIZE const variable names&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Separate multiple words with under_score&lt;/p&gt;
&lt;h5&gt;
  
  
  Variables (let)
&lt;/h5&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variables declared with let can change and be re-assigned&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variable names should be descriptive and it’s intention should be clear&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is recommended to use camelCase for long variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A variable name should have a clean, and meaning obvious.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variable naming is one of the most important and complex skills in programming.&lt;br&gt;
Some good-to-follow rules are:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use human-readable names like userName or shoppingCart.&lt;br&gt;
Rarely use abbreviations or short names like a, b, c&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make names maximally descriptive and concise. Examples of bad names are data and value..&lt;br&gt;
Agree on terms within your team and in your own mind. If a site visitor is called a “user” then we should name related variables currentUser or newUser instead of currentVisitor or newManInTown.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Data Types
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;A value in JavaScript is always of a certain type. e.g, string, number.&lt;/li&gt;
&lt;li&gt;There are &lt;strong&gt;eight (8)&lt;/strong&gt; basic data types in JavaScript, these are:&lt;/li&gt;
&lt;li&gt;&lt;p&gt;number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;bigInt&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;boolean&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;null&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;undefined&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;object&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;symbol&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can put any type in a variable. For example, a variable can at one moment be a string and then store a number: let message = “hello”; message = 123456;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programming languages that allow such things, such as JavaScript, are called “dynamically typed”, meaning that there exist data types, but variables are not bound to any of them.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Data types (number)
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;The number type represents both integer (without a decimal) and floating point numbers( with decimal).&lt;/em&gt; are referred to as number and not differentiated&lt;/li&gt;
&lt;li&gt;The following operations work on numbers:  multiplication *, division /, addition +, subtraction -.&lt;/li&gt;
&lt;li&gt;There are “special numeric values” which also belong to this data type: &lt;strong&gt;Infinity, -Infinity and NaN.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Infinity represents the mathematical Infinity ∞. e.g divide by 0&lt;br&gt;
NaN represents a computational error. It is a result of an incorrect or an undefined mathematical operation, for instance: console.log(“name” / 2)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NaN is sticky. Any further mathematical operation on NaN returns NaN&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So, if there’s a NaN somewhere in a mathematical expression, it propagates to the whole result (there’s only one exception to that: NaN ** 0 is 1).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Doing maths is “safe” in JavaScript. We can do anything: divide by zero, treat non-numeric strings as numbers, etc. The script will never stop with a fatal error (“die”). At worst, we’ll get NaN as the result.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Data types (BigInt)
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;The bigInt type represents extremely large or small integers which cannot be represented by the number type.&lt;/li&gt;
&lt;li&gt;The maximum and minimum size for a number type is (253-1) and -(253-1)&lt;/li&gt;
&lt;li&gt;This number type is enough for many purpose, so the bigInt type is rarely used.&lt;/li&gt;
&lt;li&gt;A BigInt is created by adding n to the end of a number or using the BigInt constructor
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Numbers
let size_in_meters = 20
let size_in_inches = 2.1024
let maxSize = Infinity
let minSize = -Infinity
let not_a_number = NaN

let sum = 20 + 23.1; let difference = 20 - 10;
let multiplication_result = 20 * 10; let division_result = 20 / 2;



//BigInt
let very_big_number = 872765678901234567890123567890134567890n;
let another_big_number = BigInt(872765678901234567890123567890134567890)

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

&lt;/div&gt;



&lt;h5&gt;
  
  
  Data types (Boolean)-P
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;-The boolean type has only two values: true and false.&lt;/li&gt;
&lt;li&gt;This type is commonly used to store yes/no values: true means “yes, correct”, and false means “no, incorrect”.&lt;/li&gt;
&lt;li&gt;Boolean values are mostly gotten from comparisons:&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Data types (null)-P
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;The value null represents the intentional absence of a value&lt;/li&gt;
&lt;li&gt;The null type is a special value which represents “nothing”, “emptiness” or “value unknown”.&lt;/li&gt;
&lt;li&gt;Note that type of null is object for legacy reasons&lt;/li&gt;
&lt;li&gt;An unassigned variable is automatically set to type null&lt;/li&gt;
&lt;li&gt;Use null to assign an “empty” or “unknown” value to a variable&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Data types (undefined)-P
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;The value undefined means a value is not assigned&lt;/li&gt;
&lt;li&gt;A declared variable without assigned values becomes undefined by default&lt;/li&gt;
&lt;li&gt;Show example of type of undefined&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Data types (object)- NP
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Objects are one of the most important data type in JavaScript&lt;/li&gt;
&lt;li&gt;Objects are used to store keyed-value pair collections of data and more complex entities.&lt;/li&gt;
&lt;li&gt;All other types are called “primitive” because their values can contain only a single value&lt;/li&gt;
&lt;li&gt;Objects are associative arrays with several special features. They store properties (key-value pairs), where:&lt;/li&gt;
&lt;li&gt;You can retrieve values using dot notation or with square brackets&lt;/li&gt;
&lt;li&gt;Objects are store any valid JavaScript type including objects themselves&lt;/li&gt;
&lt;li&gt;delete a property: delete obj.prop.
&lt;code&gt;let user = {};&lt;/code&gt;
&lt;code&gt;let user = new Object();&lt;/code&gt;
&lt;code&gt;user.age = 20&lt;/code&gt;
&lt;code&gt;user["emailVerify"] = false&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;delete user.emailVerify;&lt;/code&gt;&lt;br&gt;
to call the entire object&lt;/p&gt;

&lt;p&gt;console.log(Object.values(user)) // it print all values&lt;br&gt;
console.log(Object.keys(user)) // it print all values&lt;/p&gt;

&lt;p&gt;you can also have imbedded array &lt;/p&gt;

&lt;h5&gt;
  
  
  Data types (String)
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;A String type is used to represent and manipulate a sequence of characters.&lt;/li&gt;
&lt;li&gt;A string type must be surrounded by quotes or backticks. &lt;/li&gt;
&lt;li&gt;Double and single quotes are “simple” quotes. There’s practically no difference between them in JavaScript.&lt;/li&gt;
&lt;li&gt;Backticks are “extended functionality” quotes. They allow us to embed variables and expressions into a string by wrapping them in ${…}&lt;/li&gt;
&lt;li&gt;Other quotes don’t have this embedding functionality.&lt;/li&gt;
&lt;li&gt;Strings are special types, and therefore have extra functionalities built on it. &lt;/li&gt;
&lt;li&gt;You can call methods on strings to do special things like the examples below&lt;/li&gt;
&lt;li&gt;You can use special characters in strings, like the new line character (n)&lt;/li&gt;
&lt;li&gt;Other special characters are ‘, “, , t, u{1F60D}.  Show some examples in console&lt;/li&gt;
&lt;li&gt;/n, //, /r, -&amp;gt; special character&lt;/li&gt;
&lt;li&gt;Access single characters in strings using subseting a[0]&lt;/li&gt;
&lt;li&gt;Strings are immutable, you can’t change a character&lt;/li&gt;
&lt;li&gt;Get substrings with slice&lt;/li&gt;
&lt;li&gt;function and method are called to perform specific task&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Basic Operator
&lt;/h5&gt;

&lt;p&gt;Terminologies&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An operator is a reserved syntax consisting of punctuation or alphanumeric characters that carries out built-in functionality. e.g addition operator (“+“), subtraction operator (“–“). &lt;/li&gt;
&lt;li&gt; An operator can be unary or binary. e.g +&lt;/li&gt;
&lt;li&gt; An operand – is what operators are applied to. e.g the values that is act on&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;types of operator&lt;br&gt;
operator can be unary, binary or ternary&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unary acts on single operand&lt;/li&gt;
&lt;li&gt;binary acts on 2 operand&lt;/li&gt;
&lt;li&gt;ternary acts on 3 operand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Math operators&lt;br&gt;
Mathematical operation&lt;/p&gt;

&lt;p&gt;The following math operations are supported in JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Addition +, &lt;/li&gt;
&lt;li&gt;Subtraction -,&lt;/li&gt;
&lt;li&gt;Multiplication * asterick,&lt;/li&gt;
&lt;li&gt;Division / backwardlash,&lt;/li&gt;
&lt;li&gt;Remainder % modulus,&lt;/li&gt;
&lt;li&gt;Exponentiation ** raised to power&lt;/li&gt;
&lt;li&gt;Remember If an expression has more than one operator, the execution order is defined by their precedence, or, in other words, the default priority order of operators.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;binary + is applied to strings, it merges (concatenates) them:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We know many operators from school. They are things like addition +, multiplication *, subtraction -, and so on. Show examples&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remember If an expression has more than one operator, the execution order is defined by their precedence, or, in other words, the default priority order of operators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parentheses override any precedence, so if we’re not satisfied with the default order, we can use them to change it. For example, write (1 + 2) * 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let’s meet features of JavaScript operators that are beyond school arithmetics. So operators like addition works for strings. Show example&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;if the binary + is applied to strings, it merges (concatenates) them:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, let’s talk about JavaScript-specific operators, not covered by school arithmetic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Comparison operators
&lt;/h4&gt;

&lt;p&gt;This is used to check if two number are equal or not they return boolean values either true or false&lt;/p&gt;

&lt;p&gt;Comparison operators are used to apply boolean logic to operands. E.g&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Greater than: a &amp;gt; b&lt;/li&gt;
&lt;li&gt;Less than: a &amp;lt; b&lt;/li&gt;
&lt;li&gt;Greater or equals: a &amp;gt;= b&lt;/li&gt;
&lt;li&gt;Less than or equals: a &amp;lt;= b&lt;/li&gt;
&lt;li&gt;Equals: a == b, &lt;/li&gt;
&lt;li&gt;Strict Equality a === b e.g 0 === false&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not equals: a != b&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;All comparison operators return a boolean value&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To see whether a string is greater than another, JavaScript uses the so-called “dictionary” or “lexicographical” order. In other words, strings are compared letter-by-letter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Please note the double equality sign == means the equality test, while a single one a = b means an assignment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To see whether a string is greater than another, JavaScript uses the so-called “dictionary” or “lexicographical” order. In other words, strings are compared letter-by-letter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When comparing values of different types, JavaScript converts the values to numbers. alert( ‘2’ &amp;gt; 1 )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For boolean values, true becomes 1 and false becomes 0.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A regular equality check == has a problem. It cannot differentiate 0 from false: 0 == false // true,  ” == false. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These are JavaScript false values. Use a strict equality check instead. (0 === false ); // false, because the types are different&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other operators&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The assignment operator (“=”) is used to assign values to a variable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The increment (“++”) and decrement (“–“) operators&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bitwise operators  : AND ( &amp;amp; ), OR ( | ), XOR ( ^ ), NOT ( ~ ), LEFT SHIFT ( &amp;lt;&amp;lt; ), RIGHT SHIFT ( &amp;gt;&amp;gt; ), etc &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assignment = is also an operator. It is listed in the precedence table with the very low priority.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bitwise operators are used very rarely, when we need to fiddle with numbers on the very lowest (bitwise) level. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let’s note that an assignment = is also an operator. It is listed in the precedence table with the very low priority of 2. That’s why, when we assign a variable, like x = 2 * 2 + 1, the calculations are done first and then the = is evaluated, storing the result in x.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increasing or decreasing a number by one is among the most common numerical operations. So, there are special operators for it:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Bitwise operators are used very rarely, when we need to fiddle with numbers on the very lowest (bitwise) level. We won’t need these operators any time soon, as web development has little use of them, but in some special areas, such as cryptography, they are useful. You can read the Bitwise Operators chapter on MDN when a need arises.&lt;/p&gt;
&lt;h5&gt;
  
  
  Conditional branching (if)
&lt;/h5&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;day&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monday&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monday&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monday&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;OR&lt;/span&gt; 

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;day&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monday&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Monday&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Sometimes, we need to perform different actions based on different conditions. To do that, we can use the if statement and the conditional operator&lt;/li&gt;
&lt;li&gt;The if(…) statement evaluates a condition and, if the result is true, executes a block of code.&lt;/li&gt;
&lt;li&gt;We recommend wrapping your code block with curly braces {} every time you use an if statement, even if there is only one statement to execute. Doing so improves readability.&lt;/li&gt;
&lt;li&gt;The if (…) statement evaluates the expression in its parentheses and converts the result to a boolean. if (0) { // 0 is falsy..} works because 0 is falsy&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Conditional branching (if-else)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The else clause may contain an optional block if code that evaluates when the condition is falsy&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Conditional branching (else-if)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Multiple else-if clause can be chained to test numerous conditions&lt;/li&gt;
&lt;li&gt;The final else is optional. When all else fails, it gets executed&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Conditional operator ( ? )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The conditional operator (? ) called the ternary operator can be used to assign values based on a condition&lt;/li&gt;
&lt;li&gt;The operator is represented by a question mark ?. Sometimes it’s called “ternary”, because the operator has three operands. It is actually the one and only operator in JavaScript which has that many.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Conditional branching (switch)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;A switch statement can replace multiple if checks. It gives a cleaner way of comparing a value with multiple variants. It has the following syntax:&lt;/li&gt;
&lt;li&gt;The switch has one or more case blocks and an optional default.&lt;/li&gt;
&lt;li&gt;The case check is a strict equality&lt;/li&gt;
&lt;li&gt;If the equality is found, switch starts to execute the code starting from the corresponding case, until the nearest break (or until the end of switch).&lt;/li&gt;
&lt;li&gt;If no case is matched then the default code is executed (if it exists).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Logical operators
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Logical operators available in JavaScript are: || (OR), &amp;amp;&amp;amp; (AND), ! (NOT)&lt;/li&gt;
&lt;li&gt;Although they are called “logical”, they can be applied to values of any type, not only boolean. Their result can also be of any type.&lt;/li&gt;
&lt;li&gt;OR==&amp;gt; If any of its arguments are true, it returns true, otherwise it returns false. Show examples with if statements&lt;/li&gt;
&lt;li&gt;If an operand is not a boolean, it’s converted to a boolean for the evaluation. For instance, the number 1 is treated as true, the number 0 as false: if (1 || 0) {…}&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops
&lt;/h4&gt;

&lt;p&gt;Loops are used to perform repeated actions based on a condition.&lt;/p&gt;

&lt;p&gt;In JavaScript there many types of loops:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The “while” loop&lt;/li&gt;
&lt;li&gt;The “do…while” loop&lt;/li&gt;
&lt;li&gt;The “for” loop&lt;/li&gt;
&lt;li&gt;The for…of loop&lt;/li&gt;
&lt;li&gt;The for…in loop&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops ( while )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The while loop has the following syntax&lt;/li&gt;
&lt;li&gt;While the condition is truthy, the code in the while loop body is executed.&lt;/li&gt;
&lt;li&gt;A single execution of the loop body is called an iteration. The loop in the example above makes three iterations.&lt;/li&gt;
&lt;li&gt;If i++ was missing from the example above, the loop would repeat (in theory) forever. In practice, the browser provides ways to stop such loops, and in server-side JavaScript, we can kill the process.&lt;/li&gt;
&lt;li&gt;Any expression or variable can be a loop condition, not just comparisons: the condition is evaluated and converted to a boolean.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops ( do…while )
&lt;/h4&gt;

&lt;p&gt;The do…while loop has the following syntax&lt;br&gt;
This is similar to while loop. The condition check is just moved below the loop body using the do..while syntax:&lt;br&gt;
This means the code is run at least once before the loop start.&lt;/p&gt;

&lt;h4&gt;
  
  
  Loops ( do…while )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The do…while loop has the following syntax&lt;/li&gt;
&lt;li&gt;This is similar to while loop. The condition check is just moved below the loop body using the do..while syntax:&lt;/li&gt;
&lt;li&gt;This means the code is run at least once before the loop start.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops ( for )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The for loop has the following syntax&lt;/li&gt;
&lt;li&gt;The for loop is more complex, but it’s also the most commonly used loop.&lt;/li&gt;
&lt;li&gt;If you are new to loops, it could help to go back to the example and reproduce how it runs step-by-step on a piece of paper.&lt;/li&gt;
&lt;li&gt;The “counter” variable i is declared right in the loop. This is called an “inline” variable declaration. Such variables are visible only inside the loop.&lt;/li&gt;
&lt;li&gt;we can force the exit at any time using the special break directive.&lt;/li&gt;
&lt;li&gt;The continue directive is a “lighter version” of break. It doesn’t stop the whole loop. Instead, it stops the current iteration and forces the loop to start a new one (if the condition allows).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops ( for…of )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The for…of loop is used to loop over iterable properties of an object. It has the following syntax&lt;/li&gt;
&lt;li&gt;The values of an iterable object can be iterated over, meaning they can counted. E.g Arrays, Maps, Set, Strings  (We will talk deeply about these in Data Structure section)&lt;/li&gt;
&lt;li&gt;On each iteration a value of a different property is assigned to variable. variable may be declared with const, let.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loops ( for…in )
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The for…in has the following syntax&lt;/li&gt;
&lt;li&gt;The for…in statement iterates over all enumerable properties of an object that are keyed by strings (ignoring ones keyed by Symbols), including inherited enumerable properties.&lt;/li&gt;
&lt;li&gt;Given that for…in is built for iterating object properties, not recommended for use with arrays, and options like Array.prototype.forEach() and for…of exist, what might be the use of for…in at all?&lt;/li&gt;
&lt;li&gt;It may be most practically used for debugging purposes, being an easy way to check the properties of an object&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Functions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition.&lt;/li&gt;
&lt;li&gt;You’ve seen lots of built-in functions like: alert, console.log, prompt, etc&lt;/li&gt;
&lt;li&gt;Quite often we need to perform a similar action in many places of the script. For example, we need to show a nice-looking message when a visitor logs in, logs out and maybe somewhere else.&lt;/li&gt;
&lt;li&gt;Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Functions Variables
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Local variables: These are variables declared inside a function is only visible inside that function.&lt;/li&gt;
&lt;li&gt;Outer variables: These are variables declared outside a function.&lt;/li&gt;
&lt;li&gt;The function has full access to the outer variable. It can modify it as well.&lt;/li&gt;
&lt;li&gt;An outer variable is only used if there’s no local one. If a same-named variable is declared inside the function then it shadows the outer one.&lt;/li&gt;
&lt;li&gt;Variables declared outside of any function, such as the outer userName in the code above, are called global.&lt;/li&gt;
&lt;li&gt;Global variables are visible from any function (unless shadowed by locals). It’s a good practice to minimize the use of global variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Functions Parameters
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Parameters are data passed to a function. These are passed in the function’s parenthesis ( ).&lt;/li&gt;
&lt;li&gt;We can pass arbitrary data to functions using parameters.&lt;/li&gt;
&lt;li&gt;When the function is called with arguments, the given values are copied to local variables. Then the function uses them.&lt;/li&gt;
&lt;li&gt;A parameter is the variable listed inside the parentheses in the function declaration (it’s a declaration time term)&lt;/li&gt;
&lt;li&gt;An argument is the value that is passed to the function when it is called (it’s a call time term).&lt;/li&gt;
&lt;li&gt;We declare functions listing their parameters, then call them passing arguments.&lt;/li&gt;
&lt;li&gt;If a function is called, but an argument is not provided, then the corresponding value becomes undefined.&lt;/li&gt;
&lt;li&gt;We can specify the so-called “default” (to use if omitted) value for a parameter in the function declaration, using =:. e.g function showMessage(from, text = “no text given”) &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Functions Returns
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;A function can return a value back into the calling code as the result.&lt;/li&gt;
&lt;li&gt;The directive return can be in any place of the function. When the execution reaches it, the function stops, and the value is returned to the calling code (assigned to result above).&lt;/li&gt;
&lt;li&gt;There may be many occurrences of return in a single function. For instance, an if..else block&lt;/li&gt;
&lt;li&gt;It is possible to use return without a value. That causes the function to exit immediately.&lt;/li&gt;
&lt;li&gt;If a function does not return a value, it is the same as if it returns undefined:&lt;/li&gt;
&lt;li&gt;If we want the returned multiple results, then  wrap them in parenthesis &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Functions Tips
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Functions are actions. So their name is usually a verb. e.g getUser, calculatePercent, addInterest, etc&lt;/li&gt;
&lt;li&gt;A function should do exactly what is suggested by its name, no more.&lt;/li&gt;
&lt;li&gt;Functions should be short and do exactly one thing. If that thing is big, maybe it’s worth it to split the function into a few smaller functions&lt;/li&gt;
&lt;li&gt;Two independent actions usually deserve two functions, even if they are usually called together&lt;/li&gt;
&lt;li&gt;A function is similar to a comment. That is, it should be self descriptive from it’s name and usage&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Function Expression
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;There is another syntax for creating a function that is called a Function Expression. It allows us to create a new function in the middle of any expression.&lt;/li&gt;
&lt;li&gt;The syntax that we used before is called a Function Declaration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Callback functions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Functions are like values, and they can be assigned, as well as passed around just like variables&lt;/li&gt;
&lt;li&gt;In practice, such functions are quite useful&lt;/li&gt;
&lt;li&gt;The arguments showFullName and showUserName of displayUser are called callback functions or just callbacks.&lt;/li&gt;
&lt;li&gt;The idea is that we pass a function and expect it to be “called back” later if necessary. In our case, showFullName becomes the callback for display type “full”, and showUserName as opposite.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Arrow Functions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;There’s another very simple and concise syntax for creating functions, that’s often better than Function Expressions.&lt;/li&gt;
&lt;li&gt;It’s called “arrow functions”, because it looks like this&lt;/li&gt;
&lt;li&gt;Arrow functions can be used in the same way as Function Expressions.&lt;/li&gt;
&lt;li&gt;Arrow functions may appear unfamiliar and not very readable at first, but that quickly changes as the eyes get used to the structure.&lt;/li&gt;
&lt;li&gt;They are very convenient for simple one-line actions&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Scopes &amp;amp; Closures
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Scope in JavaScript refers to the current context of code, which determines the accessibility of variables to JavaScript. The two types of scope are local and global:&lt;/li&gt;
&lt;li&gt;Global variables are those declared outside of a block&lt;/li&gt;
&lt;li&gt;Local variables are those declared inside of a block&lt;/li&gt;
&lt;li&gt;A closure is a function that remembers its outer variables and can access them. In JS  all functions are naturally closures&lt;/li&gt;
&lt;li&gt;All functions and Objects have access to a Global scope.&lt;/li&gt;
&lt;li&gt;If a variable is declared inside a code block {…}, it’s only visible inside that block.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Arrays are used to store ordered collections.&lt;/li&gt;
&lt;li&gt;There are two syntaxes for creating an empty array:&lt;/li&gt;
&lt;/ul&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%2Fu8tsxqj5xfmzsmt46l8t.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%2Fu8tsxqj5xfmzsmt46l8t.png" alt="Image description" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Almost all the time, the second syntax is used. We can supply initial elements in the brackets:&lt;/li&gt;
&lt;li&gt;Array elements are numbered, starting with zero. We can get an element by its number in square brackets:&lt;/li&gt;
&lt;li&gt;An array can store elements of any type. Objects, functions, etc&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Array Method
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Array methods are functions we can call on an array&lt;/li&gt;
&lt;li&gt;There are lots of methods built into Arrays. See full list here&lt;/li&gt;
&lt;li&gt;You can loop over arrays with for, for…of, forEach&lt;/li&gt;
&lt;/ul&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%2Fxgdh2knf398pf54rao5w.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%2Fxgdh2knf398pf54rao5w.png" alt="Image description" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The length property automatically updates when we modify the array. To be precise, it is actually not the count of values in the array, but the greatest numeric index plus one.&lt;/li&gt;
&lt;li&gt;Arrays can have items that are also arrays. We can use it for multidimensional arrays, for example to store matrices:&lt;/li&gt;
&lt;/ul&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%2Fx1tadg2nkevkt38dqp1i.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%2Fx1tadg2nkevkt38dqp1i.png" alt="Image description" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays can have items that are also arrays. We can use it for multidimensional arrays, for example to store matrices:&lt;/li&gt;
&lt;li&gt;Other popular array methods are map, slice, and splice&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Sets
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;A Set is a special type collection – “set of values” (without keys), where each value may occur only once.&lt;/li&gt;
&lt;li&gt;Set has the following methods and properties:&lt;/li&gt;
&lt;li&gt;set.add(value) – adds a new value and returns the set&lt;/li&gt;
&lt;li&gt;set.delete(value) – removes the value.&lt;/li&gt;
&lt;li&gt;set.clear() – removes everything from the set.&lt;/li&gt;
&lt;li&gt;set.has(value) – returns true if the value exists, false otherwise.&lt;/li&gt;
&lt;li&gt;set.size – returns the set element count.&lt;/li&gt;
&lt;/ul&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%2Fzpy35qlf4fij102lz55k.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%2Fzpy35qlf4fij102lz55k.png" alt="Image description" width="767" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The main feature is that repeated calls of set.add(value) with the same value don’t do anything. That’s the reason why each value appears in a Set only once.&lt;/li&gt;
&lt;li&gt;For example, we have visitors coming, and we’d like to remember everyone. But repeated visits should not lead to duplicates. A visitor must be “counted” only once. Set is just the right thing for that:&lt;/li&gt;
&lt;li&gt;We can loop over a set either with for..of or using forEach&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Destructuring assignment
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Destructuring assignment is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables, as sometimes that’s more convenient.&lt;/li&gt;
&lt;li&gt;Destructuring also works great with complex functions that have a lot of parameters, default values, and so on. Soon we’ll see that.&lt;/li&gt;
&lt;/ul&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%2F7y7afcexfnlrc54lc98k.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%2F7y7afcexfnlrc54lc98k.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It’s called “destructuring assignment,” because it “destructurizes” by copying items into variables. But the array itself is not modified. let firstName = arr[0];&lt;/li&gt;
&lt;li&gt;Unwanted elements of the array can also be thrown away via an extra comma: let [firstName, , title] = [“Julius”, “Caesar”, “Consul”, “of the Roman Republic”]; In the code above, the second element of the array is skipped, the third one is assigned to title, and the rest of the array items is also skipped (as there are no variables for them).&lt;/li&gt;
&lt;li&gt;We can use it with any iterable, not only arrays: let [a, b, c] = “abc”; // [“a”, “b”, “c”]&lt;/li&gt;
&lt;li&gt;The order of destructuring in objects does not matter&lt;/li&gt;
&lt;li&gt;If we have a complex object with many properties, we can extract only what we need.&lt;/li&gt;
&lt;li&gt;If an object or an array contain other nested objects and arrays, we can use more complex left-side patterns to extract deeper portions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dom &amp;amp; Dom Manipulation
&lt;/h3&gt;

&lt;p&gt;Browser specification&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web browsers give a means to control web pages.&lt;/li&gt;
&lt;li&gt;There’s a “root” object called window. It has two roles:&lt;/li&gt;
&lt;li&gt;First, it is a global object for JavaScript code, as described in the chapter Global object.&lt;/li&gt;
&lt;li&gt;Second, it represents the “browser window” and provides methods to control it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, here we use it as a global object: alert(window.innerHeight); // inner window height&lt;br&gt;
DOM&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%2Fx7u9ubxun70q41hoys12.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%2Fx7u9ubxun70q41hoys12.png" alt="Image description" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Document Object Model, or DOM for short, represents all web page content as objects that can be modified.&lt;/li&gt;
&lt;li&gt;The document object is the main “entry point” to the page. We can change or create anything on the page using it.&lt;/li&gt;
&lt;li&gt;Properties and methods are described in the specification: DOM Living Standard.&lt;/li&gt;
&lt;li&gt;An HTML/XML document is represented inside the browser as the DOM tree.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  DOM Tree
&lt;/h4&gt;

&lt;p&gt;All HTML tag in a page is an object. Nested tags are “children” of the enclosing one. The text inside a tag is an object as well.&lt;br&gt;
The Dom tree is a large object representing all page tags. You can see the Dom tree of page by inspecting the page in the developer console&lt;/p&gt;

&lt;p&gt;DOM Tree&lt;br&gt;
The backbone of an HTML document is tags.&lt;br&gt;
For example, document.body is the object representing the &lt;/p&gt; tag. Run this code : document.body.style.background = “red”&lt;br&gt;
DOM nodes have properties and methods that allow us to travel between them, modify them, move around the page, and more. We’ll get down to them in the next chapters.

&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%2Fuzz20z5ha5jqlok2ri9x.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%2Fuzz20z5ha5jqlok2ri9x.png" alt="Image description" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The DOM allows us to do anything with elements and their contents, but first we need to reach the corresponding DOM object.&lt;/li&gt;
&lt;li&gt;All operations on the DOM start with the document object. That’s the main “entry point” to DOM. From it we can access any node.&lt;/li&gt;
&lt;/ul&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%2Fy3gtgx4kighe71qfm76h.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%2Fy3gtgx4kighe71qfm76h.png" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;DOM Navigation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The topmost tree nodes are available directly as document properties:  = document.documentElement&lt;/li&gt;
&lt;li&gt; = document.body&lt;/li&gt;
&lt;li&gt;Child nodes (or children) – elements that are direct children. In other words, they are nested exactly in the given one. For instance,  and  are children of  element.&lt;/li&gt;
&lt;li&gt;Descendants – all elements that are nested in the given one, including children, their children and so on.&lt;/li&gt;
&lt;li&gt;The childNodes collection lists all child nodes, including text nodes. Show example of listing child nodes&lt;/li&gt;
&lt;li&gt;Searching&lt;/li&gt;
&lt;li&gt;There are additional searching methods for that. These are:&lt;/li&gt;
&lt;li&gt;document.getElementById or just id&lt;/li&gt;
&lt;li&gt;querySelectorAll: returns all elements inside elem matching the given CSS selector.&lt;/li&gt;
&lt;li&gt;querySelector: The call to elem.querySelector(css) returns the first element for the given CSS selector&lt;/li&gt;
&lt;li&gt;elem.getElementsByClassName:  returns elements that have the given CSS class.&lt;/li&gt;
&lt;li&gt;elem.getElementsByTagName: looks for elements with the given tag and returns the collection of them. The tag parameter can also be a star “*” for “any tags”.&lt;/li&gt;
&lt;li&gt;The id must be unique. There can be only one element in the document with the given id. If there are multiple elements with the same id, then the behavior of methods that use it is unpredictable&lt;/li&gt;
&lt;li&gt;Only document.getElementById, not anyElem.getElementById&lt;/li&gt;
&lt;li&gt;This method querySelectorAll  is indeed powerful, because any CSS selector can be used.&lt;/li&gt;
&lt;li&gt;The call to elem.querySelector(css) returns the first element for the given CSS selector. In other words, the result is the same as elem.querySelectorAll(css)[0], but the latter is looking for all elements and picking one, while elem.querySelector just looks for one. So it’s faster and also shorter to write.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  DOM modification
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;DOM modification is the key to creating “live” pages.&lt;/li&gt;
&lt;li&gt;To create DOM nodes, there are two methods:&lt;/li&gt;
&lt;li&gt;document.createElement(tag): Creates a new element node with the given tag:&lt;/li&gt;
&lt;li&gt;document.createTextNode(text): Creates a new text node with the given text:&lt;/li&gt;
&lt;li&gt;You can insert into the DOM using :   document.body.append(div). There are other variants like prepend, before, after, replaceWith. See&lt;/li&gt;
&lt;li&gt;To remove a node, there’s a method node.remove().&lt;/li&gt;
&lt;li&gt;The id must be unique. There can be only one element in the document with the given id. If there are multiple elements with the same id, then the behavior of methods that use it is unpredictable&lt;/li&gt;
&lt;li&gt;Only document.getElementById, not anyElem.getElementById&lt;/li&gt;
&lt;li&gt;This method querySelectorAll  is indeed powerful, because any CSS selector can be used.&lt;/li&gt;
&lt;li&gt;The call to elem.querySelector(css) returns the first element for the given CSS selector. In other words, the result is the same as elem.querySelectorAll(css)[0], but the latter is looking for all elements and picking one, while elem.querySelector just looks for one. So it’s faster and also shorter to write.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dom Events &amp;amp; Events Handlers&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An event is a signal that something has happened. All DOM nodes generate such signals (but events are not limited to DOM).&lt;/li&gt;
&lt;li&gt;The following events can be tracked in the DOM:&lt;/li&gt;
&lt;li&gt;Mouse events: E.g click, mouseover, mouseup&lt;/li&gt;
&lt;li&gt;Keyboard events: E.g keydown, keyup&lt;/li&gt;
&lt;li&gt;Form element events: E.g submit, focus&lt;/li&gt;
&lt;li&gt;Document events: E.g DOMContentLoaded&lt;/li&gt;
&lt;li&gt;CSS events: E.g transitions&lt;/li&gt;
&lt;li&gt;Almost all the time, the second syntax is used. We can supply initial elements in the brackets:&lt;/li&gt;
&lt;li&gt;Array elements are numbered, starting with zero. We can get an element by its number in square brackets:&lt;/li&gt;
&lt;li&gt;An array can store elements of any type. Objects, functions, etc&lt;/li&gt;
&lt;li&gt;To react on events we can assign a handler – a function that runs in case of an event.&lt;/li&gt;
&lt;li&gt;We can set event handlers using:&lt;/li&gt;
&lt;li&gt;HTML Attributes: A handler can be set in HTML with an attribute named on.&lt;/li&gt;
&lt;li&gt;DOM property: We can assign a handler using a DOM property on.&lt;/li&gt;
&lt;li&gt;Methods event listeners. Explained in next slide&lt;/li&gt;
&lt;/ul&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%2Fkywhm795qb6zuf6gswn6.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%2Fkywhm795qb6zuf6gswn6.png" alt="Image description" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Event Handlers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Handlers are a way to run JavaScript code in case of user actions. There &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;are several ways to assign a handler. Let’s see them, starting from the simplest one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For instance, to assign a click handler for an input, we can use onclick, like here: On mouse click, the code inside onclick runs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Please note that inside onclick we use single quotes, because the attribute itself is in double quotes. If we forget that the code is inside the attribute and use double quotes inside, like this: onclick=”alert(“Click!”)”, then it won’t work right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An HTML-attribute is not a convenient place to write a lot of code, so we’d better create a JavaScript function and call it there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we know, HTML attribute names are not case-sensitive, so ONCLICK works as well as onClick and onCLICK… But usually attributes are lowercased: onclick.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the handler is assigned using an HTML-attribute then the browser reads it, creates a new function from the attribute content and writes it to the DOM property.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Event Listeners, Event Object
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Listeners can be attached to Dom elements, and will fire if the event happens&lt;/li&gt;
&lt;li&gt;You can use addEventListener to assign multiple event handlers to an element&lt;/li&gt;
&lt;li&gt;removeEventListener can be used to remove an event listener from an element&lt;/li&gt;
&lt;/ul&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%2Fvzvebfe11djc09nitjcj.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%2Fvzvebfe11djc09nitjcj.png" alt="Image description" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Event Listeners
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using event handlers, you cannot attach more than one handler to an attribute. The fundamental problem of the aforementioned ways to assign handlers – we can’t assign multiple handlers to one event.&lt;/li&gt;
&lt;li&gt;Developers of web standards understood that long ago and suggested an alternative way of managing handlers using special methods addEventListener and removeEventListener. They are free of such a problem.&lt;/li&gt;
&lt;li&gt;When an event happens, the browser creates an event object, puts details into it and passes it as an argument to the handler.&lt;/li&gt;
&lt;li&gt;Some properties of the event object are:  event.id, event.type, event.name etc. See full list here&lt;/li&gt;
&lt;/ul&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%2Fpn1wuhk2yecnn0k30stt.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%2Fpn1wuhk2yecnn0k30stt.png" alt="Image description" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Event Object
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To properly handle an event we’d want to know more about what’s happened. Not just a “click” or a “keydown”, but what were the pointer coordinates? Which key was pressed? And so on.&lt;/li&gt;
&lt;li&gt;When an event happens, the browser creates an event object, puts details into it and passes it as an argument to the handler.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors.&lt;br&gt;
Bubbling is convenient. Don’t stop it without a real need: obvious and architecturally well thought out.&lt;br&gt;
To stop bubbling, use the method event.stopPropagation().&lt;br&gt;
Almost all events bubble. One exception is the focus event.&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%2Flnu3mc242yaf0ffcmc2y.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%2Flnu3mc242yaf0ffcmc2y.png" alt="Image description" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Event Bubbling
&lt;/h3&gt;

&lt;p&gt;To properly handle an event we’d want to know more about what’s happened. Not just a “click” or a “keydown”, but what were the pointer coordinates? Which key was pressed? And so on.&lt;br&gt;
When an event happens, the browser creates an event object, puts details into it and parses it as an argument to the handler.&lt;/p&gt;

&lt;h3&gt;
  
  
  Callback
&lt;/h3&gt;

&lt;p&gt;A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.&lt;br&gt;
This execution may be immediate as in a synchronous callback, or it might happen at a later point in time as in an asynchronous callback.&lt;br&gt;
What if the script loading fails? Our callback should be able to react on that.&lt;br&gt;
Multiple asynchronous call back can result in the callback hell. &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%2Fp9ik94xw2eid66g38li0.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%2Fp9ik94xw2eid66g38li0.png" alt="Image description" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Callbacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Many functions are provided by JavaScript host environments that allow you to schedule asynchronous actions. In other words, actions that we initiate now, but they finish later. For instance, one such function is the setTimeout function.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Luckily, there are other ways to avoid such pyramids. One of the best ways is to use “promises”, described in the next slide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Promise object returns a promise to supply the resulting value at some point in the future. So we can wait for it to keep the promise&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A promise can be in any of these state:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;pending: initial state, neither fulfilled nor rejected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fulfilled: meaning that the operation was completed successfully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;rejected: meaning that the operation failed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Feh21903cs9yb7t3ev1n4.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%2Feh21903cs9yb7t3ev1n4.png" alt="Image description" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Promise
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action’s eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.&lt;/li&gt;
&lt;li&gt;The methods promise.then(), promise.catch(), and promise.finally() are used to associate further action with a promise that becomes settled.&lt;/li&gt;
&lt;li&gt;Consuming functions can be registered (subscribed) using methods .then, .catch and .finally.&lt;/li&gt;
&lt;/ul&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%2Fmqfkhb6cw9chgndrughq.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%2Fmqfkhb6cw9chgndrughq.png" alt="Image description" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Consuming a Promise
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A Promise object serves as a link between the executor (the “producing code” or “singer”) and the consuming functions (the “fans”), which will receive the result or error. Consuming functions can be registered (subscribed) using methods .then, .catch and .finally.&lt;/li&gt;
&lt;li&gt;The first argument of .then is a function that runs when the promise is resolved, and receives the result.&lt;/li&gt;
&lt;li&gt;The call .finally(f) is similar to .then(f, f) in the sense that f always runs when the promise is settled: be it resolve or reject.&lt;/li&gt;
&lt;li&gt;A finally handler has no arguments. In finally we don’t know whether the promise is successful or not. That’s all right, as our task is usually to perform “general” finalizing procedures.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Async/Await
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;async/await are special syntax to work with promises in a more comfortable fashion.&lt;/li&gt;
&lt;li&gt;The word “async” before a function means one simple thing: a function always returns a promise. Other values are wrapped in a resolved promise automatically.&lt;/li&gt;
&lt;li&gt;The keyword await makes JavaScript wait until that promise settles and returns its result.&lt;/li&gt;
&lt;/ul&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%2Fxj4orfh677sio0ad0w11.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%2Fxj4orfh677sio0ad0w11.png" alt="Image description" width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;async/await&lt;/li&gt;
&lt;li&gt;await only works inside an async function. If we try to use await in a non-async function, there would be a syntax error:&lt;/li&gt;
&lt;li&gt;Show example of converting the chapter Promises chaining and rewrite it using async/await:&lt;/li&gt;
&lt;li&gt;If a promise resolves normally, then await promise returns the result. But in the case of a rejection, it throws the error, just as if there were a throw statement at that line. So handle errors with try..catch&lt;/li&gt;
&lt;li&gt;When we use async/await, we rarely need .then, because await handles the waiting for us. And we can use a regular try..catch instead of .catch. That’s usually (but not always) more convenient.&lt;/li&gt;
&lt;li&gt;But at the top level of the code, when we’re outside any async function, we’re syntactically unable to use await, so it’s a normal practice to add .then/catch to handle the final result or falling-through error, like in the line (*) of the example above.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  object-oriented programming (OOP)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods). (Wikipedia)&lt;/li&gt;
&lt;li&gt;This approach to programming is well-suited for programs that are large, complex and actively updated or maintained.&lt;/li&gt;
&lt;li&gt;OOP uses the concept of reusable templates (classes) which encapsulate actions (methods), and features (properties) in them. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Structure of OOP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The structure, or building blocks, of object-oriented programming include the following:&lt;/li&gt;
&lt;li&gt;Classes:  These are user-defined data types that act as the blueprint for individual objects, attributes and methods.&lt;/li&gt;
&lt;li&gt;Objects: These are instances of a class created with specifically defined data.&lt;/li&gt;
&lt;li&gt;Methods: These are functions that are defined inside a class that describe the behaviors of an object. &lt;/li&gt;
&lt;li&gt;Attributes: These are properties defined in the class template and represent the state of an object. &lt;/li&gt;
&lt;li&gt; Objects can correspond to real-world objects or an abstract entity. When class is defined initially, the description is the only object that is defined.&lt;/li&gt;
&lt;li&gt;Each method contained in class definitions starts with a reference to an instance object. Additionally, the subroutines contained in an object are called instance methods. Programmers use methods for reusability or keeping functionality encapsulated inside one object at a time.&lt;/li&gt;
&lt;li&gt;Objects will have data stored in the attributes field. Class attributes belong to the class itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Principles of OOP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Object-oriented programming is based on the following principles:&lt;/li&gt;
&lt;li&gt;Encapsulation: Important information is contained inside an object and only select information is exposed&lt;/li&gt;
&lt;li&gt;Abstraction: Reveal important features, hide unnecessary details&lt;/li&gt;
&lt;li&gt;Inheritance:  Classes can reuse, or extend code from other classes&lt;/li&gt;
&lt;li&gt;Encapsulation. This principle states that all important information is contained inside an object and only select information is exposed. The implementation and state of each object are privately held inside a defined class. Other objects do not have access to this class or the authority to make changes. They are only able to call a list of public functions or methods. This characteristic of data hiding provides greater program security and avoids unintended data corruption.&lt;/li&gt;
&lt;li&gt;Abstraction. Objects only reveal internal mechanisms that are relevant for the use of other objects, hiding any unnecessary implementation code. The derived class can have its functionality extended. This concept can help developers more easily make additional changes or additions over time.&lt;/li&gt;
&lt;li&gt;Inheritance. Classes can reuse code from other classes. Relationships and subclasses between objects can be assigned, enabling developers to reuse common logic while still maintaining a unique hierarchy. This property of OOP forces a more thorough data analysis, reduces development time and ensures a higher level of accuracy
.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Benefits of OOP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Benefits of OOP include:&lt;/li&gt;
&lt;li&gt;Modularity. Encapsulation enables objects to be self-contained, making troubleshooting and collaborative development easier.&lt;/li&gt;
&lt;li&gt;Reusability. Code can be reused through inheritance.&lt;/li&gt;
&lt;li&gt;Maintainability. Programs become easy to maintain and improve&lt;/li&gt;
&lt;li&gt;Security. Using encapsulation and abstraction, complex code is hidden&lt;/li&gt;
&lt;li&gt;Modularity. Encapsulation enables objects to be self-contained, making troubleshooting and collaborative development easier.&lt;/li&gt;
&lt;li&gt;Reusability. Code can be reused through inheritance, meaning a team does not have to write the same code multiple times.&lt;/li&gt;
&lt;li&gt;Productivity. Programmers can construct new programs quicker through the use of multiple libraries and reusable code.&lt;/li&gt;
&lt;li&gt;Easily upgradable and scalable. Programmers can implement system functionalities independently.&lt;/li&gt;
&lt;li&gt;Interface descriptions. Descriptions of external systems are simple, due to message passing techniques that are used for objects communication.&lt;/li&gt;
&lt;li&gt;Security. Using encapsulation and abstraction, complex code is hidden, software maintenance is easier and internet protocols are protected.&lt;/li&gt;
&lt;li&gt;Flexibility. Polymorphism enables a single function to adapt to the class it is placed in. Different objects can also pass through the same interface.&lt;/li&gt;
&lt;/ul&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%2Fmxu6fbpxsgu1wyh82ybh.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%2Fmxu6fbpxsgu1wyh82ybh.png" alt="Image description" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Inheritance
&lt;/h3&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%2F5rds9upt42yv36ma7n05.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%2F5rds9upt42yv36ma7n05.png" alt="Image description" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please click on this link to access the resource folder for this lesson.&lt;/p&gt;

&lt;p&gt;The following platforms allows you to write and run JavaScript without installing anything&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CodeSandBox&lt;/li&gt;
&lt;li&gt;CodePen&lt;/li&gt;
&lt;li&gt;JSFiddle&lt;/li&gt;
&lt;li&gt;Replit&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>How to Design Accessible Forms with HTML and CSS</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Mon, 06 Jan 2025 08:00:00 +0000</pubDate>
      <link>https://dev.to/motuncoded/how-to-design-accessible-forms-with-html-and-css-5c15</link>
      <guid>https://dev.to/motuncoded/how-to-design-accessible-forms-with-html-and-css-5c15</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Components of a form&lt;/li&gt;
&lt;li&gt;Accessible Forms with HTML&lt;/li&gt;
&lt;li&gt;Accessible Forms with CSS&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Forms are integral part in building a website. They are used to collect data from users when they submit their details. Forms are important in the interaction of users submitting their sign up form, login in form, subscribing to newsletter or sending message to receive feedback. Creating accessible forms is important to everyone especially the screen readers to fill the form without any problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  Components of a form
&lt;/h2&gt;

&lt;p&gt;A form is composed of different components such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;form&lt;/code&gt;&lt;/strong&gt;: this is the container that accept all other form elements like &lt;code&gt;input&lt;/code&gt; tag, submit &lt;code&gt;button&lt;/code&gt;, &lt;code&gt;textarea&lt;/code&gt;, &lt;code&gt;checkboxes&lt;/code&gt; and &lt;code&gt;radio button&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;input&lt;/code&gt;&lt;/strong&gt;: this is the HTML element that accepts the user details. The input tag is served depending on the purpose of input; text, number, password, email among other things
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"range"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"color"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"date"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;label&lt;/code&gt;&lt;/strong&gt;: this tag that give an outline of the detail to fill in an input. It associate with the input tag.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;textarea&lt;/code&gt;&lt;/strong&gt;: this is an multi-line input tag that accept 524,288 characters by default except the maxlength attribute is set up to a value. It is used to accept reviews, messages and comments from the users
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Message:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;select&lt;/code&gt;&lt;/strong&gt;: this element is for creating a dropdown in which the users are able to select one option by default or more options when the attribute &lt;code&gt;multiple&lt;/code&gt; is being used.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;select&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"country"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"country"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Select your country&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"ng"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Nigeria&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"usa"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;USA&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"canada"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Canada&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"uk"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;United Kingdom&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/select&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;checkbox&lt;/code&gt;&lt;/strong&gt;: this element allow users to select one or more options.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"subscribe"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"subscribe"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subscribe"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;button&lt;/code&gt;&lt;/strong&gt;: this tag will the users the opportunity to submit their details upon completion. These details are submitted to server.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Accessible forms with HTML
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Include sematic tags&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the right sematic tags such as &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;,&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;,&lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"type"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Always use label in your forms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives the screen readers access to input with ease. Using the &lt;code&gt;for&lt;/code&gt; Attribute in label element must match the &lt;code&gt;id&lt;/code&gt; of the input element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Username:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Proper use of Accessible Rich Internet Application (ARIA) attributes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples are aria-label, aria-labelledBy, aria-hidden, aria-describedBy, aria-required, aria-invalid, aria-placeholder, aria-expanded, aria-checked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;aria-label=&lt;/span&gt;&lt;span class="s"&gt;"add"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;+&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"profile"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Profile Information&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;aria-labelledby=&lt;/span&gt;&lt;span class="s"&gt;"profile"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Username:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ Don't over use them&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide clear instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This includes the guide before or while filling the form to outline the information that is relevant. it could be a hint inform of paragraph or a placeholder text.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide error message.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is essential to users which notify them that an error has been made. The error message should be descriptive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use HTML built-in validations in the forms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples are &lt;code&gt;required&lt;/code&gt;, &lt;code&gt;maxlength&lt;/code&gt;, &lt;code&gt;minlength&lt;/code&gt;,&lt;code&gt;pattern&lt;/code&gt;,&lt;code&gt;type&lt;/code&gt;,&lt;code&gt;min&lt;/code&gt; and  &lt;code&gt;max&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Username:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"quantity"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Quantity (1-10):&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"quantity"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"quantity"&lt;/span&gt; &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessible forms with CSS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make form responsive&lt;br&gt;
Create forms that are accessible across devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide focus inclined inputs&lt;br&gt;
This allow users to navigate the form properly.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#000080&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:valid&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#000080&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:invalid&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Hidden labels
If you don't want visual labels, style it to be visually-hidden or have class name of &lt;code&gt;sr-only&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;I hope you have been convinced on the proper way to create accessible forms using HTML and CSS. Until next time, Catch me on &lt;a href="https://x.com/motunadeneye/" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://www.linkedin.com/in/motunrayoadeneye/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>How to create lines with HTML canvas</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Tue, 31 Dec 2024 16:45:33 +0000</pubDate>
      <link>https://dev.to/motuncoded/how-to-create-lines-with-html-canvas-2o54</link>
      <guid>https://dev.to/motuncoded/how-to-create-lines-with-html-canvas-2o54</guid>
      <description>&lt;h3&gt;
  
  
  ━━━ Lines
&lt;/h3&gt;

&lt;p&gt;To draw a line with canvas, there are methods used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: This method is to start a new drawing path&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;moveTo(x, y)&lt;/code&gt;: This method is to specify the starting point of the line.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lineTo(x, y)&lt;/code&gt;: This method is to specify the end point of the line &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stroke()&lt;/code&gt;: This method is to add a stroke depending on the &lt;code&gt;strokeStyle&lt;/code&gt; to the line&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setLineDash([dash length, gap length])&lt;/code&gt;: This method is to create dash or dotted line with gap in between.
-``&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Diagonal line
&lt;/h4&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%2Fi5otasnlmikuojb0e1y2.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%2Fi5otasnlmikuojb0e1y2.png" alt="line" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Straight line
&lt;/h4&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%2Fx0lberermjioq9bzhnix.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%2Fx0lberermjioq9bzhnix.png" alt="straight line" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Vertical line
&lt;/h4&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%2Feb2kohlm8livqanqf6m4.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%2Feb2kohlm8livqanqf6m4.png" alt="Vertical" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Dashed line
&lt;/h4&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%2Fgmxlfq9qwxxf2gmw1ysk.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%2Fgmxlfq9qwxxf2gmw1ysk.png" alt="dashLine" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Dotted line
&lt;/h4&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%2F19xbs4vx7nayp6fq8imb.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%2F19xbs4vx7nayp6fq8imb.png" alt="dottedLine" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Parrallel lines
&lt;/h4&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%2Ftxj54hxeb8eif84du3rx.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%2Ftxj54hxeb8eif84du3rx.png" alt="parallel line" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Curved lines
&lt;/h4&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%2Fiifyvd8i0wnt8ms034hr.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%2Fiifyvd8i0wnt8ms034hr.png" alt="curved line" width="800" height="366"&gt;&lt;/a&gt;&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%2Fgul0mnlg2lfwzppfjy4j.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%2Fgul0mnlg2lfwzppfjy4j.png" alt="Curved line" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Zigzag
&lt;/h4&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%2F43tqfx6pet7tftekk9us.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%2F43tqfx6pet7tftekk9us.png" alt="zigzag" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I hope you have been able to see different lines using HTML canvas. Follow me to see more articles.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Concatenation in JavaScript</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Wed, 18 Dec 2024 21:04:15 +0000</pubDate>
      <link>https://dev.to/motuncoded/mastering-concatenation-in-javascript-178e</link>
      <guid>https://dev.to/motuncoded/mastering-concatenation-in-javascript-178e</guid>
      <description>&lt;p&gt;Hey there 👋, This article is for those who are getting started with concatenation or who are familiar with it. Let's dive in&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Concatenation is the joining of two or more strings together. It exist among strings. Concatenation is a fundamental concept that give clarity and readability especially when reused.&lt;br&gt;
In this guide, we will be exploring at different ways to concatenate strings.&lt;/p&gt;


&lt;h2&gt;
  
  
  Using &lt;code&gt;+&lt;/code&gt; operator
&lt;/h2&gt;

&lt;p&gt;This is the use of addition operator to concatenate string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Motunrayo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Adeneye&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;//MotunrayoAdeneye&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, there is no space between the name. To include space.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Motunrayo &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Adeneye&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="nx"&gt;Motunrayo&lt;/span&gt; &lt;span class="nx"&gt;Adeneye&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Alternatively&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Motunrayo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Adeneye&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="c1"&gt;//Motunrayo Adeneye&lt;/span&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using &lt;code&gt;+=&lt;/code&gt; operator
&lt;/h2&gt;

&lt;p&gt;This combines addition sign &lt;code&gt;+&lt;/code&gt; and assignment equator &lt;code&gt;=&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;frontend&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; developer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;//frontend developer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using template literals
&lt;/h2&gt;

&lt;p&gt;This requires the use of backtick &lt;code&gt;(&lt;/code&gt; &lt;code&gt;)&lt;/code&gt; to allow the use of declared variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Motunrayo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;about&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Hello, My name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. I am &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; years old`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;about&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//Hello, My name is Motunrayo. I am 30 years old&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using the &lt;code&gt;concat()&lt;/code&gt; method
&lt;/h2&gt;

&lt;p&gt;It is javascript built in method for combining string together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;word&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Java&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;script&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//Javascript&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using &lt;code&gt;join()&lt;/code&gt; method
&lt;/h2&gt;

&lt;p&gt;This method is used to join array that containing strings together&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;yellow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;//["red", "blue", "yellow"]&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//red, blue, yellow&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;p&gt;We've reached the end of this guide on string concatenation in JavaScript. I hope you’ve learned something new or reinforced your understanding of this essential concept.&lt;br&gt;
Got questions or comments? Feel free to share them below! 😊&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to create Subscribe to Newsletter with Reactjs and Supabase</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Tue, 17 Dec 2024 15:45:00 +0000</pubDate>
      <link>https://dev.to/motuncoded/how-to-create-subscribe-to-newsletter-with-reactjs-and-supabase-2c44</link>
      <guid>https://dev.to/motuncoded/how-to-create-subscribe-to-newsletter-with-reactjs-and-supabase-2c44</guid>
      <description>&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Setting Up the Project&lt;/li&gt;
&lt;li&gt;Configuring the Newsletter Subscription Table in Supabase&lt;/li&gt;
&lt;li&gt;Building the React Component&lt;/li&gt;
&lt;li&gt;Connecting React project to Supabase&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Subscribe to newsletter page allow users to input their emails in order to get newsletters from their favorite websites. For this project we will be using Reactjs and Supabase to implement this feature. Supabase is an open source tool that is alternative to Firebase, it is used in database management, authentication and real time updates because it provides hosted PostgreSQL database and also allows easy email validation. &lt;/p&gt;




&lt;h2&gt;
  
  
  Setting up the project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Node.js Installation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check if Node.js is installed in our project by running this command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OR&lt;/strong&gt;&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="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will output the version installed, if not, head to the Node.js website and download and install Node.js. The installment package is accompanied with a Node Package Manager(NPM).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2. Initialize Reactjs project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Set up Reactjs by installing it using Vite using this command on the terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create vite@latest

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

&lt;/div&gt;



&lt;p&gt;The following prompt will pop up and answer the question.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
√ Project name: ... newsletter-app
√ Select a framework: » React
√ Select a variant: » JavaScript + SWC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the instruction below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;newsletter-app
npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3. Set up the &lt;a href="https://supabase.com/" rel="noopener noreferrer"&gt;Supabase&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First you sign up for the supabase account, if you don't have one and create a new project. Run the command below to install the supabase client on the React project.&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; @supabase/supabase-js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the installation, check the package.json to see if it is properly installed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Configuring the Newsletter Subscription Table in Supabase
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the Supabase dashboard after you have created a project, go the the table editor to create a new table.&lt;/li&gt;
&lt;/ul&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%2Fd1sy18ywrpt5mz3q02px.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%2Fd1sy18ywrpt5mz3q02px.png" alt="Table editor" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Name the table &lt;code&gt;newsletter&lt;/code&gt; and add the following columns&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1.  &lt;code&gt;id&lt;/code&gt;: Primary key, UUID, default as uuid_generate_v4().&lt;/li&gt;
&lt;li&gt;2.  &lt;code&gt;email&lt;/code&gt;: Text, unique, required.&lt;/li&gt;
&lt;li&gt;3.  &lt;code&gt;created_at&lt;/code&gt;: Timestamp, default as now().&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&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%2Fv7tuvq4u4tufxhwwrd82.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%2Fv7tuvq4u4tufxhwwrd82.png" alt="newsletter table" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Allow the Supabase to configure public access
This can be set up in the the policy page under configuration, search for the table &lt;code&gt;newsletter&lt;/code&gt; and create a policy.&lt;/li&gt;
&lt;/ul&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%2Fkw4k8rikujk0oc4rhv1r.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%2Fkw4k8rikujk0oc4rhv1r.png" alt="Policy table" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Building the React Component
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder called &lt;code&gt;components&lt;/code&gt; in the root folder and set up the &lt;code&gt;NewsletterForm.jsx&lt;/code&gt; file in the components.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/components/NewsletterForm.jsx,  &lt;/span&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;useState&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;NewsletterForm&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="p"&gt;{&lt;/span&gt; 
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&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;handleSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
  &lt;span class="p"&gt;};&lt;/span&gt;  

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;  
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Join&lt;/span&gt; &lt;span class="nx"&gt;our&lt;/span&gt; &lt;span class="nx"&gt;Newsletter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Enter&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;receive&lt;/span&gt; &lt;span class="nx"&gt;latest&lt;/span&gt; &lt;span class="nx"&gt;news&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&amp;gt;     &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;         &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;         &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sr-only&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;  
        &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  
        &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  
        &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;  
        &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  
        &lt;span class="nx"&gt;required&lt;/span&gt;  
      &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;  
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Subscribe&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&amp;gt; &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&amp;gt; &lt;/span&gt;&lt;span class="err"&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="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;NewsletterForm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove all the unneccessary code in the &lt;code&gt;App.jsx&lt;/code&gt; and import the &lt;code&gt;NewsletterForm.jsx&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;NewsletterForm&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;./NewsletterForm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NewsletterForm&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;    
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&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="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Style the Components by creating styles in the &lt;code&gt;index.css&lt;/code&gt; file
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#030303&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;system-ui&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;"Open Sans"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;"Helvetica Neue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;400px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111331&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"email"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt; &lt;span class="m"&gt;0.3s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"email"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#007bff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#007bff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75rem&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-color&lt;/span&gt; &lt;span class="m"&gt;0.3s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0056b3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-radius&lt;/span&gt; &lt;span class="m"&gt;0.5s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.9rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;*=&lt;/span&gt;&lt;span class="s1"&gt;"color: red"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;*=&lt;/span&gt;&lt;span class="s1"&gt;"color: green"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Here is the output&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%2Fry6v95rr6yv0293ngiag.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%2Fry6v95rr6yv0293ngiag.png" alt="Output" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Connecting React project to Supabase
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add the Supabase client by set up the &lt;code&gt;supabaseClient.js&lt;/code&gt; file to add the SUPABASE_URL and the SUPABASE_ANON_KEY.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createClient&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="s2"&gt;@supabase/supabase-js&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;SUPABASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://esqaciqvjfarmopjzomj.supabase.co&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;SUPABASE_ANON_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVzcWFjaXF2amZhcm1vcGp6b21qIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzQzNjA4NDksImV4cCI6MjA0OTkzNjg0OX0.Q2A5fbvdebid_Wsbm5r58Ej7xrLKCL4_4ULuu-kA6Ro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;supabase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SUPABASE_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SUPABASE_ANON_KEY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Updating the &lt;code&gt;NewsletterForm.jsx&lt;/code&gt; to have the email store in the database.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/NewsletterForm.js&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;useState&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="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;supabase&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="s2"&gt;../supabaseClient&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;NewsletterForm&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="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setSuccess&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&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;handleSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setSuccess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Check if email is valid&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\S&lt;/span&gt;&lt;span class="sr"&gt;+@&lt;/span&gt;&lt;span class="se"&gt;\S&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;\.\S&lt;/span&gt;&lt;span class="sr"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please enter a valid email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Insert email into Supabase&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;insertError&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;supabase&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;newsletters&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;([{&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="p"&gt;}]);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;insertError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error subscribing to newsletter: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;insertError&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setSuccess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Thank you for subscribing!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Clear the input field&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Clear messages after 3 seconds  &lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&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="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
      &lt;span class="nf"&gt;setSuccess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Join&lt;/span&gt; &lt;span class="nx"&gt;our&lt;/span&gt; &lt;span class="nx"&gt;Newsletter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Enter&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;receive&lt;/span&gt; &lt;span class="nx"&gt;latest&lt;/span&gt; &lt;span class="nx"&gt;news&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
        &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
        &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;required&lt;/span&gt;
      &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Subscribe&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&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="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;NewsletterForm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ffjot2bmzqsyn6f8hckzz.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%2Ffjot2bmzqsyn6f8hckzz.png" alt="Output" width="800" height="366"&gt;&lt;/a&gt;&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%2Fxfh2qn0639vyj5se5512.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%2Fxfh2qn0639vyj5se5512.png" alt="Email Table" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check the link below to check the demo&lt;br&gt;
&lt;a href="https://www.awesomescreenshot.com/video/34736889?key=7ea1cfc2deffce5d5da702beb4c9df74" rel="noopener noreferrer"&gt;Demo&lt;/a&gt; &lt;/p&gt;




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

&lt;p&gt;With this guide, you have been to create a subscribe to newsletter with Supabase to have the emails subscribed stored in the database and can be used later on.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to create shapes with HTML canvas</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Sat, 14 Dec 2024 21:32:26 +0000</pubDate>
      <link>https://dev.to/motuncoded/how-to-create-shapes-with-html-canvas-46k7</link>
      <guid>https://dev.to/motuncoded/how-to-create-shapes-with-html-canvas-46k7</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction &lt;/li&gt;
&lt;li&gt;Getting Started
&lt;/li&gt;
&lt;li&gt;Drawing Shapes &lt;/li&gt;
&lt;li&gt;Conclusion &lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  ✍️ &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element is used in creating content that includes graphics. This gives developers the opportunity to draw shapes, texts and shapes including styles and animation.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ &lt;strong&gt;Getting Started with Canvas&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In creating the shapes with HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt;, there are few tips to set up&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. Adding &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element to the HTML page to specify its use, in the canvas tag includes the identity(id) attribute which will be dynamically controlled by Javascript. You should also set the width and height to determine the size of the canvas element&lt;/li&gt;
&lt;/ul&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%2Frvgwq9ss2u3jhnr747q4.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%2Frvgwq9ss2u3jhnr747q4.png" alt="canvas set up" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;2. Manipulating the &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element with JavaScript by retrieving the element using the ID and assign to the constant &lt;code&gt;canvas&lt;/code&gt;. The &lt;code&gt;getContext("2d")&lt;/code&gt; method make the  canvas to be rendered as text, shape or image.&lt;/li&gt;
&lt;/ul&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%2Fmmvf3wsbus0lme7yoyts.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%2Fmmvf3wsbus0lme7yoyts.png" alt="canvas set up" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✏️ &lt;strong&gt;Drawing Shapes&lt;/strong&gt;
&lt;/h2&gt;




&lt;h4&gt;
  
  
  🟦 &lt;strong&gt;Rectangle&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;These methods can be used to create a rectangle where x = the x coordinate of the rectangle, y = the y coordinate of the rectangle, width = the width of the rectangle and height of the rectangle.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fillRect(x, y, width, height)&lt;/code&gt;
This method create a filled rectangle with a fill style to give it a specific color.&lt;/li&gt;
&lt;/ul&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%2F24cfckyandk6fhpjfxwm.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%2F24cfckyandk6fhpjfxwm.png" alt="filled Rectangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;strokeRect(x, y, width, height)&lt;/code&gt;
This method create an outline rectangle or a rectangle with a stroke, the strokeStyle can be used to add color to it.&lt;/li&gt;
&lt;/ul&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%2Fb7j604r6h3p3311qb02d.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%2Fb7j604r6h3p3311qb02d.png" alt="border rect" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;clearRect(x, y, width, height)&lt;/code&gt;
This method create a transparent rectangle but you have to specify the canvas width and height filled with a color name so it the transparent rectangle can render&lt;/li&gt;
&lt;/ul&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%2F31nxy1p6f4lyes31te1b.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%2F31nxy1p6f4lyes31te1b.png" alt="Transparent rectangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  🟩 &lt;strong&gt;Square&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The methods for creating square are same as rectangle, the difference is the width value which is the same as the height unlike in rectangle.&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%2Fxb324eyvidfcg68uh6p5.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%2Fxb324eyvidfcg68uh6p5.png" alt="Square " width="800" height="366"&gt;&lt;/a&gt;&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%2Fmu3452qk94dxws0lfv9q.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%2Fmu3452qk94dxws0lfv9q.png" alt="oulined Square" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  🔺 &lt;strong&gt;Triangle&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;These methods can be used to create a triangle.&lt;/p&gt;

&lt;p&gt;-&lt;code&gt;beginPath()&lt;/code&gt;: This method is to start a new path for the drawing.&lt;br&gt;
-&lt;code&gt;moveTo(x, y)&lt;/code&gt;: This method help to move the pen at the first vertex of the triangle&lt;br&gt;
-&lt;code&gt;lineTo(x, y)&lt;/code&gt;: This method draw the bottom vertex of the triangle.&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%2F8qmw8pg41apmaw4z7na8.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%2F8qmw8pg41apmaw4z7na8.png" alt="triangle" width="800" height="366"&gt;&lt;/a&gt;&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%2Frqx5d2zph9fh4envf5nn.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%2Frqx5d2zph9fh4envf5nn.png" alt="triangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  ⚪️ &lt;strong&gt;Circle&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;These following methods are used in creating a circle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: this method to begin a path.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;arc(x, y, radius, startAngle, endAngle, anticlockwise)&lt;/code&gt;: this is for to create circle where x and y is for center coordinates of the center, radius is the radius of the circle, startAngle and endAngle which is an angle for the circle.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Math.PI&lt;/code&gt;- This is used in creating a half circle while multiplying this by 2 will give a full circle&lt;/li&gt;
&lt;/ul&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%2F98l5ghbx576u0kxopqne.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%2F98l5ghbx576u0kxopqne.png" alt="circle" width="800" height="366"&gt;&lt;/a&gt;&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%2Fdjil4ixuoqc1mp33vavk.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%2Fdjil4ixuoqc1mp33vavk.png" alt="half circle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  🟠 &lt;strong&gt;Ellipse&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This shape uses the same types of methods but uses; &lt;/p&gt;

&lt;p&gt;-&lt;code&gt;ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise)&lt;/code&gt;: where &lt;br&gt;
  -&lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are the center coordinate of the ellipse, &lt;br&gt;
  -&lt;code&gt;radiusX&lt;/code&gt; and &lt;code&gt;radiusY&lt;/code&gt; is the horizontal and vertical radii of the &lt;br&gt;
    ellipse, &lt;br&gt;
  -&lt;code&gt;rotation&lt;/code&gt; displays the rotation of the ellipse in radians,&lt;br&gt;
  -&lt;code&gt;startAngle&lt;/code&gt; and &lt;code&gt;endAngle&lt;/code&gt; indicate the  start and end angles for the &lt;br&gt;
     drawing, in radians and &lt;br&gt;
  -&lt;code&gt;counterclockwise&lt;/code&gt; which is optional with the value of true or false &lt;br&gt;
    (default is false).&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%2Fxqnuc1qhmnxf3acmuncc.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%2Fxqnuc1qhmnxf3acmuncc.png" alt="ellipse" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  🟦 Parallelogram
&lt;/h4&gt;

&lt;p&gt;This shape uses the following methods;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath&lt;/code&gt; to start a new drawing path and &lt;code&gt;moveTo(x, y)&lt;/code&gt; to set the first corner since the shape has 4 sides with 4 corners.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lineTo&lt;/code&gt; to draw the lines which will connect them together since there are 4 sides.&lt;/li&gt;
&lt;/ul&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%2F6npkqd8vgrjqajw6ezo8.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%2F6npkqd8vgrjqajw6ezo8.png" alt="Parallelogram" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  🟥 &lt;strong&gt;Trapezium&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This shape is quite similar to parallelogram, they utilize the same methods in drawing them. The only different about them is the values of the coordinates.&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%2Ft1q33l2602b7xi9ud4xp.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%2Ft1q33l2602b7xi9ud4xp.png" alt="Trapezium" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  🔺  &lt;strong&gt;Cone&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This shape combines the methods of drawing triangle with the methods of the semi circle.&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%2F57avj6yfsylbvymn6b3w.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%2F57avj6yfsylbvymn6b3w.png" alt="cone" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  🔷 &lt;strong&gt;Polygon&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;To create a polygon, you need to determine the sides of the shape since there are different number of sides.&lt;/p&gt;

&lt;p&gt;These following methods are used in creating a polygon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: this method is to create a new shape.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;closePath()&lt;/code&gt;: this method is to end the shape.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cx&lt;/code&gt;: its value for the center of x co-ordinates.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cy&lt;/code&gt;: its value specifies the center for y co-ordinates.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;radius&lt;/code&gt;: radius of the shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get the angle, you have to calculate with this formula by dividing the circle into two;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;angle = 2π/ n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;pentagon&lt;/li&gt;
&lt;/ul&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%2Fwdekw9ldiyn7uook5cqa.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%2Fwdekw9ldiyn7uook5cqa.jpg" alt="pentagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;hexagon&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%2Fjg6fe3r809muz3wzpinr.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%2Fjg6fe3r809muz3wzpinr.png" alt="hexagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;heptagon&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Faqbt31c4joeobvjt3zwe.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%2Faqbt31c4joeobvjt3zwe.png" alt="heptagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;octagon&lt;/li&gt;
&lt;/ul&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%2Fowyc6awj2gtgxhmx3rmg.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%2Fowyc6awj2gtgxhmx3rmg.png" alt="octagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nonagon&lt;/li&gt;
&lt;/ul&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%2Ft29k4cjuabibj20i1asu.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%2Ft29k4cjuabibj20i1asu.png" alt="nonagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;decagon&lt;/li&gt;
&lt;/ul&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%2Fm8hyolzx5ejek2e7ljtm.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%2Fm8hyolzx5ejek2e7ljtm.png" alt="decagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Finally, we have come to the end of this article. The shapes we created have series of methods in drawing them.&lt;/p&gt;

&lt;p&gt;Thank you for reading. Connect with me on &lt;br&gt;
&lt;a href="https://www.linkedin.com/in/motunrayoadeneye" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://x.com/motunadeneye" rel="noopener noreferrer"&gt;X&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>HTML Canvas Made Simple: A Guide for Beginners.</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Wed, 11 Dec 2024 22:05:18 +0000</pubDate>
      <link>https://dev.to/motuncoded/html-canvas-made-simple-a-guide-for-beginners-739</link>
      <guid>https://dev.to/motuncoded/html-canvas-made-simple-a-guide-for-beginners-739</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction &lt;/li&gt;
&lt;li&gt;Getting Started
&lt;/li&gt;
&lt;li&gt;Drawing basics&lt;/li&gt;
&lt;li&gt;Adding Text &lt;/li&gt;
&lt;li&gt;Conclusion &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🟦 &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; is an HTML element with the tag &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; that is used to draw graphics in two or three dimension via Javascript. The &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; is a wrapper that can be manipulated by javascript to create texts, images, shapes, animations to create visually appealing and interactive elements.&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%2Fzxfgzbde3tl7u4l6ovwv.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%2Fzxfgzbde3tl7u4l6ovwv.png" alt="HTML Canvas" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The use of &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; is available in all browsers and devices which gives the developers the flexibility to create amazing graphics.  &lt;/p&gt;

&lt;h4&gt;
  
  
  Use Cases of HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Drawing shapes and lines: It can draw shapes, patterns and lines including adding of colors and gradients to the objects.&lt;/li&gt;
&lt;li&gt;Animation and interaction: The objects created by &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; can be animated and also user interactions&lt;/li&gt;
&lt;li&gt;Images Manipulation: This can used to resizing or cropping images.&lt;/li&gt;
&lt;li&gt;Game graphics: It is also used by game developer to create beautiful game user interfaces&lt;/li&gt;
&lt;li&gt;Data visualization:  It is for the creation of graphs and charts.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🟥&lt;strong&gt;Get Started&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; is used in the HTML file and can be manipulated internally in the script tag or externally in the javascript file. Without this, the canvas object will not be displayed. &lt;br&gt;
First we have to create an &lt;code&gt;index.html&lt;/code&gt; file and include the &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt;wrapper for the object to be created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;HTML Canvas Example&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"myCanvas"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"500"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we add a script tag so we can define the behavior of the object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;HTML Canvas Example&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"myCanvas"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"500"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"500"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
         &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myCanvas&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;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
         &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wowu !!! We get the output.&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%2Flpiugkos1916g7xvaei2.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%2Flpiugkos1916g7xvaei2.png" alt="canvas" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the structure of the code. We define canvas wrapper having an &lt;code&gt;id&lt;/code&gt; attribute, this is can only be done by &lt;code&gt;id&lt;/code&gt; and not &lt;code&gt;class&lt;/code&gt; because of uniqueness which is used to reference the canvas with the &lt;code&gt;id&lt;/code&gt; name.&lt;br&gt;
To access this we need to retrieve the node created in the Document Object Model(DOM) by using the &lt;code&gt;getElementById("myCanvas")&lt;/code&gt; and have access to it using the &lt;code&gt;getContext("2d")&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;This method make us to have access to different drawing methods like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fillRect(x, y, width, height)&lt;/code&gt;: This method is to draw a filled rectangle at a position(x, y) with a specified width and height.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fillStyle = colorName&lt;/code&gt;: It is a property to set the color for the object. It could be a colorname, RGB or hex code for the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;strokeRect(x, y, width, height)&lt;/code&gt;: This method to to make a outline stroke on the rectangle, this may be used independently or combined with &lt;code&gt;fillStyle&lt;/code&gt; and &lt;code&gt;fillRect(x, y, width, height)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;clearRect(x, y, width, height)&lt;/code&gt;: to clear the rectangle by making it transparent.&lt;/li&gt;
&lt;/ul&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%2Fcosryson2glgrns9gj55.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%2Fcosryson2glgrns9gj55.png" alt="Rectangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  🟩 &lt;strong&gt;Drawing basics&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Different shapes and lines can be drawn using some specific methods depending on the object.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Path:
&lt;/h4&gt;

&lt;p&gt;Examples are line, wavy line, zigzag e.t.c&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%2Fenw14sykbp9lzt20bori.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%2Fenw14sykbp9lzt20bori.png" alt="Line" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For creating a line, the following method needs to be set up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: This method is to start a new path for a drawing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;moveTo(x, y)&lt;/code&gt;: This is to move the drawing to the specified points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lineTo(x, y)&lt;/code&gt;: This is to draw from the current position to the specified points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stroke()&lt;/code&gt;: This is to draw the line.&lt;/li&gt;
&lt;/ul&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%2Fftzl6ddwg80it8t0ltne.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%2Fftzl6ddwg80it8t0ltne.png" alt="zigzag" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  2.   Rectangle and Square
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Rectangle&lt;/li&gt;
&lt;/ul&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%2Fjxjlxsfds17s6wet25gv.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%2Fjxjlxsfds17s6wet25gv.png" alt="Rectangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Square &lt;/li&gt;
&lt;/ul&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%2Fb4am8332subjx0pa0l4q.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%2Fb4am8332subjx0pa0l4q.png" alt="Square" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These following methods are used in creating a rectangle or square:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fillRect&lt;/code&gt;: this method is for create rectangle and square only.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;clearRect(x, y, width, height)&lt;/code&gt;: this method is to clear rectangle hence making it transparent.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strokeRect(x, y, width, height)&lt;/code&gt;: is used to create an outline rectangle or square.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fillStyle&lt;/code&gt;: this is used to fill the container of the rectangle or square.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strokeStyle&lt;/code&gt;: this method is for add stroke color to an outline rectangle.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;roundRect(x, y, width, height, radii)&lt;/code&gt;: this method is for creating round border rectangle.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  3. Circle
&lt;/h4&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%2Fj4ovop71kvkpds0pe259.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%2Fj4ovop71kvkpds0pe259.png" alt="circle" width="800" height="366"&gt;&lt;/a&gt;&lt;br&gt;
 These following methods are used in creating a circle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: this method to begin a path.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;arc(x, y, radius, startAngle, endAngle, anticlockwise)&lt;/code&gt;: this is for to create circle where &lt;code&gt;x and y&lt;/code&gt; is for center coordinate of the center, &lt;code&gt;radius&lt;/code&gt; is the radius of the circle, &lt;code&gt;startAngle&lt;/code&gt; and &lt;code&gt;endAngle&lt;/code&gt; which is an angle for the circle.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  4. Polygon
&lt;/h4&gt;

&lt;p&gt;To create a polygon, you need to determine the sides of the shape, it could be a triangle(3 sides), pentagon (5 sides), hexagon(6 sides) or decagon  (10 sides).&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%2Fplza6zkez2u4skbi4jv3.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%2Fplza6zkez2u4skbi4jv3.png" alt="triangle" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These following methods are used in creating a polygon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;beginPath()&lt;/code&gt;: this method is to create a new shape.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;closePath()&lt;/code&gt;: this method is to end the shape.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cx&lt;/code&gt;: its value for the center of x co-ordinates.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cy&lt;/code&gt;: its value specifies the center for y co-ordinates.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;radius&lt;/code&gt;: radius of the shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get the angle, you have to calculate with this formula by dividing the circle into two;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;angle = 2π/ n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where π is 3.14; n is the number of sides. You also have to minus π/2 to get the position of the shape top to bottom.&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%2Fng3kq55t4p1slfxri2lr.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%2Fng3kq55t4p1slfxri2lr.png" alt="pentagon" width="800" height="366"&gt;&lt;/a&gt;&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%2Fzps08u57rz01q49fathq.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%2Fzps08u57rz01q49fathq.png" alt="hexagon" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🟨 &lt;strong&gt;Text with &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt;&lt;/strong&gt;
&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%2F63ynq8hdbps6o22a8xab.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%2F63ynq8hdbps6o22a8xab.png" alt="text" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To create text, the following methods are used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;font&lt;/code&gt;: to specify font size and font family.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fillStyle&lt;/code&gt;: this is to add color to the text.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fillText&lt;/code&gt;: this draws a filled text.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strokeText&lt;/code&gt;: this draws an outline text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;createLinearGradient&lt;/code&gt; or &lt;code&gt;createRadialGradient&lt;/code&gt;: to add gradients to the text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;textAlign&lt;/code&gt;: to set the text horizontally&lt;/li&gt;
&lt;/ul&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%2Fcsi9kuy2nvd9m5l73qhs.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%2Fcsi9kuy2nvd9m5l73qhs.png" alt="Outline Text" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;




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

&lt;p&gt;Using HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; can help dynamically to draw graphics. With this you have learnt the how to draw with canvas including its use and importance which is the foundation of creating complex graphics later on.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Connect with me&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For more articles on web development. Follow me on Linkedin and X&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/motunrayoadeneye" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;   &lt;a href="https://x.com/motunadeneye" rel="noopener noreferrer"&gt;X&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
      <category>web</category>
    </item>
    <item>
      <title>My First Hacktoberfest experience as a contributor.</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Sat, 02 Nov 2024 09:41:18 +0000</pubDate>
      <link>https://dev.to/motuncoded/my-first-hacktoberfest-experience-as-a-contributor-4l3n</link>
      <guid>https://dev.to/motuncoded/my-first-hacktoberfest-experience-as-a-contributor-4l3n</guid>
      <description>&lt;p&gt;This year &lt;a href="https://hacktoberfest.com/profile/" rel="noopener noreferrer"&gt;hacktoberfest&lt;/a&gt; was a bit of mixed feelings from the registration to the participation. I came across the word hacktoberfest on LinkedIn where people were discussing about it. Then I decided to check it out on its website and I registered for it. &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%2Ftbuz59eym3h64jd5ae6v.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%2Ftbuz59eym3h64jd5ae6v.png" alt="Motuncoded Hacktoberfest" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I registered as early as soon and overtime I couldn't do anything. I checked out the discord channel for the hacktoberfest to search for open source projects but the tech stacks used in the projects was not the same as the one I have. &lt;/p&gt;

&lt;p&gt;At a point, I could not pick a project to work on and this made me sad. I checked out different posts on Linkedin tagging hacktoberfest to gain insights on how people get projects to work.&lt;br&gt;
I stumbled upon Tobisolutions and Emmanuel event on Linkedin where he talked about how to contribute to open source projects. Thanks to him, I began to pick interest on working on different projects and how I can add values to the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Participations
&lt;/h2&gt;

&lt;p&gt;I majorly worked on documentations and later codebase. Along the line, I learnt about how to create issues with different labels depending on what changes I want to make.&lt;br&gt;
I made better commit messages and descriptions that will assist my fellow developers on what changes I made on the projects. Following 2024, I hope to contribute more in open source projects that will make a better developer. &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%2Fhith65tmdk5ms7g15hc1.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%2Fhith65tmdk5ms7g15hc1.png" alt="Merged PRs" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right now, I have butterflies in my stomach having my 4 PRs merged.&lt;/p&gt;

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

&lt;p&gt;Congratulations to all the contributors and maintainers.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hacktoberfest</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How to setup the tailwindcss in your next HTML project ?</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Mon, 29 Apr 2024 19:58:00 +0000</pubDate>
      <link>https://dev.to/motuncoded/how-to-setup-the-tailwindcss-in-your-next-html-project--38p9</link>
      <guid>https://dev.to/motuncoded/how-to-setup-the-tailwindcss-in-your-next-html-project--38p9</guid>
      <description>&lt;p&gt;In this article of mine, I will be showing you how to install tailwindcss in your next HTML projects. From there we can explore the ways of installing tailwindcss.&lt;/p&gt;

&lt;p&gt;Being a utility first css framework packed with classes, tailwindcss helps to create website in your markup language-HTML.&lt;/p&gt;

&lt;p&gt;It is not only restricted to utility approach but also a component approach which treat every element as a whole and apply styles to them.&lt;/p&gt;

&lt;p&gt;Before we dive in the creating our project, we need set up our installation environments.&lt;/p&gt;

&lt;p&gt;First we create a folder called the my_projects or use any project title and open the folder on your code editor, I personally use Visual studio code editor.&lt;br&gt;
Open the terminal on your code editor and make sure you are in the right folder which is my_project folder.&lt;br&gt;
In the terminal you will add this command below, to create a development environment for the projects.&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%2F5dtei1brc1asux6a8rl3.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%2F5dtei1brc1asux6a8rl3.png" alt="to create vite" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the command is clicked, an extension of the command continues to ask for a name for the project. Since we have one, we specify by using  "./" to navigate in the same folder we have previously created.&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%2Flmfbj9snlemgeq04fcqv.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%2Flmfbj9snlemgeq04fcqv.png" alt="command line" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will create extension that will inform us on the type of framework to use, since we will be using little JavaScript in our project, we will select vanilla. Which will take us to select either vanilla JavaScript or vanilla Typescript. We select the vanilla JavaScript.&lt;/p&gt;

&lt;p&gt;After doing that this below will pop up and then we run the following command.&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%2Fqh1ysbro238ndktcjz9f.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%2Fqh1ysbro238ndktcjz9f.png" alt="Vite pop up" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is to help install the necessary installation packages including package.json files.&lt;br&gt;
Moving on, we will have to install the tailwindcss package which will be used in styling the website.&lt;/p&gt;

&lt;p&gt;Following commands should be pasted on the terminal one after the order to help in the installation of the tailwind packages.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -D tailwindcss&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx tailwindcss init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The above commands will help in creating the &lt;code&gt;tailwind.config.js&lt;/code&gt; file that will be used to create custom styles that may be in the m-project folder. You can copy and paste these code below to replace the ones on the &lt;code&gt;tailwind.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
/** @type {import('tailwindcss').Config} &lt;em&gt;/&lt;br&gt;
module.exports = {&lt;br&gt;
  content: ["./&lt;/em&gt;&lt;em&gt;/&lt;/em&gt;.{html,js}"],&lt;br&gt;
  theme: {&lt;br&gt;
    extend: {},&lt;br&gt;
  },&lt;br&gt;
  plugins: [],&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
Then create an dist folder in the root folder of the my-project folder, and since the style.css is present with the vite installation. You will have to add the code below.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
@tailwind base;&lt;br&gt;
@tailwind components;&lt;br&gt;
@tailwind utilities;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
You make sure you add this code below in the package.json file like this&lt;br&gt;
`{&lt;br&gt;
  "name": "my-project",&lt;br&gt;
  "private": true,&lt;br&gt;
  "version": "0.0.0",&lt;br&gt;
  "type": "module",&lt;br&gt;
  "scripts": {&lt;br&gt;
    "dev": "vite",&lt;br&gt;
    "build": "npx tailwindcss -i ./style.css -o ./dist/output.css --watch",&lt;br&gt;
    "preview": "vite preview"&lt;br&gt;
  },&lt;br&gt;
  "devDependencies": {&lt;br&gt;
    "tailwindcss": "^3.4.3",&lt;br&gt;
    "vite": "^5.2.0"&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Run the following command below in the terminal to help scan the classes available on the mark up language.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx tailwindcss -i ./style.css -o ./dist/output.css --watch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You then add this link below in the &lt;code&gt;index.html&lt;/code&gt; file &lt;br&gt;
&lt;code&gt;&amp;lt;link href="dist/output.css" rel="stylesheet"&amp;gt;&lt;/code&gt;&lt;br&gt;
Make some changes in the &lt;code&gt;main.js&lt;/code&gt; file 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%2Fegcwktbj6ios44l0fsr0.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%2Fegcwktbj6ios44l0fsr0.png" alt="html-file" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then run &lt;code&gt;npm run build&lt;/code&gt; to build the project for production and &lt;code&gt;npm run dev&lt;/code&gt; simultaneously to start the project&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%2F4kt1hnr9d90dqe93o5v5.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%2F4kt1hnr9d90dqe93o5v5.png" alt="my-project" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whoa, our project is running.&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>css</category>
      <category>html</category>
      <category>vite</category>
    </item>
    <item>
      <title>Starting my 100 days of code</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Sun, 19 Jun 2022 09:06:29 +0000</pubDate>
      <link>https://dev.to/motuncoded/starting-my-100-days-of-code-13bk</link>
      <guid>https://dev.to/motuncoded/starting-my-100-days-of-code-13bk</guid>
      <description>&lt;p&gt;Today I would be starting my 100days of code with Reactjs, Typescript, Next and Vue. I would be starting with a minimal functionality to a potential website. &lt;br&gt;
I love to reflect on what I have learn so far from the documentation.&lt;br&gt;
I hope by posting this will keep me motivated to go further in learning. Would love to hear comments from you. &lt;/p&gt;

</description>
      <category>react</category>
      <category>css</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Learning JavaScript</title>
      <dc:creator>Adijat Motunrayo Adeneye</dc:creator>
      <pubDate>Fri, 06 Aug 2021 10:51:31 +0000</pubDate>
      <link>https://dev.to/motuncoded/learning-javascript-11jh</link>
      <guid>https://dev.to/motuncoded/learning-javascript-11jh</guid>
      <description>&lt;p&gt;Hello, I am Motunrayo Adeneye from Lagos, Nigeria. I would learning JavaScript in my 100daysofcoding.&lt;/p&gt;

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