<?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: Armen Ghazaryan</title>
    <description>The latest articles on DEV Community by Armen Ghazaryan (@armenzet).</description>
    <link>https://dev.to/armenzet</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%2F927010%2F25d97093-5de8-4ea7-ba43-1fa784749369.png</url>
      <title>DEV Community: Armen Ghazaryan</title>
      <link>https://dev.to/armenzet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/armenzet"/>
    <language>en</language>
    <item>
      <title>JS Functions</title>
      <dc:creator>Armen Ghazaryan</dc:creator>
      <pubDate>Wed, 07 Dec 2022 10:22:00 +0000</pubDate>
      <link>https://dev.to/armenzet/js-functions-d96</link>
      <guid>https://dev.to/armenzet/js-functions-d96</guid>
      <description>&lt;p&gt;Functions are statements that perform some tasks. We define function using function keyword. Then we name the function and open curly braces{}, in which the statements are written. A function performs the task when we “call” it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function age(x){
alert(x " years old")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if we write &lt;br&gt;
&lt;code&gt;age(19)&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
A window will be opened in which will be written &lt;/p&gt;

&lt;p&gt;&lt;em&gt;19 years old.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The function receives what are written in the brackets. It do the the operations with the arguments which were given and returns us the final result. We can create function once and reuse it. We can call it every time with different arguments and get different results. The variables which are declared inside the function are not visible outside the function. There also exists function composition. We can have functions inside functions.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>functional</category>
    </item>
    <item>
      <title>JS Variables</title>
      <dc:creator>Armen Ghazaryan</dc:creator>
      <pubDate>Thu, 01 Dec 2022 08:17:50 +0000</pubDate>
      <link>https://dev.to/armenzet/js-variables-1dj4</link>
      <guid>https://dev.to/armenzet/js-variables-1dj4</guid>
      <description>&lt;p&gt;JavaScript is mostly used on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web development.&lt;/li&gt;
&lt;li&gt;Web applications.&lt;/li&gt;
&lt;li&gt;Web servers.&lt;/li&gt;
&lt;li&gt;Mobile applications.&lt;/li&gt;
&lt;li&gt;Games development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;etc.&lt;/p&gt;

&lt;p&gt;It's the most used programming language in the world, used as a client-side programming language by 97.0% of all websites.&lt;/p&gt;

&lt;p&gt;As in other programing languages, in JavaScript there are different data types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strings. &lt;/li&gt;
&lt;li&gt;Arrays.&lt;/li&gt;
&lt;li&gt;Objects.&lt;/li&gt;
&lt;li&gt;Functions. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Declaring a variable is a way of storing data. It can be declared by keywords &lt;strong&gt;var&lt;/strong&gt;, &lt;strong&gt;let&lt;/strong&gt; and &lt;strong&gt;const&lt;/strong&gt;. The &lt;em&gt;var&lt;/em&gt; keyword is used in all JavaScript code from 1995 to 2015. The &lt;em&gt;let&lt;/em&gt; and &lt;em&gt;const&lt;/em&gt; keywords were added to JavaScript in 2015. If there is a need of running code in an old browser, variables should be declared with &lt;em&gt;var&lt;/em&gt;.&lt;br&gt;
There are some restrictions that we need to follow at a time of getting name to the variable. We cannot use spaces or tabs, and the name cannot start with the number. Names of variables are case sensitive: words with uppercase and lowercase letters are different.&lt;/p&gt;

&lt;p&gt;Variables can contain different types of information: Numbers, Strings, Booleans, etc. &lt;/p&gt;

&lt;p&gt;String is used with double or single quotes and contains a group of characters. &lt;br&gt;
Boolean data type has two values: true and false.&lt;/p&gt;

&lt;p&gt;Here is how variables are declared:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var name = "Armen";
let AUAstudent = true;
const age = 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we use the &lt;em&gt;const&lt;/em&gt; for declaring variable, then the variable cannot be changed or reassigned.&lt;/p&gt;

&lt;p&gt;We can change the value of the variables declared with &lt;em&gt;let&lt;/em&gt; or &lt;em&gt;var&lt;/em&gt;. For example:&lt;br&gt;
&lt;code&gt;let course = “Introduction to Computer Science”;&lt;/code&gt;&lt;br&gt;
for changing the variable course we write:&lt;br&gt;
&lt;code&gt;course = “Linear Algebra”;&lt;/code&gt;&lt;br&gt;
In this way we assign a new value to the variable.&lt;/p&gt;

&lt;p&gt;We can also do mathematical operations inside the variables, such &lt;br&gt;
as&lt;br&gt;
&lt;code&gt;let a = 5+6;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The main difference between &lt;em&gt;var&lt;/em&gt; and &lt;em&gt;let&lt;/em&gt; is the scope. Via scopes we can know where the variable can be used.&lt;br&gt;
There are two type of scopes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;global&lt;/li&gt;
&lt;li&gt;local &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Global variables can be redeclared outside of a block, and they are accessible from every point of the code. Its &lt;strong&gt;var&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Local variables are declared inside of a block. Its &lt;strong&gt;let&lt;/strong&gt;. Let variables need to be declared before use.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let&lt;/em&gt; allows us to declare variables which are limited to a block statement but &lt;em&gt;var&lt;/em&gt; lets us redeclare the variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x = 17
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;x is global variable here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function() {
let n = 11
alert(n)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;n is local variable here.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>variable</category>
    </item>
    <item>
      <title>Binary numbers</title>
      <dc:creator>Armen Ghazaryan</dc:creator>
      <pubDate>Thu, 15 Sep 2022 22:12:38 +0000</pubDate>
      <link>https://dev.to/armenzet/binary-numbers-566e</link>
      <guid>https://dev.to/armenzet/binary-numbers-566e</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;A binary number is a number expressed in the base-2 numeral system by using only two symbols: 0 and 1. It is just like counting in decimal except we reach 10 much sooner. We start with 0 then 1 and after which we start with 0 again but already with 1 on the left side (10). This is the language which is used to speak with all computer-based devices. Besides the binary there are also 8-based 16 based representations. This is also the base of Boolean algebra: 0 is False, 1 is True.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to convert decimal to binary
&lt;/h2&gt;

&lt;p&gt;Let's consider a decimal number 46 and try to convert it to binary.&lt;br&gt;
46/2 will be 23 and 0 reminder&lt;br&gt;
23/2=11, 1 reminder&lt;br&gt;
11/2=5, 1 reminder&lt;br&gt;
5/2=2, 1 reminder&lt;br&gt;
2/2=1, 0 reminder&lt;br&gt;
2/2= 1&lt;br&gt;
So the representation of 46 in binary will be 101110 from below to above.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to convert Binary to decimal
&lt;/h2&gt;

&lt;p&gt;Now let's try to convert 11011001 binary number into decimal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zvFYihNe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u17thpac9ymzb3kq4k5e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zvFYihNe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u17thpac9ymzb3kq4k5e.jpg" alt="Image description" width="240" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Order start from right to left and we start count from 0.&lt;br&gt;
11011001&lt;br&gt;
&lt;em&gt;76543210&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then we are summing up all numbers multiplied by the 2 power of their order number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Memory
&lt;/h2&gt;

&lt;p&gt;Each 1 or 0 in binary number is one bit, so 11011001 is 8 bits which is equal to 1 byte. Bit is the smallest measure. Let's consider English Alphabet (there are 26 letters) we can represent it with 5 digits because 4 will be not enough.&lt;br&gt;
00001&lt;br&gt;
00010&lt;br&gt;
…&lt;br&gt;
01111&lt;br&gt;
11111&lt;br&gt;
With 5 digits we can represent 2^5=32 letters or something.&lt;/p&gt;

&lt;h2&gt;
  
  
  Addition
&lt;/h2&gt;

&lt;p&gt;Binary addition works like a decimal addition, but the number can have only zeros and ones as digits, so if the sum exceeds 1, you have to carry 1 to the next bit.&lt;/p&gt;

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

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

&lt;p&gt;When we add 1 to 1 we will get 10 so we will have 0 and 1 carry. Moreover,  we can check that by converting these numbers and our answer into decimal.&lt;br&gt;
10001 = 17&lt;br&gt;
11101 = 29&lt;br&gt;
17 + 29 = 46 &lt;br&gt;
101110 = 46 &lt;/p&gt;

&lt;h2&gt;
  
  
  Multiplication
&lt;/h2&gt;

&lt;p&gt;Binary multiplication is similar to the multiplication of decimal numbers.&lt;/p&gt;

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

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

&lt;p&gt;Here we can also check the results by converting binary numbers into decimal.&lt;/p&gt;

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