<?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: Ivana</title>
    <description>The latest articles on DEV Community by Ivana (@ivanadokic).</description>
    <link>https://dev.to/ivanadokic</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%2F313267%2Ff21aa287-b398-4faf-8420-3fe47acf649c.jpeg</url>
      <title>DEV Community: Ivana</title>
      <link>https://dev.to/ivanadokic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ivanadokic"/>
    <language>en</language>
    <item>
      <title>Django Web Framework (Python)</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 11 Apr 2021 02:24:50 +0000</pubDate>
      <link>https://dev.to/ivanadokic/django-web-framework-python-ebn</link>
      <guid>https://dev.to/ivanadokic/django-web-framework-python-ebn</guid>
      <description>&lt;p&gt;&lt;a href="https://docs.djangoproject.com/en/3.2/" rel="noopener noreferrer"&gt;Django&lt;/a&gt; is an extremely popular and fully featured server-side web framework, written in Python. &lt;/p&gt;

&lt;h2&gt;
  
  
  Install Django
&lt;/h2&gt;

&lt;p&gt;Before you can use Django, you’ll need to install it. More about what Python version should be used with Django version can be found &lt;a href="https://docs.djangoproject.com/en/3.2/faq/install/#faq-python-version-support" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Get the latest development version
&lt;/h4&gt;

&lt;p&gt;The latest and greatest Django version is the one that’s in its Git repository, we started with:&lt;br&gt;
&lt;code&gt;git clone https://github.com/django/django.git&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Install Python
&lt;/h4&gt;

&lt;p&gt;Download the latest version for Mac OS X &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What does Django code look like?
&lt;/h2&gt;

&lt;p&gt;A web application waits for HTTP requests from the web browser (or other clients) and when a request is received the application works out what is needed based on the URL and possibly information in POST/GET data. Depending on what is required it may then read or write information from a database or perform other tasks required to satisfy the request. The application will then return a response to the web browser, often dynamically creating an HTML page for the browser to display by inserting the retrieved data into placeholders in an HTML template.&lt;br&gt;
Django web applications typically group the code that handles each of these steps into separate files:&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%2F5aj63lefpumjr7zggqk0.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%2F5aj63lefpumjr7zggqk0.png" alt="Alt Text" width="713" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URLs&lt;/strong&gt;: While it is possible to process requests from every single URL via a single function, it is much more maintainable to write a separate view function to handle each resource. A URL mapper is used to redirect HTTP requests to the appropriate view based on the request URL. The URL mapper can also match particular patterns of strings or digits that appear in a URL and pass these to a view function as data.&lt;br&gt;
&lt;strong&gt;View&lt;/strong&gt;: A view is a request handler function, which receives HTTP requests and returns HTTP responses. Views access the data needed to satisfy requests via models and delegate the formatting of the response to templates.&lt;br&gt;
&lt;strong&gt;Models&lt;/strong&gt;: Models are Python objects that define the structure of an application's data and provide mechanisms to manage (add, modify, delete) and query records in the database. &lt;br&gt;
&lt;strong&gt;Templates&lt;/strong&gt;: A template is a text file defining the structure or layout of a file (such as an HTML page), with placeholders used to represent actual content. A view can dynamically create an HTML page using an HTML template, populating it with data from a model. A template can be used to define the structure of any type of file; it doesn't have to be HTML!&lt;/p&gt;
&lt;h2&gt;
  
  
  Sending the request to the right view (urls.py)
&lt;/h2&gt;

&lt;p&gt;A URL mapper is stored in a file named urls.py. The mapper (urlpatterns) defines a list of mappings between routes (specific URL patterns) and corresponding view functions. If an HTTP Request is received that has a URL matching a specified pattern, then the associated view function will be called and passed the request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;urlpatterns = [
    path('admin/', admin.site.urls),
    path('book/&amp;lt;int:id&amp;gt;/', views.book_detail, name='book_detail'),
    path('catalog/', include('catalog.urls')),
    re_path(r'^([0-9]+)/$', views.best),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;urlpatterns&lt;/code&gt; object is a list of &lt;code&gt;path()&lt;/code&gt; and/or &lt;code&gt;re_path()&lt;/code&gt; functions (Python lists are defined using square brackets, where items are separated by commas and may have an optional trailing comma.&lt;/p&gt;

&lt;p&gt;The first argument to both methods is a route (pattern) that will be matched. The &lt;code&gt;path()&lt;/code&gt; method uses angle brackets to define parts of a URL that will be captured and passed through to the view function as named arguments. The &lt;code&gt;re_path()&lt;/code&gt; function uses a flexible pattern matching approach known as a regular expression. We'll talk about these in a later article!&lt;/p&gt;

&lt;p&gt;The second argument is another function that will be called when the pattern is matched. The notation &lt;code&gt;views.book_detail&lt;/code&gt;indicates that the function is called &lt;code&gt;book_detail()&lt;/code&gt; and can be found in a module called views.&lt;/p&gt;

&lt;h2&gt;
  
  
  Handling the request (views.py)
&lt;/h2&gt;

&lt;p&gt;Views are the heart of the web application, receiving HTTP requests from web clients and returning HTTP responses. &lt;/p&gt;

&lt;p&gt;We will show a view function &lt;code&gt;index()&lt;/code&gt;, which could have been called by our URL mapper in the previous section. Like all view functions it receives an &lt;code&gt;HttpRequest&lt;/code&gt; object as a parameter &lt;code&gt;(request)&lt;/code&gt; and returns an &lt;code&gt;HttpResponse&lt;/code&gt; object. In this case, we don't do anything with the request, and our response returns a hard-coded string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# filename: views.py (Django view functions)

from django.http import HttpResponse

def index(request):
    # Get an HttpRequest - the request parameter
    # perform operations using information from the request.
    # Return HttpResponse
    return HttpResponse('Hello from Django!')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Views are usually stored in a file called views.py.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main features
&lt;/h2&gt;

&lt;p&gt;We will list the main features that you'll use in almost every web application: URL mapping, views, models, and templates. Just a few of the other things provided by Django include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forms&lt;/strong&gt;: HTML Forms are used to collect user data for processing on the server and Django simplifies form creation, validation, and processing.&lt;br&gt;
&lt;strong&gt;User authentication and permissions&lt;/strong&gt;: Django includes robust user authentication and permission system that has been built with security in mind. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching&lt;/strong&gt;: Creating content dynamically is much more computationally intensive (and slow) than serving static content. Django provides flexible caching so that you can store all or part of a rendered page so that it doesn't get re-rendered except when necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Administration site&lt;/strong&gt;: The Django administration site is included by default when you create an app using the basic skeleton. It's providing an admin page for site administrators to create, edit, and view any data models on your site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Serializing data&lt;/strong&gt;: Django makes it easy to serialize and serve your data as XML or JSON. This can be useful when creating a web service (a website that purely serves data to be consumed by other applications or sites, and doesn't display anything itself), or when creating a website in which the client-side code handles all the rendering of data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a project
&lt;/h2&gt;

&lt;p&gt;To create a project run the following command in your terminal:&lt;br&gt;
&lt;code&gt;django-admin startproject mysite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create a &lt;code&gt;mysite&lt;/code&gt; directory in your current directory.  After the project is created go to its directory via &lt;code&gt;cd&lt;/code&gt; command:&lt;br&gt;
&lt;code&gt;cd mysite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s look at what &lt;code&gt;startproject&lt;/code&gt; created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those files are:&lt;/p&gt;

&lt;p&gt;The outer &lt;strong&gt;mysite/&lt;/strong&gt; root directory is a container for your project. Its name doesn’t matter to Django and you can rename it to anything you like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;manage.py&lt;/strong&gt;: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin and manage.py.&lt;/p&gt;

&lt;p&gt;The inner &lt;strong&gt;mysite/ directory&lt;/strong&gt; is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mysite/&lt;strong&gt;init&lt;/strong&gt;.py&lt;/strong&gt;: An empty file that tells Python that this directory should be considered a Python package. If you’re a Python beginner, read more about packages in the official Python docs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mysite/settings.py&lt;/strong&gt;: Settings/configuration for this Django project. Django settings will tell you all about how settings work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mysite/urls.py&lt;/strong&gt;: The URL declarations for this Django project; a “table of contents” of your Django-powered site. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mysite/asgi.py&lt;/strong&gt;: An entry-point for ASGI-compatible web servers to serve your project. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mysite/wsgi.py&lt;/strong&gt;: An entry-point for WSGI-compatible web servers to serve your project. &lt;/p&gt;

&lt;p&gt;To start a server run the following command:&lt;br&gt;
&lt;code&gt;python manage.py runserver&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After visiting &lt;a href="http://127.0.0.1:8000/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/&lt;/a&gt; you can see your server is really running:)&lt;/p&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>django</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript Array methods: Filter, Map, Reduce, and Sort</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Fri, 02 Apr 2021 02:21:19 +0000</pubDate>
      <link>https://dev.to/ivanadokic/javascript-array-methods-filter-map-reduce-and-sort-32m5</link>
      <guid>https://dev.to/ivanadokic/javascript-array-methods-filter-map-reduce-and-sort-32m5</guid>
      <description>&lt;p&gt;Functions are a very important part of JavaScript, and you will use them all the time. In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. There are several ways to define functions, the most common one is to define functions with a function declaration. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function calcRectArea(width, height) {
  return width * height;
}

console.log(calcRectArea(5, 6));
//-------&amp;gt; Output: 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Term "callback"
&lt;/h3&gt;

&lt;p&gt;When we pass a function expression (an anonymous function) or the pointer (variable name, declared function name) to a function as an argument, the passed function is called a callback. Since the receiving function will execute, or call that function at a later time; that is, it will call it back, it is called a callback.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's learn more about Array methods: Filter, Map, Reduce, and Sort
&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%2Fpcpniz4b2c2s7nv4azxw.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%2Fpcpniz4b2c2s7nv4azxw.png" alt="Alt Text" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Arrays provide a lot of methods. JavaScript already has methods built into its Array data type. Follows the examples of how to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use &lt;code&gt;.filter()&lt;/code&gt; to filter an Array
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;filter()&lt;/code&gt; returns a new array of filter elements that meet a certain condition. The &lt;code&gt;filter()&lt;/code&gt; method creates a new array with all elements that pass the test implemented by the provided function.&lt;br&gt;
&lt;code&gt;filter()&lt;/code&gt; does not execute the function for array elements without values and doesn't change the original array.&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array.filter(function(currentValue, index, arr), thisValue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;function(currentValue, index,arr)&lt;/code&gt; is required. &lt;/p&gt;

&lt;p&gt;A function to be run for each element in the array, function arguments are:&lt;br&gt;
&lt;code&gt;currentValue&lt;/code&gt;- required, the value of the current element&lt;br&gt;
&lt;code&gt;index&lt;/code&gt; - optional, the array index of the current element&lt;br&gt;
&lt;code&gt;arr&lt;/code&gt; -    optional, the array object the current element belongs to.&lt;br&gt;
&lt;code&gt;thisValue&lt;/code&gt;- optional. A value to be passed to the function to be used as its "this" value. If this parameter is empty, the value "undefined" will be passed as its "this" value.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word =&amp;gt; word.length &amp;gt; 6);

console.log(result);
//-------&amp;gt; Output: Array ["exuberant", "destruction", "present"]

//-------&amp;gt; Output: ["exuberant", "destruction", "present"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 40].filter(function() {
    return true;
  }) //=&amp;gt; [10, 20, 30, 40] (map, basically)

  [10, 20, 30, 40].filter(function(e) {
    return e &amp;lt; 30;
  }) //=&amp;gt; [10, 20]

  [10, 20, 30, 40].filter(function(e, index) {
    return index % 2 === 0;
  }) //=&amp;gt; [10, 30] (elements with an even-numbered index)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myArray = [
  { id: 1, name: "Mark" },
  { id: 2, name: "Sam" },
  { id: 3, name: "Sandy" },
  { id: 4, name: "Mark" },
]

myArray.filter(element =&amp;gt; element.name === "Mark")
//-------&amp;gt; Output : 0:{id: 1, name: "Mark"},
//                  1:{id: 4, name: "Mark"}

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

&lt;/div&gt;

&lt;h2&gt;
  
  
  Use &lt;code&gt;.map()&lt;/code&gt; to transform an Array
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; method calls a callback function on every element of an array and returns a new array that contains the results.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; method takes two named arguments, the first one is required whereas the second one is optional.&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newArr = oldArr.map(function(currentValue, index, array) {
  // Do stuff with currentValue (index and array are optional)
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;newArr&lt;/code&gt; - the new array that is returned&lt;br&gt;
&lt;code&gt;oldArr&lt;/code&gt; - the old array being operated on. This array will not be changed&lt;br&gt;
&lt;code&gt;currentValue&lt;/code&gt; - the current value being processed&lt;br&gt;
&lt;code&gt;index&lt;/code&gt; - the current index of the value being processed&lt;br&gt;
&lt;code&gt;array&lt;/code&gt; - the original array&lt;/p&gt;
&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x =&amp;gt; x * 2);

console.log(map1);
//-------&amp;gt; Output: [2, 8, 18, 32]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 40].map(function(a) {
  return a * 2;
}); 
//-------&amp;gt; Output: [20, 40, 60, 80]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  ES6 Example:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr = [1, 2, 3, 4];

const newArray = arr.map(element =&amp;gt; {
  return element * 2;
});

const newArrayOneLiner = arr.map(element =&amp;gt; element * 2);

console.log(arr); // [1, 2, 3, 4]
console.log(newArray); // [2, 4, 6, 8]
console.log(newArrayOneLiner); // [2, 4, 6, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Use &lt;code&gt;.reduce()&lt;/code&gt; to reduce an Array to a value
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;reduce()&lt;/code&gt; method executes a reducer function (that you provide) on each element of the array, resulting in a single output value. The &lt;code&gt;reduce()&lt;/code&gt; method executes a provided function for each value of the array (from left-to-right).&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%2Fnc1bxwewgyp6m2hss9n4.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%2Fnc1bxwewgyp6m2hss9n4.jpg" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
The return value of the function is stored in an accumulator (result/total).&lt;/p&gt;

&lt;p&gt;Note: &lt;code&gt;reduce()&lt;/code&gt; does not execute the function for array elements without values.&lt;/p&gt;

&lt;p&gt;This method does not change the original array.&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array.reduce( function(total, currentValue, currentIndex, arr), 
initialValue )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This method accepts five parameters:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function(total, currentValue, index, arr)&lt;/code&gt;: It is the required parameter and used to run for each element of the array. It contains four-parameter which are listed below:&lt;br&gt;
&lt;code&gt;total&lt;/code&gt;: It is a required parameter and used to specify the initialValue, or the previously returned value of the function.&lt;br&gt;
&lt;code&gt;currentValue&lt;/code&gt;: It is a required parameter and used to specify the value of the current element.&lt;br&gt;
&lt;code&gt;currentIndex&lt;/code&gt;: It is an optional parameter and used to specify the array index of the current element.&lt;br&gt;
&lt;code&gt;arr&lt;/code&gt;: It is an optional parameter and used to specify the array object the current element belongs to.&lt;br&gt;
initialValue: It is an optional parameter and used to specify the value to be passed to the function as the initial value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 40].reduce(function(memo, i) { return memo + i }) //=&amp;gt; 100
[10, 20, 30, 40].reduce(function(memo, i) { return memo + i }, 100) //=&amp;gt; 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Subtract the numbers in the array, starting from the beginning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var numbers = [125, 20, 25, 30];

document.getElementById("demo").innerHTML = numbers.reduce(myFunc);

function myFunc(total, num) {
  return total - num;
}
//=&amp;gt; 50

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

&lt;/div&gt;



&lt;p&gt;Let's see how &lt;code&gt;.reduce()&lt;/code&gt; works. The callback would be invoked four times, with the arguments and return values in each call being as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[0, 1, 2, 3, 4].reduce(function(accumulator, currentValue, currentIndex, array) {
  return accumulator + currentValue
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;callback iteration&lt;/th&gt;
&lt;th&gt;accumulator&lt;/th&gt;
&lt;th&gt;currentValue&lt;/th&gt;
&lt;th&gt;currentIndex&lt;/th&gt;
&lt;th&gt;array&lt;/th&gt;
&lt;th&gt;returnValue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;first call&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;[0, 1, 2, 3, 4]&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;second call&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;[0, 1, 2, 3, 4]&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;third call&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;[0, 1, 2, 3, 4]&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fourth call&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;[0, 1, 2, 3, 4]&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Use &lt;code&gt;sort()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;sort()&lt;/code&gt; method sorts the elements of an array in place and returns the sorted array. &lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arr.sort([compareFunction])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paramaters:&lt;br&gt;
&lt;code&gt;compareFunction&lt;/code&gt; is optional. It specifies a function that defines the sort order. &lt;br&gt;
&lt;code&gt;firstEl&lt;/code&gt;, the first element for comparison.&lt;br&gt;
&lt;code&gt;secondEl&lt;/code&gt;, the second element for comparison.&lt;/p&gt;

&lt;p&gt;To sort an array of objects by the values of the object’s properties, you use the &lt;code&gt;sort()&lt;/code&gt; method and provide a comparison function that determines the order of objects.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Suppose that you have an array of &lt;code&gt;students&lt;/code&gt; objects as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let students = [
    {
        firstName: 'Johnny',
        lastName: 'Lee',
        age: 20,
    },

    {
        firstName: 'Anna',
        lastName: 'Zax',
        age: 19,

    },

    {
        firstName: 'Zion',
        lastName: 'Sanches',
        age: 22,

    }
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following statement snippet sorts the students array by ages in ascending order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;students.sort((a, b) =&amp;gt; {
    return a.age - b.age;
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where to display the students, you can use the forEach() method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;studetns.forEach((e) =&amp;gt; {
    console.log(`${e.firstName} ${e.lastName} ${e.age}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Anna Zax 19
Jonny Lee 20
Zion Sanchez 22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To sort the students by ages in descending order, you just need to reverse the order in the comparison function like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;students.sort((a, b) =&amp;gt; b.age - a.age);

students.forEach((e) =&amp;gt; {
    console.log(`${e.firstName} ${e.lastName} ${e.age}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zion Sanchez 22
Jonny Lee 20
Anna Zax 19
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;We saw how &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;filter()&lt;/code&gt;, &lt;code&gt;reduce()&lt;/code&gt; and &lt;code&gt;sort()&lt;/code&gt; can ease the life of a developer by reducing the number of unnecessary explicit loops and empty array declarations. Try replacing your for loops with these state-of-the-art functions whenever you get a chance. More documentation can be found &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Web form</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 28 Mar 2021 21:20:08 +0000</pubDate>
      <link>https://dev.to/ivanadokic/web-form-4c2i</link>
      <guid>https://dev.to/ivanadokic/web-form-4c2i</guid>
      <description>&lt;p&gt;Web forms are a very powerful tool for interacting with users. It's one of the main points of interaction between a user and a web site or application. &lt;/p&gt;

&lt;p&gt;Forms allow users to enter data, which is generally sent to a web server for processing and storage, or used on the client-side to immediately update the interface in some way. &lt;/p&gt;

&lt;p&gt;A web form's HTML is made up of one or more form controls (sometimes called widgets).&lt;/p&gt;

&lt;p&gt;Let's make a local copy of our HTML template — you'll enter your form HTML into here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en-US"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;title&amp;gt;Test page&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;p&amp;gt;Hello, this is a test page!&amp;lt;/p&amp;gt;
  &amp;lt;/body&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Forms start with &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; container element, specifically for containing forms that supports some specific attributes to configure the way the form behaves. The standard practice is to set at least the &lt;code&gt;action&lt;/code&gt; and &lt;code&gt;method&lt;/code&gt; attributes like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form action="/my-handling-form-page" method="post"&amp;gt;
 &amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;label for="name"&amp;gt;Name:&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" id="name" name="user_name"&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;label for="mail"&amp;gt;E-mail:&amp;lt;/label&amp;gt;
    &amp;lt;input type="email" id="mail" name="user_email"&amp;gt;
  &amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;
    &amp;lt;label for="msg"&amp;gt;Message:&amp;lt;/label&amp;gt;
    &amp;lt;textarea id="msg" name="user_message"&amp;gt;&amp;lt;/textarea&amp;gt;
  &amp;lt;/li&amp;gt;
 &amp;lt;/ul&amp;gt;
&amp;lt;/form&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;action&lt;/code&gt; attribute defines the location (URL) where the form's collected data should be sent when it is submitted.&lt;br&gt;
The &lt;code&gt;method&lt;/code&gt; attribute defines which HTTP method to send the data with (&lt;code&gt;get&lt;/code&gt; or `post).&lt;/p&gt;

&lt;p&gt;Let's add the above &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;element into your HTML &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. On the &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element, the most important attribute is the &lt;code&gt;type&lt;/code&gt; attribute, it defines the way the  element appears and behaves. &lt;/p&gt;

&lt;p&gt;In our example, we use the value &lt;code&gt;&amp;lt;input/text&amp;gt;&lt;/code&gt; , it's a single-line text field that accepts any kind of text input.&lt;/p&gt;

&lt;p&gt;For the second input, we use the value &lt;code&gt;&amp;lt;input/email&amp;gt;&lt;/code&gt;, which defines a single-line text field that only accepts a well-formed e-mail address. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag is an empty element, that doesn't need a closing tag. &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; is not an empty element, it should be closed with the proper ending tag. To define the default value of an &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element you have to use the value attribute like this:&lt;br&gt;
&lt;code&gt;&lt;/code&gt;&lt;code&gt;&amp;lt;input type="text" value="by default this element is filled with this text"&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;To define a default value for a &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;, you put it between the opening and closing tags of the&lt;code&gt; &amp;lt;textarea&amp;gt;&lt;/code&gt; element, like this:&lt;br&gt;
&lt;code&gt;&amp;lt;textarea&amp;gt;and by default it will be text&amp;lt;/textarea&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;button&lt;/code&gt; element
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; element accepts a &lt;code&gt;type&lt;/code&gt; attribute - one of three values: &lt;code&gt;submit&lt;/code&gt;, &lt;code&gt;reset&lt;/code&gt;, or &lt;code&gt;button&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A click on a &lt;code&gt;submit&lt;/code&gt; button (the default value) sends the form's data to the web page defined by the action attribute of the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A click on a &lt;code&gt;reset&lt;/code&gt; button resets all the form widgets to their default value immediately. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A click on a &lt;code&gt;button&lt;/code&gt; is just a clickable button.&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%2Ftsku9h2r32ql5tmr01xl.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%2Ftsku9h2r32ql5tmr01xl.png" alt="Alt Text" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sending form data to your web server
&lt;/h2&gt;

&lt;p&gt;The last part is to handle form data on the server side. The &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element defines where and how to send the data thanks to the &lt;code&gt;action&lt;/code&gt; and &lt;code&gt;method&lt;/code&gt; attributes.&lt;/p&gt;

&lt;p&gt;We provide a name to each form control. It tells the browser which name to give each piece of data and, on the server-side, they let the server handle each piece of data by name. The form data is sent to the server as &lt;code&gt;name/value&lt;/code&gt; pairs.&lt;/p&gt;

&lt;p&gt;To name the data in a form you need to use the &lt;code&gt;name&lt;/code&gt; attribute on each form widget that will collect a specific piece of data. In our example, the form will send 3 pieces of data named "user_name", "user_email", and "user_message". That data will be sent to the URL "/my-handling-form-page" using the HTTP POST method.&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%2Fe7w9jqj3hkiboynsgakf.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%2Fe7w9jqj3hkiboynsgakf.png" alt="Alt Text" width="800" height="603"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This form with added styling can be found &lt;a href="https://github.com/ivanadokic/form/blob/main/form.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;p&gt;We will need to add some form validations.&lt;/p&gt;

&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Visualize with React Chart Race</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Mon, 22 Mar 2021 00:48:17 +0000</pubDate>
      <link>https://dev.to/ivanadokic/react-chart-race-nba-leaders-ece</link>
      <guid>https://dev.to/ivanadokic/react-chart-race-nba-leaders-ece</guid>
      <description>&lt;p&gt;Using a Chart Library that consolidates and presents data visually might help people to understand a large amount of information and make better business decisions. Using the right type of chart is the decision to make when you want to present data. Those are some charts I have used:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.chartjs.org/" rel="noopener noreferrer"&gt;Chartjs&lt;/a&gt;- Simple JavaScript charting for designers &amp;amp; developers&lt;br&gt;
&lt;a href="https://developers.google.com/chart" rel="noopener noreferrer"&gt;Google Charts&lt;/a&gt; - Google chart tools are powerful, simple to use, and free&lt;br&gt;
&lt;a href="https://d3js.org/" rel="noopener noreferrer"&gt;D3&lt;/a&gt; - JavaScript library for manipulating docs based on data&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;animated bar chart race&lt;/strong&gt; is one of my favorite visualizations and it helps you for example to visualize the change in trends over time. This type of animation has been around for a while it's very popular on social media as they provide a holistic data story/insight in an easy-to-understand chart. &lt;/p&gt;

&lt;p&gt;A bar chart race contains an animated order of bars that display the value of data at a different moment in time. You can make your own bar chart race without coding with &lt;a&gt;Flourish&lt;/a&gt; - platform for data visualization and storytelling. &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%2F34pew4odzc2g3zezjpju.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%2F34pew4odzc2g3zezjpju.png" alt="Alt Text" width="800" height="440"&gt;&lt;/a&gt;.&lt;br&gt;
You will need to Create Flourish Account, Open up the Bar Chart Race Template, and format the data to be imported to Flourish, you can Download the formatted data and Import directly following the structure in the file. &lt;/p&gt;

&lt;p&gt;Sometimes, in the software we build, we find that we have to deal with data sets that cannot be viewed clearly unless we visualize it. Depends on the data set after knowing what you are looking for, you will need to surf for the dataset that can be used using different sources such as web scraping or for example use Python that can allow us to scrape websites effectively.&lt;/p&gt;

&lt;p&gt;I was looking for NBA Season Leaders - ESPN Rating&lt;br&gt;
data sets, and for this project I came across a bar chart race visualization library called &lt;code&gt;React Chart Race&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Chart Race
&lt;/h2&gt;

&lt;p&gt;I really like this animated bar chart race &lt;a href="https://www.npmjs.com/package/react-chart-race" rel="noopener noreferrer"&gt;React Chart Race&lt;/a&gt; I found while I was looking to show the top NBA Players ranked visually for the &lt;a href="https://nba-stats-seven.vercel.app/" rel="noopener noreferrer"&gt;NBA-stats&lt;/a&gt; project I was building.&lt;/p&gt;

&lt;p&gt;The animated bar chart race helps you visualize your changing data and it's quite easy to understand. A rising or decreasing bar moves up or down along with the animation.&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%2Fgny87viq8miiqruhp578.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgny87viq8miiqruhp578.gif" alt="here" width="600" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npm install --save react-chart-race&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Import
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;import ChartRace from 'react-chart-race';&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;An element must consist of 4 variables: id, title, value, color, I wanted to have those bars set to &lt;code&gt;color&lt;/code&gt; that is the exact &lt;code&gt;NBA hex color code&lt;/code&gt; of the Player's Team &lt;a href="https://teamcolorcodes.com/nba-team-color-codes/" rel="noopener noreferrer"&gt;NBA Team Color Codes&lt;/a&gt;&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%2Favyte4ehwwex1q1eoj45.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%2Favyte4ehwwex1q1eoj45.png" alt="Alt Text" width="800" height="202"&gt;&lt;/a&gt;. I manually set &lt;code&gt;values&lt;/code&gt; from 2020-2021 NBA Season Leaders - ESPN Rating in order to have Players ranked, I choose the top 6 Players, but it depends on you to chose and add or remove it.&lt;/p&gt;

&lt;p&gt;To learn more follow this &lt;a href="https://teamcolorcodes.com/milwaukee-bucks-color-codes/" rel="noopener noreferrer"&gt;link&lt;/a&gt; for the rest of the NBA &lt;code&gt;hex color codes&lt;/code&gt; for all of your favorite NBA team color codes.&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%2Fn5rbpuu15ok7rnb5p7r8.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%2Fn5rbpuu15ok7rnb5p7r8.png" alt="Alt Text" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;p&gt;We will need to &lt;code&gt;setState&lt;/code&gt; for the animation to work.&lt;/p&gt;

&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Let’s deploy the starter Gatsby template</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 14 Mar 2021 01:19:36 +0000</pubDate>
      <link>https://dev.to/ivanadokic/let-s-deploy-the-starter-gatsby-template-19i8</link>
      <guid>https://dev.to/ivanadokic/let-s-deploy-the-starter-gatsby-template-19i8</guid>
      <description>&lt;h2&gt;
  
  
  Gatsby and Netlify Form integration
&lt;/h2&gt;

&lt;p&gt;This is an example site integrating Netlify’s contact form handling with Gatsby: &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%2Fu8f3rh3zlzds55hvtfem.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%2Fu8f3rh3zlzds55hvtfem.png" alt="Alt Text" width="800" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Forms
&lt;/h3&gt;

&lt;p&gt;Gatsby is built on top of React. So anything that we can do with a React form is possible in Gatsby. Additional details about how to create React forms can be found in the React forms documentation (which happens to be built with Gatsby!)&lt;br&gt;
How to get started documentation can be found &lt;a href="https://reactjs.org/docs/forms.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Integrating Netlify Form Handling in Gatsby
&lt;/h1&gt;

&lt;p&gt;Example for integrating a basic contact form with Netlify’s form handling feature. Demo: &lt;a href="https://gatsby-netlify-form-example-v2.netlify.com/" rel="noopener noreferrer"&gt;https://gatsby-netlify-form-example-v2.netlify.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Features: Basic form submission. Example use controlled form to offer more flexibility. &lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy
&lt;/h2&gt;

&lt;p&gt;To Deploy on Netlify you will need to follow few steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connect to Github
&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%2F6m8k4de7k0xooqj53kpd.png" alt="Alt Text" width="800" height="594"&gt;
&lt;/li&gt;
&lt;li&gt;Configure your site - Save and Deploy (change your Repository name)
&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%2F00rdvdtak2oijbjilo2p.png" alt="Alt Text" width="800" height="519"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>gatsby</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>JS Fundamentals: Arrays</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Mon, 08 Mar 2021 01:51:11 +0000</pubDate>
      <link>https://dev.to/ivanadokic/js-fundamentals-arrays-29d5</link>
      <guid>https://dev.to/ivanadokic/js-fundamentals-arrays-29d5</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Arrays are a simple data structure for storing lots of similar items. Arrays are used to store multiple values in a single variable, and variable can store only one value. All programming languages uses arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common operations
&lt;/h2&gt;

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

&lt;p&gt;An Array is a list, with the items listed in a particular order, surrounded by square brackets &lt;code&gt;[]&lt;/code&gt;. &lt;br&gt;
To declare an array, define the variable type with square brackets:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;['This', 'is', 'an', 'array', 'of', 'strings.'];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The members or elements in an Array can be data of any type in JavaScript:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;['Hi there!', 502, null, NaN];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Arrays are ordered, meaning that the elements in them will always appear in the same order. So for example the Array &lt;code&gt;[1, 2, 3, 4]&lt;/code&gt; is different from the Array &lt;code&gt;[4, 3, 2, 1]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Just like any other type of JavaScript data, we can assign an Array to 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 primes = [2, 3, 5, 7, 11, 13,]; 
const shows = ['Game of Thrones', 'True Detective', 'Empire'];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We can find out how many elements an Array contains by checking the Array's built-in length property:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myArray = ['This', 'array', 'has', 5, 'elements'];
myArray.length;
// =&amp;gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruits = ['Apple', 'Banana']
console.log(fruits.length)
// 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Access the Elements in an Array
&lt;/h3&gt;

&lt;p&gt;Every element in an Array is assigned a unique index value that corresponds to its place within the collection. The first element in the array is at index 0, the fifth element at index 4, and the 128th element at index 127, and all can be manipulated with various methods. &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%2F88fadkbz4fzb57i2pmlk.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%2F88fadkbz4fzb57i2pmlk.jpg" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To access an element, we use the computed member access operator - "square brackets", most people just call it bracket notation or the bracket operator.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const winningNumbers = [32, 9, 14, 33, 48, 5];
// =&amp;gt; undefined

winningNumbers[0];
// =&amp;gt; 32

winningNumbers[3];
// =&amp;gt; 33
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Add Elements to an Array
&lt;/h3&gt;

&lt;p&gt;JavaScript allows us to manipulate the members in an Array with &lt;code&gt;.push()&lt;/code&gt; and &lt;code&gt;.unshift()&lt;/code&gt; methods.&lt;/p&gt;

&lt;p&gt;With the &lt;code&gt;.push()&lt;/code&gt; method, we can add elements to the end of an Array:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const fruits = ["Apple", "Banana", "Orange"];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fruits.push("Lemon");&lt;/code&gt;&lt;br&gt;
&lt;code&gt;// =&amp;gt; 4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fruits;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;// =&amp;gt; ["Apple", "Banana", "Orange", "Lemon"]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can also .unshift() elements onto the &lt;strong&gt;beginning&lt;/strong&gt; of 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;const cities = ['New York', 'San Francisco', 'Atlantic City'];

cities.unshift('Los Angeles');
// =&amp;gt; 3

cities;
// =&amp;gt; ["Los Angeles", "New York", "San Francisco", "Atlantic City"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Remove Elements from an Array
&lt;/h3&gt;

&lt;p&gt;As complements for &lt;code&gt;.push()&lt;/code&gt; and &lt;code&gt;.unshift()&lt;/code&gt;, respectively, we have &lt;code&gt;.pop()&lt;/code&gt; and &lt;code&gt;.shift()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.pop()&lt;/code&gt; method removes the last element in an Array, destructively updating the original Array:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];

days.pop();
// =&amp;gt; "Sun"

days;
// =&amp;gt; ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;.shift()&lt;/code&gt; method removes the first element in an Array, also mutating the original:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];

days.shift();
// =&amp;gt; "Mon"

days;
// =&amp;gt; [Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Spread Operator - Important feature of ES6
&lt;/h3&gt;

&lt;p&gt;ECMAScript 6 (ES6 or ECMAScript 2015 ) was the second major revision to JavaScript. ES2015 introduced the spread operator, which looks like an ellipsis: .... &lt;/p&gt;

&lt;p&gt;The spread operator allows us to spread out the contents of an existing Array into a new Array, adding new elements but preserving the original:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const coolCities = ['New York', 'San Francisco'];

const allCities = ['Los Angeles', ...coolCities];

coolCities;
// =&amp;gt; ["New York", "San Francisco"]

allCities;
// =&amp;gt; ["Los Angeles", "New York", "San Francisco"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Arrow Functions - Important feature of ES6
&lt;/h3&gt;

&lt;p&gt;Arrow functions allow a short syntax for writing function expressions. You don't need the &lt;code&gt;function&lt;/code&gt; keyword, the &lt;code&gt;return&lt;/code&gt; keyword, and the curly brackets.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ES5
var x = function(x, y) {
   return x * y;
}

// ES6
const x = (x, y) =&amp;gt; x * y;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;reduce&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt; methods
&lt;/h2&gt;

&lt;p&gt;These are the collection-processing methods you should memorize and practice heavily. &lt;/p&gt;

&lt;p&gt;Now that you have written &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;reduce&lt;/code&gt;, here's the big reveal: JavaScript already has these methods built into its Array data type!&lt;/p&gt;
&lt;h2&gt;
  
  
  Use map to Transform an Array
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 40].map(function(a) {
  return a * 2;
}); //=&amp;gt; [20, 40, 60, 80]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Use reduce to Reduce an Array to a Value
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[10, 20, 30, 40].reduce(function(memo, i) { return memo + i }) //=&amp;gt; 100
[10, 20, 30, 40].reduce(function(memo, i) { return memo + i }, 100) //=&amp;gt; 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;JavaScript loves functions and by being able to pass functions around comfortably, we can take advantage of methods that JavaScript gives us! Given what you know about writing your own map and reduce functions, read the JavaScript documentation and make sure you know how to use the versions JavaScript provides you: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;map&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce" rel="noopener noreferrer"&gt;reduce&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;filter()&lt;/code&gt; method
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;filter()&lt;/code&gt; method creates a new array with all elements that pass the test implemented by the provided function.&lt;/p&gt;

&lt;p&gt;The syntax snippet is provided as:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let newArray = arr.filter(callback(currentValue[, index[, array]]) {
  // return element for newArray, if true
}[, thisArg]);

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

&lt;/div&gt;

&lt;h5&gt;
  
  
  Parameters:
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;callback&lt;/code&gt; - the function is a predicate, to test each element of the array. Return a value that coerces to true to keep the element, or to false otherwise. &lt;code&gt;callback&lt;/code&gt; is invoked with three arguments:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;the value of the element&lt;/code&gt;&lt;br&gt;
&lt;code&gt;the index of the element&lt;/code&gt;&lt;br&gt;
`the Array object being traversed&lt;/p&gt;

&lt;p&gt;It accepts three arguments:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;currentValue&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
The current element being processed in the array.&lt;br&gt;
Here, we're told that on an Array (arr), we add a &lt;code&gt;.filter&lt;/code&gt;, and then, between (), we provide a callback and a &lt;code&gt;thisArg&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;index&lt;/code&gt; Optional&lt;/strong&gt;&lt;br&gt;
The index of the current element being processed in the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;array&lt;/code&gt; Optional&lt;/strong&gt;&lt;br&gt;
The array filter was called upon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;thisArg&lt;/code&gt; Optional&lt;/strong&gt;&lt;br&gt;
Value to use as this when executing &lt;code&gt;callback&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;JavaScript will move through the Array that filter() was invoked on and pass the element, the index of that element, and the whole array to the callback.&lt;/p&gt;

&lt;p&gt;We don't have to add parameters for index or array, or element even. We can name our parameters whatever we like. JavaScript always makes those 3 arguments available to our callback. See examples below to see how we can play with this. Now, what happens in a callback? &lt;/p&gt;

&lt;p&gt;The documentation tells us:&lt;br&gt;
&lt;code&gt;Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise. It accepts three arguments&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This function runs and has access to the parameters we just explained.&lt;/p&gt;

&lt;p&gt;If the call to callback returns true, that element will be added to an invisible "keeper" Array; else, it's left out.&lt;/p&gt;

&lt;p&gt;We can use the element or the array or the index or (more typically) some interaction between them to create an expression that returns a Boolean value from the callback.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example: Find all prime numbers in an array
&lt;/h4&gt;

&lt;p&gt;The following example returns all prime numbers in the array&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%2F4e2v81jcbd206vyl8oas.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%2F4e2v81jcbd206vyl8oas.png" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn more, check the official &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" rel="noopener noreferrer"&gt;MDN&lt;/a&gt; documentation and JS examples: &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/ivanadokic" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F313267%2Ff21aa287-b398-4faf-8420-3fe47acf649c.jpeg" alt="ivanadokic"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/ivanadokic/hoisting-in-javascript-let-const-and-var-4dcg" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Hoisting in JavaScript — let, const, and var&lt;/h2&gt;
      &lt;h3&gt;Ivana ・ Jun 17 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#react&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#ruby&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#rails&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>array</category>
    </item>
    <item>
      <title>Median of Dynamic Stream of Integers</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 28 Feb 2021 04:40:09 +0000</pubDate>
      <link>https://dev.to/ivanadokic/dynamic-stream-of-integers-median-m3o</link>
      <guid>https://dev.to/ivanadokic/dynamic-stream-of-integers-median-m3o</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Running median, moving median, continuous median, or median from the dynamic stream of integers are all the names for the same and well-known coding problem. You are given with dynamic stream of integers, coming one after another randomly and unsorted and you have to find the median of the current received set of integers. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Let's first define what is median
&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%2Fxj2ijrz3e16f8c4fb53x.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%2Fxj2ijrz3e16f8c4fb53x.png" alt="Alt Text" width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The median is the "middle" value of a sorted set of numbers. To find the median, you must first sort your set of integers in non-decreasing order. Then, if there is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;odd number&lt;/strong&gt; of integers, the middle element is the median. For example, in the ordered set: &lt;code&gt;2, 5, 6, 8, 10&lt;/code&gt; the median is &lt;code&gt;6&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;even number&lt;/strong&gt; of integers, there's no middle element; the median is computed as the average of the two middle elements. Example in the ordered set: &lt;code&gt;3, 4, 7, 8, 10, 15&lt;/code&gt; the median is &lt;code&gt;(7 + 8) / 2 = 7.5&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Formalize the dynamic stream statement
&lt;/h2&gt;

&lt;p&gt;We need to write a function to get a median number of dynamic stream. Let's think about the dynamic stream (running/moving/continuous) median as an array of numbers that you are reading in one after another and after each number you want to print the median of all numbers.&lt;/p&gt;

&lt;p&gt;How we are going to do this?&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Heap Data Structure
&lt;/h2&gt;

&lt;p&gt;One of the most effective ways of solving this is a Heap Data Structure. &lt;/p&gt;

&lt;p&gt;A Heap is a special Tree-based data structure in which the tree is a complete binary tree. There are in general two types of heap Max-Heap and Min-Heap.&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%2Fz2kizk4kgrjw2464pd7x.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%2Fz2kizk4kgrjw2464pd7x.png" alt="Alt Text" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  In a Min-Heap:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;The root node has the minimum value.&lt;/li&gt;
&lt;li&gt;The value of each node is equal to or greater than the value of its parent node.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  In a Max-Heap:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;The root node has the maximum value.&lt;/li&gt;
&lt;li&gt;The value of each node is equal to or less than the value of its parent node.&lt;/li&gt;
&lt;/ol&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%2Frj3iy2lvuhkgpi0ue1qs.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%2Frj3iy2lvuhkgpi0ue1qs.png" alt="Alt Text" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Actually, the Heap approach is the perfect solution for our problem because it allows us to efficiently pull out the biggest element (maximum value) or smallest element (minimum value):&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%2Fvi8hmw0mp1n4r7m363le.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%2Fvi8hmw0mp1n4r7m363le.png" alt="Alt Text" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a number comes we will first compare it with the current median and put it to the appropriate Heap. If the new integer value is less than the current median, we put it into the max-heap else we put it to the min-heap. &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Let's turn to the code
&lt;/h2&gt;

&lt;p&gt;In Java, the &lt;code&gt;PriorityQueue&lt;/code&gt; class represents a heap. As per definition PriorityQueue in Java is a special type of queue wherein all the elements are ordered as per their natural ordering or based on a custom Comparator supplied at the time of creation. Let's divide the solution into 4 main steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 1. &lt;code&gt;getMedians&lt;/code&gt; function
&lt;/h3&gt;

&lt;p&gt;That's going to take an integer array and return an array of doubles 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%2Fa04fk812gl7m4rjcyqly.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%2Fa04fk812gl7m4rjcyqly.png" alt="Alt Text" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 2. &lt;code&gt;addNumber&lt;/code&gt; method
&lt;/h3&gt;

&lt;p&gt;that will take in number, &lt;code&gt;priorityQueue&lt;/code&gt; of the lowers and highers like this:&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%2F12sxvnfufxj0c42tf9uf.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%2F12sxvnfufxj0c42tf9uf.png" alt="Alt Text" width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 3. &lt;code&gt;rebalance&lt;/code&gt; method
&lt;/h3&gt;

&lt;p&gt;Rebalancing works by moving the largest element from the max-heap to the min-heap, or by moving the smallest element from the min-heap to the max-heap: &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%2F3mhobwvomr2evykuycq6.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%2F3mhobwvomr2evykuycq6.png" alt="Alt Text" width="800" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 4. &lt;code&gt;getMedian&lt;/code&gt; method
&lt;/h3&gt;

&lt;p&gt;This method will look into two Heap sizes, if they are different take the top element from the larger Heap. If they are the same size we will need to average them:&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%2Fofa07lp0v2wcwlfw93k6.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%2Fofa07lp0v2wcwlfw93k6.png" alt="Alt Text" width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Thank you for reading!
&lt;/h4&gt;

&lt;p&gt;Github repo can be found &lt;a href="https://github.com/ivanadokic/Median-Dynamic-Stream" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>java</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Build a Spoken Universal Translator with Node-RED and Watson AI services</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Mon, 22 Feb 2021 01:43:26 +0000</pubDate>
      <link>https://dev.to/ivanadokic/how-to-build-a-spoken-universal-translator-with-node-red-and-watson-ai-services-3pdb</link>
      <guid>https://dev.to/ivanadokic/how-to-build-a-spoken-universal-translator-with-node-red-and-watson-ai-services-3pdb</guid>
      <description>&lt;h1&gt;
  
  
  What is Node-RED?
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://nodered.org/" rel="noopener noreferrer"&gt;Node-RED&lt;/a&gt; is a low-code programming environment for event-driven applications. It's a programming tool for wiring together hardware devices, APIs, and online services in new and interesting ways.&lt;/p&gt;

&lt;p&gt;At the core of Node-RED is Node.js a JavaScript runtime environment built on Chrome's V8 JavaScript engine. Top 5 reasons to use Node-RED can be found &lt;a href="https://developer.ibm.com/blogs/top-5-reasons-to-use-node-red-right-now/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's build a spoken universal translator using Node-RED and Watson AI services
&lt;/h2&gt;

&lt;p&gt;We will build a universal translator by using a Node-RED Starter application to connect with those Watson AI services: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Speech to Text&lt;/li&gt;
&lt;li&gt;Language Translator&lt;/li&gt;
&lt;li&gt;Text to Speech&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%2Fdpbrpmrd9baso5d2a3bx.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%2Fdpbrpmrd9baso5d2a3bx.png" alt="Alt Text" width="800" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.ibm.com/tutorials/how-to-create-a-node-red-starter-application/" rel="noopener noreferrer"&gt;Node-RED Starter application&lt;/a&gt; includes a Node-RED Node.js web server and a Cloudant database to store the Node-RED flows.&lt;/p&gt;

&lt;h4&gt;
  
  
  We will learn how to:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a &lt;strong&gt;Node-RED starter&lt;/strong&gt; app running in IBM Cloud. Create instances of the Watson services: Speech to Text, Text to Speech, and Language Translator and how to connect those services to your Node-Red app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Launch and configure the Node-RED visual programming editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install additional Node-RED nodes and create flows that use the Watson services to create the spoken universal translator.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;This app can be completed using an IBM Cloud Lite account.&lt;/p&gt;

&lt;p&gt;Create an &lt;a href="https://cloud.ibm.com/registration?cm_sp=ibmdev-_-developer-tutorials-_-cloudreg" rel="noopener noreferrer"&gt;IBM Cloud account&lt;/a&gt;&lt;br&gt;
Log into &lt;a href="https://cloud.ibm.com/login?cm_sp=ibmdev-_-developer-tutorials-_-cloudreg" rel="noopener noreferrer"&gt;IBM Cloud&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1 – Let's create a Node-RED Starter App
&lt;/h1&gt;

&lt;p&gt;Follow these steps to create a Node-RED Starter application in IBM Cloud.&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%2F7h9yhwwgc9lv1vuzx7in.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%2F7h9yhwwgc9lv1vuzx7in.png" alt="Alt Text" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Log in to your IBM Cloud account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Catalog &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for node-red &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Starter Kits category, then select Node-RED Starter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a unique name for your application, it will be part of the application URL :&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%2F849vm4y4s1f93oa0mtfs.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%2F849vm4y4s1f93oa0mtfs.png" alt="Alt Text" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Region, Organization, and Space fields will be pre-populated with valid options for your IBM Cloud account. I have a Lite account and I just accepted the defaults. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Selected Plan section, choose Lite.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Create button.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Node-RED Starter application will be provisioned in the IBM Cloud region that was specified. This process is called staging an application. &lt;/p&gt;

&lt;h1&gt;
  
  
  Step 2 – Let's create the Watson AI service instances
&lt;/h1&gt;

&lt;p&gt;You can add Watson AI microservices to your application as APIs, through instances that you can manage through credentials. We will create and bind these microservices to your Cloud Foundry application. There are three Watson AI services, all available in the &lt;em&gt;IBM Cloud Lite tier&lt;/em&gt;, needed to build a universal translator:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Watson Speech to Text&lt;/li&gt;
&lt;li&gt;Watson Text to Speech&lt;/li&gt;
&lt;li&gt;Watson Language Translator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In IBM Cloud Catalog search for speech and navigate to the AI category:&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%2Fjgzhwggn3fl4gyhqbzel.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%2Fjgzhwggn3fl4gyhqbzel.png" alt="Alt Text" width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;Speech to Text&lt;/strong&gt;, and click the Create button.&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%2F7dpxfbqrgj16b1dgwsf4.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%2F7dpxfbqrgj16b1dgwsf4.png" alt="Alt Text" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Return to the AI category in the IBM Cloud Catalog, and select &lt;strong&gt;Text to Speech&lt;/strong&gt;, and click the Create button:&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%2Fnlqj3oadcz3dmcwzw7hw.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%2Fnlqj3oadcz3dmcwzw7hw.png" alt="Alt Text" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In IBM Cloud Catalog, search for a translator, navigate to the AI category, select &lt;strong&gt;Language Translator&lt;/strong&gt;, and click the Create button, I already had the one: &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%2Fa0kg5c3jcqkm3i0rjt24.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%2Fa0kg5c3jcqkm3i0rjt24.png" alt="Alt Text" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 3 – Let's connect the Watson AI Services to the Node-RED Starter Application
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;a href="https://cloud.ibm.com/resources?cm_sp=ibmdev-_-developer-tutorials-_-cloudreg" rel="noopener noreferrer"&gt;IBM Cloud Dashboard&lt;/a&gt; navigate to the Apps section and select Node-RED universal-translator (your apps unique name):&lt;/li&gt;
&lt;/ol&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%2F147tyk7n742cf5j1q20f.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%2F147tyk7n742cf5j1q20f.png" alt="Alt Text" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Applications Details opens, search for the Watson services that you created in the previous step and press the Connect button. Once it's connected you will have those Services ( Speech to Text, Text to Speech, and Language Translator ) connected like this: &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%2Fwyohkndk5xgayjwiu11r.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%2Fwyohkndk5xgayjwiu11r.png" alt="Alt Text" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 4 – Launch your Node-RED app and open the Node-RED visual programming editor
&lt;/h1&gt;

&lt;p&gt;Node-RED is an open-source Node.js application that provides a visual programming editor that makes it easy to wire together flows.&lt;/p&gt;

&lt;p&gt;The first time you start the Node-RED app, it will help you configure the visual programming editor. Once the Green Running icon appears, click the View App URL link, a new browser tab opens to the Node-RED start page: &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%2Fuhmw6h2o1gpltwwkgjz0.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%2Fuhmw6h2o1gpltwwkgjz0.png" alt="Alt Text" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A new browser tab opens to the Node-RED start page.&lt;/p&gt;

&lt;p&gt;Use the setup wizard to secure your editor with a user name and password and to browse and add more nodes. Click the Finish button to proceed: &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%2F8zj68d52pwgbxszy5u96.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%2F8zj68d52pwgbxszy5u96.png" alt="Alt Text" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the Go to your Node-RED flow editor button to launch the Node-RED flow editor:&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%2Fwlhwuatjglmcjujjmnsx.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%2Fwlhwuatjglmcjujjmnsx.png" alt="Alt Text" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the Person icon in the upper right corner, and Sign in with your new username and password credentials and you will get a screen like this:&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%2F9qsslxb8ke41azaz8un5.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%2F9qsslxb8ke41azaz8un5.png" alt="Alt Text" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Node-RED Visual Programming Editor has a left side with a palette of nodes that you can drag onto the flow and wire nodes together to create a program.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 5 – Let's install Additional Node-RED Nodes
&lt;/h1&gt;

&lt;p&gt;The universal translator that we are building needs a &lt;strong&gt;microphone&lt;/strong&gt; to record your message and the ability to play the audio of the translation. We can add nodes to the Node-RED palette that add these capabilities, such a great thing! &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click the Node-RED Menu, and select Manage palette&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%2Frefq1uhevlz2r3slvh5k.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%2Frefq1uhevlz2r3slvh5k.png" alt="Alt Text" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Install tab, and search for &lt;em&gt;browser-utils&lt;/em&gt; and Install the &lt;strong&gt;node-red-contrib-browser-utils&lt;/strong&gt; node. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fw8gidpxydu51jz1r33hk.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%2Fw8gidpxydu51jz1r33hk.png" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search for &lt;em&gt;play-audio&lt;/em&gt;, find the &lt;strong&gt;node-red-contrib-play-audio&lt;/strong&gt; node, and click the Install button.
&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%2Fyukptsavbb1wkrp0aicd.png" alt="Alt Text" width="800" height="416"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Step 6 – Build the flows for the universal translator
&lt;/h1&gt;

&lt;p&gt;Node-RED allows you to drag and drop Nodes from the left palette onto your flow canvas and wire them together to create programs. &lt;/p&gt;

&lt;h3&gt;
  
  
  Speech-to-Text flow
&lt;/h3&gt;

&lt;p&gt;Click and drag a microphone node to your flow.&lt;/p&gt;

&lt;p&gt;Click and drag a Speech to Text node to your flow. Double-click it and select US English.&lt;/p&gt;

&lt;p&gt;Click and drag a Debug node to your flow. Double-click it and have it output msg.transcription.&lt;/p&gt;

&lt;p&gt;Wire the nodes together as shown in the screenshot below.&lt;/p&gt;

&lt;p&gt;Click the red Deploy button.&lt;/p&gt;

&lt;p&gt;Select the tab to the left of the microphone node and allow your browser access to the microphone on the laptop.&lt;/p&gt;

&lt;p&gt;Record a message, like “wow this is so much fun!”&lt;/p&gt;

&lt;h1&gt;
  
  
  Text-to-Speech flow
&lt;/h1&gt;

&lt;p&gt;Now, let’s build the Text-to-Speech flow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click and drag an Inject node to your flow and double-click it and change the payload type to a string and type a message.&lt;/li&gt;
&lt;li&gt;Click and drag a Text to Speech node to your flow, double-click it and select US English.&lt;/li&gt;
&lt;li&gt;Click and drag a Change node to your flow, double-click the Change node and assign the msg.payload to msg.speech.&lt;/li&gt;
&lt;li&gt;Click and drag a play-audio node to your flow.&lt;/li&gt;
&lt;li&gt;Wire the nodes together as shown in the screenshot below:
&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%2F28p0496xngl5r804n4ba.png" alt="Alt Text" width="800" height="175"&gt;
&lt;/li&gt;
&lt;li&gt;Press the Deploy button (the red one).&lt;/li&gt;
&lt;li&gt;Select the tab to the left of the Inject node. The audio of the message will play.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Language Translator flow
&lt;/h1&gt;

&lt;p&gt;The universal translator will use the recorded transcript as the input to the language translator node, and send the foreign language to the Text to Speech node.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click and drag another Change node to your flow, double-click it and assign msg.payload to msg.transcription like this:&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%2F3wbanqisq73ayp2dpmjd.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%2F3wbanqisq73ayp2dpmjd.png" alt="Alt Text" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click and drag a language translator node to your flow. Double-click it and select English as the Source and Croatian &lt;br&gt;
as the Target.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Ftqxsc2yr6l306b8ldjxz.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%2Ftqxsc2yr6l306b8ldjxz.png" alt="Alt Text" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click and drag a Debug node to your flow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click the Text to Speech node, and change the language to Spanish and select a voice (here I clicked and tried Croatian language but it was not available, doesn’t show it on the list and I'll stick with Spanish)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is how your final flow should look like:&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%2Fgxqu1fz166ctfryb2kja.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%2Fgxqu1fz166ctfryb2kja.png" alt="Alt Text" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, click the Deploy button (the red one) on the right top corner!&lt;/p&gt;

&lt;h1&gt;
  
  
  Final Step – let's test universal translator
&lt;/h1&gt;

&lt;p&gt;Select the tab to the left of the microphone node and allow your browser access to the microphone on the laptop and &lt;strong&gt;record a message&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can follow the process and view the translations in the &lt;strong&gt;Debug&lt;/strong&gt; tab of Node-RED: &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%2F9tuu4habq17sa9yh8smt.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%2F9tuu4habq17sa9yh8smt.png" alt="Alt Text" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Full documentation and more details on how to build Node-RED starter application using Watson services in IBM Cloud can be found &lt;a href="https://developer.ibm.com/technologies/iot/tutorials/build-universal-translator-nodered-watson-ai-services/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To connect please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>javascript</category>
      <category>node</category>
      <category>ibmwatson</category>
    </item>
    <item>
      <title>Strapi Quickstart 🚀</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Mon, 15 Feb 2021 04:56:58 +0000</pubDate>
      <link>https://dev.to/ivanadokic/strapi-quickstart-11gk</link>
      <guid>https://dev.to/ivanadokic/strapi-quickstart-11gk</guid>
      <description>&lt;p&gt;&lt;a href="https://strapi.io/" rel="noopener noreferrer"&gt;Strapi&lt;/a&gt; is the leading open-source headless content management system or headless CMS. A headless CMS provides a way to author content, but instead of having your content coupled to a particular output (like web page rendering), it provides your content as data over an API. &lt;/p&gt;

&lt;p&gt;Strapi's name comes from the word Bootstrap and helps Bootstrap your API.&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%2Fi%2Fwux00ysf1fm3pgd4t45n.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%2Fi%2Fwux00ysf1fm3pgd4t45n.png" alt="Alt Text" width="800" height="803"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A full list of Headless Content Management Systems for Jamstack Sites can be found &lt;a href="https://jamstack.org/headless-cms/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Strapi is 100% Javascript and fully customizable. From it's &lt;a href="https://strapi.io/documentation/developer-docs/latest/getting-started/introduction.html#what-is-strapi" rel="noopener noreferrer"&gt;documenation&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Strapi is a flexible, open-source Headless CMS that gives developers the freedom to choose their favorite tools and frameworks while also allowing editors to easily manage and distribute their content. &lt;/p&gt;

&lt;p&gt;By making the admin panel and API extensible through a plugin system, Strapi enables the world's largest companies to accelerate content delivery while building beautiful digital experiences. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Custom Content Structure
&lt;/h5&gt;

&lt;p&gt;You can generate the admin panel in a few clicks and get your whole CMS setup in a few minutes.&lt;/p&gt;

&lt;h5&gt;
  
  
  Easy Content Management
&lt;/h5&gt;

&lt;p&gt;Strapi's admin panel gives you an intuitive interface to create, edit and delete your content.&lt;/p&gt;

&lt;h5&gt;
  
  
  Developer-Friendly API
&lt;/h5&gt;

&lt;p&gt;Strapi provides you with an API that will easily match your needs and you can Fetch any data you might need via a REST API or GraphQL endpoint.&lt;/p&gt;

&lt;h5&gt;
  
  
  Roles &amp;amp; Permissions
&lt;/h5&gt;

&lt;p&gt;Strapi has a built-in user system that allows you to manage who can access what.&lt;/p&gt;

&lt;h5&gt;
  
  
  Customization
&lt;/h5&gt;

&lt;p&gt;Every part of your application can be easily customized. &lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Install Strapi and Create a new project
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npx create-strapi-app my-project --quickstart&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Due to dependency conflict, I received an error right there and needed to fix dependencies. This works for me:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save --legacy-peer-deps&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Description of `--legacy-peer-deps command is to ignore all peerDependencies when installing, in the style of npm version 4 through version 6. &lt;/p&gt;

&lt;p&gt;More about npm install and dependencies can be found in &lt;a href="https://docs.npmjs.com/cli/v6/commands/npm-install" rel="noopener noreferrer"&gt;Documentation for the npm registry, website, and command-line interface&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Create an Administrator user
&lt;/h3&gt;

&lt;p&gt;Navigate to &lt;a href="http://localhost:1337/" rel="noopener noreferrer"&gt;http://localhost:1337/&lt;/a&gt; and you will see:&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%2Fi%2Fs9dfdf9u1jwb8ckllw6n.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%2Fi%2Fs9dfdf9u1jwb8ckllw6n.png" alt="Alt Text" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since I got the &lt;code&gt;not Found&lt;/code&gt; error page &lt;a href="http://localhost:1337/admin" rel="noopener noreferrer"&gt;http://localhost:1337/admin&lt;/a&gt; I had to run &lt;code&gt;npm run build&lt;/code&gt; for building admin UI:&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%2Fi%2F3bcgfbocaunt7o3ho31k.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%2Fi%2F3bcgfbocaunt7o3ho31k.png" alt="Alt Text" width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to be able to complete the form to create the first Administrator user when visiting &lt;a href="http://localhost:1337/admin/auth/register-admin:" rel="noopener noreferrer"&gt;http://localhost:1337/admin/auth/register-admin:&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%2Fi%2F99nbydjmgos6h15kqnhe.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%2Fi%2F99nbydjmgos6h15kqnhe.png" alt="Alt Text" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will also need to &lt;code&gt;npm run strapi develop&lt;/code&gt; to have "+ Create new collection type" link.  For me, this link won't appear at all. After I run &lt;code&gt;npm run strapi develop&lt;/code&gt; the problem was solved and I was able to click the link "+ Create new collection type":&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%2Fi%2Frbupgp0tbrtjklu2llcm.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%2Fi%2Frbupgp0tbrtjklu2llcm.png" alt="Alt Text" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create a Restaurant Content-Type
&lt;/h3&gt;

&lt;p&gt;Navigate to PLUGINS - Content Type Builder (opens new window), in the left-hand menu.&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;"+ Create new collection type"&lt;/strong&gt; link&lt;br&gt;
Enter &lt;code&gt;restaurant&lt;/code&gt;, and click &lt;code&gt;Continue&lt;/code&gt;&lt;br&gt;
Click the &lt;strong&gt;"+ Add another Field"&lt;/strong&gt; button&lt;br&gt;
Click the &lt;strong&gt;Text&lt;/strong&gt; field&lt;br&gt;
Type &lt;code&gt;name&lt;/code&gt; in the &lt;strong&gt;Name&lt;/strong&gt; field&lt;br&gt;
Click over to the &lt;strong&gt;ADVANCED SETTINGS&lt;/strong&gt; tab, and check the &lt;code&gt;Required field&lt;/code&gt; and the &lt;code&gt;Unique field&lt;/code&gt;&lt;br&gt;
Click the &lt;strong&gt;"+ Add another Field"&lt;/strong&gt; button&lt;br&gt;
Click the &lt;strong&gt;Rich Text&lt;/strong&gt; field&lt;br&gt;
Type &lt;code&gt;description&lt;/code&gt; under the &lt;strong&gt;BASE SETTINGS&lt;/strong&gt; tab, in the &lt;strong&gt;Name&lt;/strong&gt; field&lt;br&gt;
Click &lt;code&gt;Finish&lt;/code&gt;&lt;br&gt;
Click the &lt;strong&gt;Save&lt;/strong&gt; button and wait for Strapi to restart, you should have this 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%2Fi%2Fivir752p0bd6a5j2wndf.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%2Fi%2Fivir752p0bd6a5j2wndf.png" alt="Alt Text" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s next?
&lt;/h3&gt;

&lt;p&gt;🚀Let's see what's next amazing coming after adding more features like: &lt;/p&gt;

&lt;h5&gt;
  
  
  4. Create a Category Content type
&lt;/h5&gt;

&lt;h5&gt;
  
  
  5. Add content to "Restaurant" Content Type
&lt;/h5&gt;

&lt;h5&gt;
  
  
  6. Add categories to the "Category" Content Type
&lt;/h5&gt;

&lt;h5&gt;
  
  
  7. Set Roles and Permissions
&lt;/h5&gt;

&lt;h5&gt;
  
  
  8. Publish the content
&lt;/h5&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>strapi</category>
      <category>tutorial</category>
      <category>npm</category>
    </item>
    <item>
      <title>Building Ruby on Rails app</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Mon, 08 Feb 2021 02:13:12 +0000</pubDate>
      <link>https://dev.to/ivanadokic/building-ruby-on-rails-app-1b30</link>
      <guid>https://dev.to/ivanadokic/building-ruby-on-rails-app-1b30</guid>
      <description>&lt;h1&gt;
  
  
  Ruby on Rails app with Authorization and Authentication
&lt;/h1&gt;

&lt;p&gt;Ruby on Rails is the most popular server-side web application framework that is written in Ruby (open-source programming language). It's powerful and magical! Let's work through what makes it powerful and start that initial setup and learn more about Authorization and Authentication security concepts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1.
&lt;/h3&gt;

&lt;p&gt;Create a new &lt;code&gt;store&lt;/code&gt; Rails application skipping a test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rails new store --skip-test-unit
$ cd shop
$ rake db:create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2.
&lt;/h3&gt;

&lt;p&gt;Add Bootstrap and styles&lt;br&gt;
Let’s add a ‘bootstrap-sass’ gem to our Gemfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'bootstrap-sass', '~&amp;gt; 3.3', '&amp;gt;= 3.3.6'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and bundle everything with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Add some styles to our store application, rename the &lt;code&gt;application.css&lt;/code&gt; to the &lt;code&gt;application.scss&lt;/code&gt; under the &lt;code&gt;app/assets/stylesheets&lt;/code&gt; to be able to use imports. Add these lines after the manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import "bootstrap";
@import "bootstrap-sprockets";

#main-container {
  position: relative;
  padding-top: 50px;
  padding-bottom: 50px;
}

.product-block {
  width: 750px;
}

.btn {
  font-family: Impact, fantasy;
}

body {
  background: #f19797;
  font-family: Impact, fantasy;
}

th {
  background-color: #333333;
  color: white;
}

td {
  background-color: #f8f2f2;
  color: white;
}

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

&lt;/div&gt;



&lt;p&gt;And add the following into &lt;code&gt;assets/javascript/application.js&lt;/code&gt; file, this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("bootstrap")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3. Edit views
&lt;/h3&gt;

&lt;p&gt;Replace the content of your &lt;code&gt;views/layouts/application.html.erb&lt;/code&gt; file with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Store&amp;lt;/title&amp;gt;
    &amp;lt;%= csrf_meta_tags %&amp;gt;
    &amp;lt;%= csp_meta_tag %&amp;gt;

    &amp;lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
    &amp;lt;%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
  &amp;lt;nav class="navbar navbar-inverse navbar-top navbar-fixed-top"&amp;gt;
    &amp;lt;div class="container-fluid"&amp;gt;
      &amp;lt;div class="container"&amp;gt;
        &amp;lt;div class="navbar-header"&amp;gt;
      &amp;lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&amp;gt;
        &amp;lt;span class="sr-only"&amp;gt;Toggle navigation&amp;lt;/span&amp;gt;
        &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
      &amp;lt;/button&amp;gt;
      &amp;lt;a class="navbar-brand" href="/"&amp;gt;Store app&amp;lt;/a&amp;gt;
    &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/nav&amp;gt;
  &amp;lt;div id="main-container" class="container"&amp;gt;
    &amp;lt;%= yield %&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add those 2 methods(&lt;code&gt;bootstrap_classs&lt;/code&gt; and &lt;code&gt;flash_messages&lt;/code&gt;) to &lt;code&gt;app/helpers/application_helper.rb&lt;/code&gt; which will be used to display messages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module ApplicationHelper
  def boostrap_class(alert)
    { success: 'alert-success', error: 'alert-danger', notice: 'alert-success', warning: 'alert-warning',
      danger: 'alert-danger', alert: 'alert-danger' }[alert.to_sym]
  end

  def flash_messages(_opts = {})
    flash.each do |msg_type, message|
      concat(content_tag(:div, message, class: "alert #{boostrap_class(msg_type.to_sym)} fade in") do
        concat(content_tag(:button, id: "close-button", class: "close", type: :button, data: { dismiss: 'alert' }, "aria-label" =&amp;gt; :Close) do
          concat content_tag(:span, "&amp;amp;times;".html_safe, "aria-hidden" =&amp;gt; true)
        end)
        concat message
      end)
    end
    nil
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5. Add welcome page
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;dashboard_controller.rb&lt;/code&gt; file under &lt;code&gt;app/controllers&lt;/code&gt; folder and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class DashboardController &amp;lt; ApplicationController
  def index
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a &lt;code&gt;app/views/index.html.erb&lt;/code&gt; file and make it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;%= flash_messages %&amp;gt;
&amp;lt;div class="block"&amp;gt;
    &amp;lt;header class="header-group"&amp;gt;
        &amp;lt;h2&amp;gt;Welcome to Rails Authentication and Authorization!&amp;lt;/h2&amp;gt;
    &amp;lt;/header&amp;gt;
    &amp;lt;div class="row"&amp;gt;
        &amp;lt;div class="col-md-12"&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step would be to clear and add the following code to &lt;code&gt;routes.rb&lt;/code&gt; file under the config folder:&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
  root 'dashboard#index'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5. Start an application
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;rails s&lt;/code&gt; command and got to &lt;code&gt;http://localhost:3000&lt;/code&gt; browser, it should look like this:&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%2Fi%2Fj378naflmg3sxwf94idb.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%2Fi%2Fj378naflmg3sxwf94idb.png" alt="Alt Text" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are few more steps such as creating a &lt;code&gt;product&lt;/code&gt; scaffold, add bootstrap to product files, and add products links to the navigation bar and when it's all done if you go to &lt;a href="http://localhost:3000/products/new" rel="noopener noreferrer"&gt;http://localhost:3000/products/new&lt;/a&gt; you will see:&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%2Fi%2Fqtmjlndn7ls08xmrg1ni.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%2Fi%2Fqtmjlndn7ls08xmrg1ni.png" alt="Alt Text" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6. Add authentication and authorization
&lt;/h3&gt;

&lt;p&gt;Let’s move on to a very important part – authentication and authorization.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The next step will be to add authentication and authorization, but I would like first to deep dive into this concept which is very often misunderstood.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Breaking Down the Authentication and Authorization Problem
&lt;/h2&gt;

&lt;p&gt;It's important to have a general understanding of their meaning. We can divide the &lt;strong&gt;"who can see what"&lt;/strong&gt; problem into four smaller security concepts:&lt;br&gt;
&lt;strong&gt;Identification&lt;/strong&gt; Who you claim to be &lt;br&gt;
&lt;strong&gt;Authentication&lt;/strong&gt; Validation that you are you who you claim to be&lt;br&gt;
&lt;strong&gt;Access Policy&lt;/strong&gt; Association of roles based on your identity, what given roles are allowed to do&lt;br&gt;
&lt;strong&gt;Authorization&lt;/strong&gt; Mechanisms to enforce the Access Policy &lt;/p&gt;

&lt;h3&gt;
  
  
  Examples of Authentication and Authorization FLOWS
&lt;/h3&gt;

&lt;p&gt;If you were to enter your local bank branch, here's how these concepts would apply.&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%2Fi%2Fk22yaru69cg8ma66fo0v.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%2Fi%2Fk22yaru69cg8ma66fo0v.jpg" alt="Alt Text" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  First - Identification
&lt;/h4&gt;

&lt;p&gt;Assert who you are by stating your name and showing an ID.&lt;/p&gt;

&lt;h4&gt;
  
  
  Second - Authentication
&lt;/h4&gt;

&lt;p&gt;Verify your identity claim by verifying you possess a secret that only the "real you" would know and which has been established prior to this moment like a password or matching signature.&lt;/p&gt;

&lt;h4&gt;
  
  
  Third - Access Policy
&lt;/h4&gt;

&lt;p&gt;Interlude At this point the bank knows that they are dealing with a verified entity. From the perspective of their system, all verified entities act with respect to roles. At the point of Authentication, the verified entity's collection of roles is also retrieved. This is the point where the association of roles based on your identity was given.&lt;/p&gt;

&lt;h4&gt;
  
  
  Fourth - Authorization
&lt;/h4&gt;

&lt;p&gt;You then proceed to withdraw enough money. At this point, the Access Policy &lt;em&gt;("As an owner of an account, the owner is permitted to withdraw money from that account provided")&lt;/em&gt; is implemented in an activity known as Authorization. Since your authentication step validated you in the role of owner, this transaction proceeds.&lt;/p&gt;

&lt;p&gt;If you try again, your roles owner and customer have a "NO ACCESS" Access Policy as relates to the bank's vault and you will not be Authorized and cannot enter the bank vault.&lt;/p&gt;

&lt;p&gt;Commonly used Gems for &lt;strong&gt;authentications&lt;/strong&gt; are: Devise, &lt;a href="https://github.com/omniauth" rel="noopener noreferrer"&gt;OmniAuth&lt;/a&gt;, Authlogic AND for &lt;strong&gt;authorization&lt;/strong&gt;: CanCanCan, Pundit, more gem options can be found in &lt;a href="https://www.ruby-toolbox.com/search?q=authorization" rel="noopener noreferrer"&gt;Ruby Toolbox&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This &lt;strong&gt;FLOW&lt;/strong&gt; applies to users of the &lt;code&gt;store&lt;/code&gt; app. We will define its access policy and verify the identity of users.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What’s next?
&lt;/h3&gt;

&lt;p&gt;The next step will be to add authentication and authorization using some of the popular rails &lt;code&gt;Gems&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Weather App Using React</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 31 Jan 2021 03:39:02 +0000</pubDate>
      <link>https://dev.to/ivanadokic/weather-app-using-react-4143</link>
      <guid>https://dev.to/ivanadokic/weather-app-using-react-4143</guid>
      <description>&lt;h1&gt;
  
  
  Tech Stack &amp;amp; Features
&lt;/h1&gt;

&lt;p&gt;The weather app project demonstrates how to use: &lt;/p&gt;

&lt;p&gt;-&lt;a href="https://reactjs.org/docs/create-a-new-react-app.html" rel="noopener noreferrer"&gt;Create React App&lt;/a&gt; and set up a modern web app by running one command&lt;/p&gt;

&lt;p&gt;-&lt;a href="https://openweathermap.org/api" rel="noopener noreferrer"&gt;Open Weather Map API&lt;/a&gt;, 5-day forecast available at any location or city. It includes weather forecast data with a 3-hour step. The forecast is available in JSON or XML format.&lt;/p&gt;

&lt;p&gt;-&lt;a href="https://websygen.github.io/owfont/" rel="noopener noreferrer"&gt;OpenWeatherFont (owfont) Icons&lt;/a&gt;, designed to match to weather condition codes from Open Weather Map API. &lt;/p&gt;

&lt;p&gt;-&lt;a href="https://momentjs.com/" rel="noopener noreferrer"&gt;Moment.js&lt;/a&gt; to parse, validate, manipulate, and display dates and times in JavaScript&lt;/p&gt;

&lt;p&gt;-&lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt; the world’s most popular framework for building responsive, mobile-first sites.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Those are weather app features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Shows the 5-day forecast for a specific city&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include a weather icon temperature reading and description of weather conditions ☀️🌤⛈❄️&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Getting Started
&lt;/h1&gt;

&lt;h2&gt;
  
  
  STEP 1
&lt;/h2&gt;

&lt;p&gt;To get started, run the following code in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;create-react-app weather-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And right on a begging after I run &lt;code&gt;npm start&lt;/code&gt; I get this error with instruction to fix the dependency tree, try following the steps below in the exact order:&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%2Fi%2Fgbvveny1cgti3azf2b0j.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%2Fi%2Fgbvveny1cgti3azf2b0j.png" alt="Alt Text" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tried to follow and troubleshoot but everything fails, so I created a &lt;code&gt;.env&lt;/code&gt; file in the root directory and added &lt;code&gt;SKIP_PREFLIGHT_CHECK=true&lt;/code&gt;, and relaunch with &lt;code&gt;npm start&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This worked for me and I could see my React app update live on a localhost server: &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%2Fi%2Fnsb09cwc78ncqo2pq7j9.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%2Fi%2Fnsb09cwc78ncqo2pq7j9.png" alt="Alt Text" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 2
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;WeekContainer.js&lt;/code&gt; - class component was created as a new file in the &lt;code&gt;src folder&lt;/code&gt; and imported into App.js:&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, { Component } from 'react';
import './App.css';
import WeekContainer from './WeekContainer';

class App extends Component {
  render() {
    return (
      &amp;lt;div className="App"&amp;gt;
        &amp;lt;WeekContainer /&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

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

&lt;/div&gt;



&lt;p&gt;Live updates on a local host look like this, and everything is properly rendered on screen:&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%2Fi%2Fpp6py882migk7zk37y05.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%2Fi%2Fpp6py882migk7zk37y05.png" alt="Alt Text" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  STEP 3
&lt;/h3&gt;
&lt;h4&gt;
  
  
  How to get Weather Data for WeekContainer
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;WeekContainer&lt;/code&gt;'s "job" will be to hold 5 “weather cards”, each representing a day of the week.&lt;/p&gt;

&lt;p&gt;In order to do this, we will first need to &lt;code&gt;fetch&lt;/code&gt; the data from the API. OpenWeatherMap is one of my favorite API providing weather information. There are few steps to getting an API key that will be explained below.&lt;/p&gt;
&lt;h3&gt;
  
  
  STEP 4
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Getting an API Key
&lt;/h4&gt;

&lt;p&gt;-Sign up for an account on the OpenWeatherMap website &lt;a href="https://openweathermap.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;-You will receive an email with an API key that will activate within a few hours of receiving the email (from my experience it will only take 10 minutes).&lt;/p&gt;

&lt;p&gt;This is an example of an API call:&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%2Fi%2Fxan5i3590ce4i80ma5wi.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%2Fi%2Fxan5i3590ce4i80ma5wi.png" alt="Alt Text" width="800" height="661"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-Create a file (maybe called keys.js) within the src folder and add your API key to it and add the newly created file to your .gitignore so once its push to git it will be “ignored”.&lt;/p&gt;

&lt;p&gt;-Import the hidden file within WeekContainer.js so you can use string interpolation to use your API key in the fetch request without giving away your API key on GitHub, hope this will work well!&lt;/p&gt;

&lt;p&gt;Here, we’re specifying for the response to be specifically for zip code 11001:&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 apiConfig from './keys';

class WeekContainer extends React.Component {
  render() {


    const weatherURL =
      `http://api.openweathermap.org/data/2.5/forecast?zip=11001${apiConfig.owmKey}`
//You can search weather forecast with data by city name

    return (
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;We will have a Weather app soon!&amp;lt;/h1&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}

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

&lt;/div&gt;



&lt;p&gt;More info about Open Weather Map API' available parameters can be found &lt;a href="https://openweathermap.org/api" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 5
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Fetching from the Open Weather Map API
&lt;/h4&gt;

&lt;p&gt;Now it’s time to fetch! Let's create a componentDidMount method with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentDidMount = () =&amp;gt; {
      const weatherURL =
        `http://api.openweathermap.org/data/2.5/forecast?zip=11001${apiConfig.owmKey}`
      fetch(weatherURL)
        .then(res =&amp;gt; res.json())
        .then(data =&amp;gt; console.log("Data List Loaded", data.list))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just a beginning and I will write more about how to Filter and render Card for each day and add Bootstrap.&lt;/p&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting started with Gatsby</title>
      <dc:creator>Ivana</dc:creator>
      <pubDate>Sun, 24 Jan 2021 06:23:55 +0000</pubDate>
      <link>https://dev.to/ivanadokic/getting-started-with-gatsby-4lbj</link>
      <guid>https://dev.to/ivanadokic/getting-started-with-gatsby-4lbj</guid>
      <description>&lt;p&gt;&lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; is a React-based open-source framework for creating websites and apps. It's &lt;strong&gt;the #1 fastest growing framework&lt;/strong&gt;, great whether you're building a portfolio site or blog, or a high-traffic e-commerce store or company homepage.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's start
&lt;/h1&gt;

&lt;h4&gt;
  
  
  1. Create a new site
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;npm init gatsby&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Follow the prompts to choose your preferred CMS, styling tools, and additional features:&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%2Fi%2F7uziwyr4wy7nnnf9clfz.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%2Fi%2F7uziwyr4wy7nnnf9clfz.png" alt="Alt Text" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Start the local development server
&lt;/h4&gt;

&lt;p&gt;Start by going to the directory with &lt;code&gt;cd my-gatsby-site&lt;/code&gt;&lt;br&gt;
and start the local development server with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Gatsby will start a hot-reloading development environment accessible by default at &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt;. Usually, &lt;code&gt;npm run develop&lt;/code&gt; command can be used to build your site into development mode without any issues. But, sometimes errors happen and didn't work for me right away, I get this error returned:&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%2Fi%2Fcnx256s55b56ew1sdebb.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%2Fi%2Fcnx256s55b56ew1sdebb.png" alt="Alt Text" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This error tells that &lt;code&gt;"trackingId"&lt;/code&gt; can't be set as empty...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Invalid plugin options for "gatsby-plugin-google-analytics":
- "trackingId" is not allowed to be emptySetting up Google Analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use &lt;code&gt;gatsby-plugin-google-analytics&lt;/code&gt; to track site activity and provide insights into how users access your website.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's get your Google Analytics &lt;code&gt;trackingId&lt;/code&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to your Google Analytics account.&lt;/li&gt;
&lt;li&gt;Click Admin.&lt;/li&gt;
&lt;li&gt;Select an account from the menu in the ACCOUNT column.&lt;/li&gt;
&lt;li&gt;Select a property from the menu in the PROPERTY column.&lt;/li&gt;
&lt;li&gt;Under Property, click Tracking Info &amp;gt; Tracking Code. Your Tracking ID is displayed at the top of the page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you get &lt;code&gt;trackingId&lt;/code&gt; go to your gatsby-config.js file and replace 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%2Fi%2Fzjdtjuf6k384rd7egzd2.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%2Fi%2Fzjdtjuf6k384rd7egzd2.png" alt="Alt Text" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;npm run develop&lt;/code&gt; and Gatsby will start a development environment accessible by default at &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt; mine looked 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%2Fi%2Fkm96x6at6k7xsxr8xx8f.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%2Fi%2Fkm96x6at6k7xsxr8xx8f.png" alt="Alt Text" width="800" height="944"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Make changes
&lt;/h4&gt;

&lt;p&gt;Now you’re ready to make changes to your site by editing the home page in &lt;code&gt;src/pages/index.js&lt;/code&gt;, saved changes will live reload in the browser.&lt;/p&gt;

&lt;p&gt;This was a quick start, for intermediate to advanced developers. For a gentler intro to Gatsby and more details check this &lt;a href="https://www.gatsbyjs.com/tutorial/" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Add more &lt;a href="https://www.gatsbyjs.com/docs/recipes/" rel="noopener noreferrer"&gt;features&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Install and configure additional plugins to quickly add additional functionality to your site.&lt;/p&gt;

&lt;h4&gt;
  
  
  Deploy your site using &lt;a href="https://www.gatsbyjs.com/cloud/" rel="noopener noreferrer"&gt;Gatsby Cloud&lt;/a&gt;.
&lt;/h4&gt;

&lt;p&gt;Can't wait to connect with Gatsby community members from all over the world and learn about the newest developments from the Gatsby team, &lt;strong&gt;March 2-3, 2021&lt;/strong&gt;  &lt;strong&gt;ONLINE&lt;/strong&gt;, &lt;a href="https://gatsbyconf.com/https://ctt.ec/cdhcQ+" rel="noopener noreferrer"&gt;Join me here!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To connect with me please check my &lt;a href="https://github.com/ivanadokic" rel="noopener noreferrer"&gt;Github&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/ivana-dokic/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/LloydPile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>gatsby</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
