<?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: Mazin Idris</title>
    <description>The latest articles on DEV Community by Mazin Idris (@mazin1231).</description>
    <link>https://dev.to/mazin1231</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%2F929794%2F84a3ef66-ea7c-4004-bef5-9272b1a3d3d2.jpg</url>
      <title>DEV Community: Mazin Idris</title>
      <link>https://dev.to/mazin1231</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mazin1231"/>
    <language>en</language>
    <item>
      <title>JavaScript Loops</title>
      <dc:creator>Mazin Idris</dc:creator>
      <pubDate>Wed, 01 Feb 2023 02:40:58 +0000</pubDate>
      <link>https://dev.to/mazin1231/javascript-loops-2123</link>
      <guid>https://dev.to/mazin1231/javascript-loops-2123</guid>
      <description>&lt;p&gt;Do you think you understand for-loops in JavaScript? Do you want to test your JavaScript for-loops knowledge? You came to the right place!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are JavaScript For-Loops&lt;/strong&gt;&lt;br&gt;
JavaScript For-Loops are just loops. They exist in almost every single programming language. Like the name suggests, loops will loop and in our case it would loop JavaScript code! So you can run a certain set of JavaScript code x number of times! However there two important things in regards to for-loops that one must be aware of.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Index in JavaScript For-Loops&lt;/strong&gt;&lt;br&gt;
When you have a for-loop you will have access to something called an index. Index is an integer (plain number). You can start at 0 or 1 or 2 or even -35. Your choice! You will have access to this index which by the way you can call anything you want in the set of code that you loop through. Most developers choose to call this index “i” without the quotes.&lt;/p&gt;

&lt;p&gt;JavaScript For-Loops are Mostly Used in Arrays!&lt;br&gt;
Make no mistake. JavaScript for-loops are mostly used in Arrays. Remember what arrays are. They are just a collection of stuff. So if you want to go through every single element in your array you can use a for-loop! Simple right? You have a bunch of data in an array and you want to…let’s say….print them out to the screen or console. You can use a for-loop for that!&lt;/p&gt;

&lt;p&gt;How a JavaScript For-Loop Looks Like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 1; i &amp;lt;= 10; i++) {
  console.log(i);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;2&lt;/p&gt;

&lt;p&gt;3&lt;/p&gt;

&lt;p&gt;4&lt;/p&gt;

&lt;p&gt;5&lt;/p&gt;

&lt;p&gt;6&lt;/p&gt;

&lt;p&gt;7&lt;/p&gt;

&lt;p&gt;8&lt;/p&gt;

&lt;p&gt;9&lt;/p&gt;

&lt;p&gt;10&lt;/p&gt;

&lt;p&gt;Simple right? Well, let’s break it out real quick.&lt;/p&gt;

&lt;p&gt;JavaScript For-Loop Syntax&lt;br&gt;
I am just going to focus on the inner part of the parenthesis ()&lt;/p&gt;

&lt;p&gt;Part 1) i = 1&lt;/p&gt;

&lt;p&gt;Start our “count” at 1&lt;/p&gt;

&lt;p&gt;Part 2) i &amp;lt;= 10&lt;/p&gt;

&lt;p&gt;Keep going as long as i is less than or equal to 10&lt;/p&gt;

&lt;p&gt;Part 3) i++&lt;/p&gt;

&lt;p&gt;Increase i by one everytime&lt;/p&gt;

&lt;p&gt;That’s it!&lt;/p&gt;

&lt;p&gt;JavaScript For-Loops with Arrays&lt;br&gt;
I feel like any description of JavaScript for-loops without including arrays is an inadequate description. So here we go.&lt;/p&gt;

&lt;p&gt;We have an array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr = ["Ricciardo", "Verstappen", "Bottas"];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now let’s print out every single element to the console or screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 0; i &amp;lt; arr.length; i++) {
  console.log(arr[i]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print&lt;/p&gt;

&lt;p&gt;Ricciardo&lt;/p&gt;

&lt;p&gt;Verstappen&lt;/p&gt;

&lt;p&gt;Bottas&lt;/p&gt;

&lt;p&gt;Simple right? At least I hope it is.&lt;/p&gt;

&lt;p&gt;Now to the exercise! Don’t be nervous. No one is watching you and it is not timed. In fact, no one gives a shit if you do well or not so…no pressure!&lt;/p&gt;

&lt;p&gt;JavaScript for-loop Exercise&lt;br&gt;
Using a for loop output the elements in reverse order&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr = [43, "what", 9, true, "cannot", false, "be", 3, true];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;// Example output:&lt;br&gt;
// true 3.5 be false cannot true 9 what 43 OR each item on a new line&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Hope JavaScript for-loops make just a little more sense now. If it doesn’t, feel free to schedule a one-on-one tutoring session with me. I would love to help you understand it better.&lt;/p&gt;

</description>
      <category>crypto</category>
      <category>cryptocurrency</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Routing in Rails</title>
      <dc:creator>Mazin Idris</dc:creator>
      <pubDate>Mon, 12 Dec 2022 18:19:19 +0000</pubDate>
      <link>https://dev.to/mazin1231/routing-in-rails-52op</link>
      <guid>https://dev.to/mazin1231/routing-in-rails-52op</guid>
      <description>&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%2Fwcq1pljvyiz8m97lse1f.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%2Fwcq1pljvyiz8m97lse1f.png" alt="Image description" width="375" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What exactly is routing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When there's an HTTP request from the user to the application, it should be directed to the right controller. You can picture a router as a receptionist at who connects you to the right person to talk to.&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%2Fnnw2kdw6bfbzunsw2czv.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%2Fnnw2kdw6bfbzunsw2czv.png" alt="Image description" width="259" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How is routing done in Ruby on Rails?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Rails, the routes of your application live in config/routes.rb. The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views. Let's consider an application to book rooms in different Hotels and take a look at how this works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of HTTP request methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The application receives an HTTP request which carries along with it a method which could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET - Retrieve a resource&lt;/li&gt;
&lt;li&gt;POST - Create a resource&lt;/li&gt;
&lt;li&gt;PUT - Completely update a resource&lt;/li&gt;
&lt;li&gt;PATCH - Partially update a resource&lt;/li&gt;
&lt;li&gt;DELETE - Delete a resource&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These methods determine which controller action method is called.&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%2Fmhnlhsdult85f3qp9a8f.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%2Fmhnlhsdult85f3qp9a8f.png" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoding the http request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the application receives the request, GET /players/1. The request is dispatched to the players controller's show action with { id: '1' } in params.&lt;/p&gt;

&lt;p&gt;get '/teams/:id', to: 'teams#show'&lt;/p&gt;

&lt;p&gt;Similarly,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get '/teams', to: 'teams#index'
get '/teams/:id', to: 'teams#show'
get '/teams/new', to: 'teams#new'
post '/teams', to: 'teams#create'
get '/teams/:id/edit', to: 'teams#edit'
put '/teams/:id', to: 'teams#update'
delete '/teams/:id', to: 'teams#destroy'

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Defining resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like how the team manger holds a record of all the players, the application too has its own record in config/routes.rb.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
  resources :teams
end

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

&lt;/div&gt;



&lt;p&gt;By writing resources :teams we create all seven different routes in your application, all mapping to the Teams controller like mentioned above.&lt;/p&gt;

&lt;p&gt;If your controller has only a few of these actions you can alter the same with the following keywords.&lt;/p&gt;

&lt;p&gt;The keyword only includes only the actions mentioned. resources :teams, only: [:edit]&lt;/p&gt;

&lt;p&gt;There's also the keyword except to name the ones you don't want to include.&lt;/p&gt;

&lt;p&gt;resources :teams, except: [:index]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources :players,
resources :teams
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nested Resources&lt;/strong&gt;&lt;br&gt;
Sometimes we have nested routes, /teams/:id/players which are a result of resources that are logically children of other resources. For example, suppose your application includes these models:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Team &amp;lt; ApplicationRecord
  has_many :players
end

class Player &amp;lt; ApplicationRecord
  belongs_to :teams
end
&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%2Fsqvof3fq8k36s8l410g4.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%2Fsqvof3fq8k36s8l410g4.png" alt="Image description" width="259" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In which case we will declare our resources this way,'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources :teams do
  resources :players
end

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

&lt;/div&gt;



&lt;p&gt;This declaration helps us access the nested URLs such as /teams/:id/players , /teams/:id/players/:id , /teams/:id/players/new etc&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Ruby Migration.</title>
      <dc:creator>Mazin Idris</dc:creator>
      <pubDate>Wed, 16 Nov 2022 02:22:46 +0000</pubDate>
      <link>https://dev.to/mazin1231/ruby-migration-43n8</link>
      <guid>https://dev.to/mazin1231/ruby-migration-43n8</guid>
      <description>&lt;p&gt;&lt;strong&gt;What’s a Rails migration?&lt;/strong&gt;&lt;br&gt;
 A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.&lt;/p&gt;

&lt;p&gt;Migrations are additive. Each one represents a new version of your database schema. Rails applications can evolve, and publishing a new migration with a new release of your application isn’t unusual.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Migrations provide lot of benefits, including:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When working on a large project with different team members, it gets easier to keep track of all the changes that the schema goes through.&lt;/li&gt;
&lt;li&gt;Migrations make it easier to rollback to an older schema version, undoing specific migrations.&lt;/li&gt;
&lt;li&gt;Rails migrations make changes more readable and easier to understand.&lt;/li&gt;
&lt;li&gt;Each developer will know whenever a schema is updated, and they can use migrations to speed up to the latest version.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to create a migration:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake db:create_migration NAME=maz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec rake db:create_migration NAME=maz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Migration table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateMaz &amp;lt; ActiveRecord::Migration[6.1]
  def change
    create_table :Maz do |t|
      t.string :name
      t.string :address
      t.string :img_url
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Rolling back migrations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In case a migration has been executed and is now a part of the application’s database schema, it can always be rolled back or reverted to a state prior to when that particular migration altered the schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails db:rollback STEP=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command shown above will undo the most recently executed migration. The STEP=1 portion of the command makes sure that only the most recent migration needs to be rolled back. In case we want more than one migration to be rolled back, we can change the number of the STEP flag. For example, STEP=3 would roll back the three most recent executed migrations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add a column&lt;/strong&gt;&lt;br&gt;
One of the most common changes in an app is adding a field to an existing object. So adding a column to a database is a typical migration. If you’re working with Active Records, Rails will create the migration for you.&lt;/p&gt;

&lt;p&gt;You can use all of the Rails basic data types with migrations, and it’ll be matched to the corresponding type in the database you migrate to. Here’s a list of data types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;string&lt;/li&gt;
&lt;li&gt;text&lt;/li&gt;
&lt;li&gt;integer&lt;/li&gt;
&lt;li&gt;bigint&lt;/li&gt;
&lt;li&gt;float&lt;/li&gt;
&lt;li&gt;decimal&lt;/li&gt;
&lt;li&gt;numeric&lt;/li&gt;
&lt;li&gt;datetime&lt;/li&gt;
&lt;li&gt;time&lt;/li&gt;
&lt;li&gt;date&lt;/li&gt;
&lt;li&gt;timestamp&lt;/li&gt;
&lt;li&gt;binary&lt;/li&gt;
&lt;li&gt;primary_key&lt;/li&gt;
&lt;li&gt;boolean&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also specify a database-specific data type for a column, but this may cause problems if you try to migrate your application to a new platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rails migration helps interacting with the Database easier.&lt;/p&gt;

&lt;p&gt;By taking advantages of this layer, the app can perform very fast, hence we may consider to understand Rails migration and Database well.&lt;/p&gt;

&lt;p&gt;No SQL Database and reactive programming also open new ways to fix some missing features of SQL database. With new technologies, it may outdate? the migration layer in Rails. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Map() Method In React JS.</title>
      <dc:creator>Mazin Idris</dc:creator>
      <pubDate>Fri, 04 Nov 2022 02:50:14 +0000</pubDate>
      <link>https://dev.to/mazin1231/map-method-in-react-js-4i2o</link>
      <guid>https://dev.to/mazin1231/map-method-in-react-js-4i2o</guid>
      <description>&lt;p&gt;&lt;strong&gt;The map() method ?&lt;/strong&gt; A map is a data collection type where data is stored in the form of pairs. It contains a unique key. The value stored in the map must be mapped to the key. We cannot store a duplicate pair in the map(). It is because of the uniqueness of each stored key. It is mainly used for fast searching and looking up data.&lt;/p&gt;

&lt;p&gt;In React, the ?map? method used to traverse and display a list of similar objects of a component. A map is not the feature of React. Instead, it is the standard JavaScript function that could be called on any array. The map() method creates a new array by calling a provided function on every element in the calling array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to render an array of objects with Array.map in React?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To render an array of objects in react with JSX we need to use Array.map() to transform the object into something react can make use of because you cannot directly render an object into React. Instead, by using Array.map() to convert each object in the array into something else, like a string or a component we can then render it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is an example of how to render data using Array.map:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';   
import ReactDOM from 'react-dom';   

function NameList(props) {  
  const myLists = props.myLists;  
  const listItems = myLists.map((myList) =&amp;gt;  
    &amp;lt;li&amp;gt;{myList}&amp;lt;/li&amp;gt;  
  );  
  return (  
    &amp;lt;div&amp;gt;  
          &amp;lt;h2&amp;gt;React Map Example&amp;lt;/h2&amp;gt;  
              &amp;lt;ul&amp;gt;{listItems}&amp;lt;/ul&amp;gt;  
    &amp;lt;/div&amp;gt;  
  );  
}  
const myLists = ['Soccer', 'Basketball', 'Swimming'];   
ReactDOM.render(  
  &amp;lt;NameList myLists={myLists} /&amp;gt;,  
  document.getElementById('app')  
);  
export default App;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In React, map() can be used to generate lists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you map objects in React?&lt;/strong&gt;&lt;br&gt;
 To map through an object's value in React: Use the Object. values() method to get an array of the object's values. Call the map() method on the array of values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is map a callback function?&lt;/strong&gt;&lt;br&gt;
The map() method calls a callback function on every element of an array and returns a new array that contains the results. The map() method takes two named arguments, the first one is required whereas the second one is optional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are 3 purposes of a map?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Maps represent the real world on a much smaller scale&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;They help you travel from one location to another.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They help you organize information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They help you figure out where you are and how to get where you want to go.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What is map and its advantages?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Two advantages of maps: &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Maps are easier to use and easier to carry around.&lt;/li&gt;
&lt;li&gt;They can show the earth's entire surface or just a small part and can show even a small locality in a great detail.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What is map in JS?&lt;/strong&gt;&lt;br&gt;
 Map is a collection of elements where each element is stored as a Key, value pair. Map object can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, value pair in the same order as inserted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I map data from API?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Getting Started With API Data Mapping&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Data Discovery.&lt;/li&gt;
&lt;li&gt;Define a Default Map.&lt;/li&gt;
&lt;li&gt;Map Custom Data From Each Instance.&lt;/li&gt;
&lt;li&gt;Make Your “Default” A Guideline, Not a Requirement.&lt;/li&gt;
&lt;li&gt;Leverage Self-Service Data Mapping Tools.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Here is my final results of my project after Map() to render the data to the home page:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8fa9m1oolqz4uef1mwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8fa9m1oolqz4uef1mwr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using the map() function, you can pretty much do all sorts of manipulations without mutating the original array. The non-mutation part is essential, as it does not cause any side effects by default and makes it easy to debug your code. If you want to mutate the original array, you can use the traditional for or any other type of loop, or you can use the forEach() function which will need another blog to talk about.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>functional</category>
      <category>programming</category>
    </item>
    <item>
      <title>Different ways of writing functions in JavaScript</title>
      <dc:creator>Mazin Idris</dc:creator>
      <pubDate>Tue, 11 Oct 2022 05:26:20 +0000</pubDate>
      <link>https://dev.to/mazin1231/different-ways-of-writing-functions-in-javascript-59f2</link>
      <guid>https://dev.to/mazin1231/different-ways-of-writing-functions-in-javascript-59f2</guid>
      <description>&lt;p&gt;in My first phase with Flatiron school i learned how to write functions in a deferent way. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Function?&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A function in JavaScript is similar to a procedure—a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of writing a function:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function Declaration&lt;/li&gt;
&lt;li&gt;Function Expression&lt;/li&gt;
&lt;li&gt;Arrow Function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is a Function Declaration:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The function declaration (function statement) defines a function with the specified parameters. You can also define functions using the Function constructor and a function expression&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An example of a function declaration:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;functions are declared with the following syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function functionName(parameters) {
  // code to be executed
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declared functions are not executed immediately. They are "saved for later use", and will be executed later, when they are invoked (called upon).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myFunction(a, b) {
  return a * b;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is a Function Expression:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Function Expression is another way to define a function in JavaScript. Here we define a function using a variable and store the returned value in that variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An example of a function expression:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A function expression can be stored in a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x = function (a , b) {return a * b};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a function expression has been stored in a variable, the variable can be used as a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x = function (a, b) {return a * b};
let z = x(4, 3);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is an Arrow Function:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Arrow functions are a new way to write anonymous function expressions, and are similar to lambda functions in some other programming languages, such as Python. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An example of a function arrow:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before Arrow function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Piece = function() {
  return "One Piece!";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Arrow function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Piece = () =&amp;gt; {
  return "One Piece!";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It gets shorter! If the function has only one statement, and the statement returns a value, you can remove the brackets and the return keyword:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Piece = () =&amp;gt; "One Piece!";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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