<?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>Forem: Boyan Iliev</title>
    <description>The latest articles on Forem by Boyan Iliev (@boiliev).</description>
    <link>https://forem.com/boiliev</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%2F473176%2Fb39253d5-a467-4048-8e7e-fdfdf337696f.png</url>
      <title>Forem: Boyan Iliev</title>
      <link>https://forem.com/boiliev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boiliev"/>
    <language>en</language>
    <item>
      <title>What is HTTP, HTTPS, and SSL</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Mon, 08 Nov 2021 13:19:34 +0000</pubDate>
      <link>https://forem.com/boiliev/what-is-http-https-and-ssl-1924</link>
      <guid>https://forem.com/boiliev/what-is-http-https-and-ssl-1924</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;If you are a developer, you probably know what an &lt;code&gt;SSL&lt;/code&gt; certificate is. If you don't know what it is, don't worry. An &lt;code&gt;SSL&lt;/code&gt; certificate is a must-have on any website. It lets your web browser connect to a web server securely. &lt;code&gt;SSL&lt;/code&gt; stands for &lt;strong&gt;Secure Sockets Layer&lt;/strong&gt;, and it is a digital certificate that allows for an encrypted connection.&lt;/p&gt;

&lt;p&gt;But let's back it up a bit. First, we need to know what lets a web browser and a webserver connect. To connect with a website, we need &lt;code&gt;HTTP&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is &lt;code&gt;HTTP&lt;/code&gt;?
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;HTTP&lt;/code&gt; stands for &lt;strong&gt;Hypertext Transfer Protocol&lt;/strong&gt; and this protocol is used to transfer data from the web servers to web browsers. So if you ever visit a website you can notice the protocol being added at the beginning of the web address. So for example &lt;code&gt;http://www.website.com&lt;/code&gt;. This protocol is used to view different web pages on the internet.&lt;/p&gt;

&lt;p&gt;By default in standard &lt;code&gt;HTTP&lt;/code&gt;, all of the information is sent in clear text. What this means is when you type something, it gets sent over the public internet which means that hackers can view it, because it's all sent over in clear text.&lt;/p&gt;

&lt;p&gt;This isn't a problem, that is if you only browse a website, but if there are any passwords involved, or any other personal information, such as credit card information, then a hacker could easily get that info. Due to the fact it's being sent over the public internet, a hacker could listen in as the data is being transferred and could steal it.&lt;/p&gt;

&lt;p&gt;If you ever have to type in personal information, you should always check if you have a secure connection. And for you to have a secure connection, you would need to use &lt;code&gt;HTTPS&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is &lt;code&gt;HTTPS&lt;/code&gt;?
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;HTTPS&lt;/code&gt; is &lt;code&gt;HTTP&lt;/code&gt;, but secure. That's why there is an &lt;code&gt;S&lt;/code&gt; added. &lt;strong&gt;Hypertext Transfer Protocol Secure&lt;/strong&gt;. What this does is encrypt the data that is being retrieved by &lt;code&gt;HTTP&lt;/code&gt;. It lets all of the data that is being transferred between the server and the computer secure. The way it does that is by making the data impossible to read by encryption algorithms that mix up the data that's being transferred.&lt;/p&gt;

&lt;p&gt;So whenever you are on a site and you have to enter a password or some credit card information, make sure the web address looks like this - &lt;code&gt;https://www.website.com&lt;/code&gt;. This means that the data that you pass in will be protected. You can also notice a padlock to the left of the web address, which also indicates you are using a secure &lt;code&gt;HTTP&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Thanks to the encryption algorithms the data we put in comes out all scrambled up so that hackers can't understand and decrypt it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HTTPS&lt;/code&gt; secures the data thanks to a protocol called:&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;SSL&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;SSL&lt;/code&gt; stands for &lt;strong&gt;Secure Sockets Layer&lt;/strong&gt; and it is a protocol that's used to establish security on the internet. But how exactly does &lt;code&gt;SSL&lt;/code&gt; work? Well, it uses public-key encryption to secure data.&lt;/p&gt;

&lt;p&gt;What this means is when a computer connects with a website that is using &lt;code&gt;SSL&lt;/code&gt;, the computer's web browser will ask the website to say who it is or identify itself. Then the webserver will send the computer a copy of the &lt;code&gt;SSL&lt;/code&gt; certificate it has.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;SSL certificate&lt;/code&gt; is a small digital certificate that is used to validate the identity of a website. Or in other words, this lets your computer know that the website you're visiting is reliable and trustworthy.&lt;/p&gt;

&lt;p&gt;So then the browser of the computer can check if it trusts the certificate and if it does it will send a message to the web server, to which then the web server will respond with a response so that an &lt;code&gt;SSL&lt;/code&gt; session can begin.&lt;/p&gt;

&lt;p&gt;Most &lt;code&gt;SSL&lt;/code&gt; certificates have to be paid for, but there are also some free ones, for example:&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;Let’s Encrypt&lt;/code&gt; is a Certificate Authority (CA) that provides an easy way to obtain and install free &lt;code&gt;SSL&lt;/code&gt; certificates, thereby enabling encrypted HTTPS on web servers. You could check this post out on &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04" rel="noopener noreferrer"&gt;How To Secure Nginx with Let's Encrypt on Ubuntu&lt;/a&gt; so that you can get a little bit more familiar with &lt;code&gt;Let's Encrypt&lt;/code&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This may seem confusing at first, but it's best to get to know how the internet actually works and the different protocols that are out there. If you notice almost all of the sites nowadays have &lt;code&gt;HTTPS&lt;/code&gt; instead of &lt;code&gt;HTTP&lt;/code&gt;, even though there isn't any data to be transferred between servers, and that's because Google has started flagging websites as &lt;strong&gt;Not Secure&lt;/strong&gt; because they aren't protected with &lt;code&gt;SSL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I hope that this post has helped you learn a little bit more about these protocols that you use daily and how they work.&lt;/p&gt;

</description>
      <category>http</category>
      <category>https</category>
      <category>ssl</category>
    </item>
    <item>
      <title>How to get the size of a directory in Linux</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Thu, 04 Nov 2021 09:17:37 +0000</pubDate>
      <link>https://forem.com/boiliev/how-to-get-the-size-of-a-directory-in-linux-3bhd</link>
      <guid>https://forem.com/boiliev/how-to-get-the-size-of-a-directory-in-linux-3bhd</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Linux is one of the most popular operating systems in the world. It is Unix-like, and it is also open-source. Quite a big percentage of developers use Linux because it can be customized in so many ways.&lt;/p&gt;

&lt;p&gt;What's cool about Linux is its command line. Every 'hackers' paradise. There are a ton of commands. If you aren't familiar with any Linux commands, be sure to check out this post on the &lt;a href="https://devdojo.com/bo-iliev/8-linux-commands-everyone-should-know" rel="noopener noreferrer"&gt;8 Linux Commands Everyone Should Know&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There is probably a command for almost anything that you want to do. For example what if you wanted to get the size of a directory? Well luckily for you there is a command for that. In this post, we are going to talk about that command and see what it can offer.&lt;/p&gt;

&lt;h1&gt;
  
  
  The &lt;code&gt;du&lt;/code&gt; command
&lt;/h1&gt;

&lt;p&gt;This command lets the user get a quick view of the &lt;strong&gt;disk usage&lt;/strong&gt;. The best way to use it is by giving it the directory you want to see the size of. It should look a little something 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;du directory_name

// output
2314    directory_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will give you the size of all the files and at the very end, it will give you the size of the directory itself. You could point out the full path, or you could just give the name of the directory you want to see if you are already on the same path.&lt;/p&gt;

&lt;p&gt;But we could make this even easier just b adding 2 &lt;strong&gt;flags&lt;/strong&gt;. Flags help the command change its behavior. For the &lt;code&gt;du&lt;/code&gt; command we could add the flags &lt;code&gt;-s&lt;/code&gt; and &lt;code&gt;-h&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-s&lt;/code&gt; stands for &lt;strong&gt;summarize&lt;/strong&gt; and it will show you only the total size of the directory, without all those files popping up on your screen.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-h&lt;/code&gt; stands for &lt;strong&gt;human-readable&lt;/strong&gt; and it will convert the size so that you can read it easier. Just by running the command without the &lt;code&gt;-h&lt;/code&gt; flag doesn't specify you a unit of measurement.&lt;/p&gt;

&lt;p&gt;So now to get the best of this command, you should run it like this with the &lt;code&gt;-s&lt;/code&gt; and &lt;code&gt;-h&lt;/code&gt; flags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;du -sh directory_name

// output
44.5M   directory_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you wanted to see all of the directories sizes, you could just run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;du -sh ./*

// output
12.2M   dir1
 2.5M   dir2
  55M   dir3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another thing you can do is use pipe(&lt;code&gt;|&lt;/code&gt;) and sort them by size, which will make it even easier for you to see their sizes. What &lt;code&gt;|&lt;/code&gt; does is get the output from the command behind it and add it into the input of the command after it. So to sort the directories by size just run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;du -sh ./* | sort -h

// output
  55M   dir3
12.2M   dir1
 2.5M   dir2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is a pretty useful command that I think everybody should know, just because of how short and easy it is. I hope that this post has helped you and I wish you happy coding.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>terminal</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Replace All Occurrences of a String</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Thu, 08 Jul 2021 17:33:02 +0000</pubDate>
      <link>https://forem.com/boiliev/how-to-replace-all-occurrences-of-a-string-24mi</link>
      <guid>https://forem.com/boiliev/how-to-replace-all-occurrences-of-a-string-24mi</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;One of the main data types in JavaScript is &lt;code&gt;strings&lt;/code&gt;. These data types are used for storing and manipulating &lt;strong&gt;text&lt;/strong&gt;. And luckily for us, there are quite a few methods that help us in manipulating these data types.&lt;/p&gt;

&lt;p&gt;These methods are one of the many built-in methods of JavaScript. This is because JS has some built-in objects. Some of them are: &lt;code&gt;Array&lt;/code&gt;, &lt;code&gt;Math&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt;. And for each object, some properties and methods are associated with them.&lt;/p&gt;

&lt;p&gt;In this post we are going to see &lt;strong&gt;How to Replace All Occurrences of a String&lt;/strong&gt; with the &lt;code&gt;replaceAll()&lt;/code&gt; method.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;replaceAll()&lt;/code&gt; Method
&lt;/h1&gt;

&lt;p&gt;In order to use this method, we first have to create our string. Let's add randomly &lt;code&gt;!&lt;/code&gt; inside this strong so that we can remove it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let intro = 'My! n!ame! i!s Bo!yan!';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to remove it, we have to write the strings name, then add the &lt;code&gt;replaceAll&lt;/code&gt; method next to it, and pass in the first argument which element we want to be replaced or removed. An important thing is to remember that you have to save the new string into a new variable. It should look something 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;let newIntro = intro.replaceAll('!', '')
console.log(newIntro);

&amp;lt;- My name is Boyan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you want to replace the elements, just pass in the second argument as what you want it replaced with. Let's replace the whitespace with &lt;code&gt;-&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let newerIntro =newIntro.replaceAll(' ', '-');
console.log(newerIntro)

&amp;lt;- My-name-is-Boyan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is pretty much it to the &lt;code&gt;replaceAll()&lt;/code&gt; method. It is the main method used, if not the only method, that replaces all occurrences of a string.&lt;/p&gt;

&lt;p&gt;I hope that this post has helped you and I would love to hear some feedback in the comments below.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>developer</category>
      <category>codenewbie</category>
      <category>methods</category>
    </item>
    <item>
      <title>Introduction To MongoDB and How To Use It</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Tue, 29 Jun 2021 14:08:16 +0000</pubDate>
      <link>https://forem.com/boiliev/introduction-to-mongodb-and-how-to-use-it-3no1</link>
      <guid>https://forem.com/boiliev/introduction-to-mongodb-and-how-to-use-it-3no1</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;MongoDB is a &lt;code&gt;NoSQL&lt;/code&gt; (not only SQL) database. In NoSQL databases, we store our data in a collection of documents. These documents are very similar to &lt;code&gt;JavaScript objects&lt;/code&gt; or &lt;code&gt;JSON objects&lt;/code&gt;. So if you are familiar with JavaScript, then you are going to like Mongo, because it will be easier to get the hang of it.&lt;/p&gt;

&lt;p&gt;MongoDB is very scalable. It has built-in replication and sharding. It's performant, it's fast, and mostly, it's very flexible. Because the data structure is like a JavaScript object, you don't have to map out your entire data structure beforehand as you do with relational databases. Unlike a relational database like &lt;code&gt;MySQL&lt;/code&gt;, where you have to create all your tables and all your columns, Mongo gives you the freedom to structure your data however we want through our application. This doesn't mean it's better than relational databases, it all depends on how you need to use your database.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing MongoDB
&lt;/h1&gt;

&lt;p&gt;We are going to install MongoDB through &lt;code&gt;Homebrew&lt;/code&gt;. If you don't have Homebrew installed, just run the code below in your terminal and that will install Homebrew.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you get Homebrew installed on your Mac, just run the three following commands. First, we run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew tap mongodb/brew
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install mongodb-community@4.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then after that, we will want to run it as a service with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew services start mongodb-community@4.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, we need to run the following command so that we can connect and start using MongoDB.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This is what you should see after running the command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F79r5zuoeirbem8zm6a9z.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%2F79r5zuoeirbem8zm6a9z.png" alt="Mongo - Imgur.png" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have Mongo installed and ready, let's start with some of the main commands that you should know&lt;/p&gt;

&lt;h1&gt;
  
  
  Commands
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Show Current Database
&lt;/h3&gt;

&lt;p&gt;The command for seeing the current database is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Show All Databases
&lt;/h3&gt;

&lt;p&gt;In order to see all of the databases just run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show dbs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Switching and Creating Databases
&lt;/h3&gt;

&lt;p&gt;If you want to switch which database you are using, just type in &lt;code&gt;use&lt;/code&gt; followed by the database name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use db_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to create a DB, just type in the &lt;code&gt;use&lt;/code&gt; command again, followed by your new DBs name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use new_db_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run &lt;code&gt;show dbs&lt;/code&gt; after creating a DB, the new DB won't show because it doesn't have anything in it, so don't worry when it doesn't show up after running the &lt;code&gt;show dbs&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dropping a Database
&lt;/h3&gt;

&lt;p&gt;In order to drop a database, or in other words, delete it, you first need to switch to the database with the &lt;code&gt;use&lt;/code&gt; command, and after that, you need to type in the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.dropDatabase()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating and Viewing Collections
&lt;/h3&gt;

&lt;p&gt;To create a collection in the DB that you are using, you just have to run the following command and set the name of your collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.createCollection('collection_name')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you want to view the collection, just run the &lt;code&gt;show&lt;/code&gt; command followed by &lt;code&gt;collections&lt;/code&gt; and that should print out the collections in your DB.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show collections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inserting Rows
&lt;/h3&gt;

&lt;p&gt;Now in order to insert a row, just type in the &lt;code&gt;db&lt;/code&gt; followed by the name of the collection that you want to insert the row in, and then by &lt;code&gt;insert&lt;/code&gt;, which is then followed by parentheses&lt;code&gt;()&lt;/code&gt;. And in those parentheses, you pass in an object with whatever you want.&lt;/p&gt;

&lt;p&gt;Here is an example of how this should look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.users.insert({
    username: 'Batman_fan_44',
    followers: 3,
    following: [
        'Alred',
        'Robin'
    ],
    status: {
        name: 'Bruce Wayne',
        status: 'active'
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see this looks just like a normal JavaScript object. You can store strings, numbers, arrays and can also have embedded objects inside. This is why Mongo is liked by so many, because of how similar it is to JS and how easy it is to use.&lt;/p&gt;

&lt;p&gt;If you want to insert more than one row, instead of typing &lt;code&gt;insert&lt;/code&gt; after the collections name, type in &lt;code&gt;insertMany&lt;/code&gt; and then insert your rows in an array 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;db.users.insertMany([
    {
        username: 'Tony Montana',
        followers: 1234
    },
    {
        username: 'Hannibal Lecter',
        followers: 5
    },
    {
        username: 'Rick Grimes',
        followers: 21
    }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These rows don't have as many stuff like likes or status. which our first row has, but that doesn't matter. Unlike relational databases, in Mongo, we don't have that strict data model that we have to follow. We can put whatever we want wherever we want, which is awesome!&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewing Rows
&lt;/h3&gt;

&lt;p&gt;To view the rows of a certain collection, just run the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.collection_name.find()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print out the data, but it will be hard to read. Luckily there is a method called &lt;code&gt;pretty()&lt;/code&gt;, which formats all the rows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.collection_name.find().pretty()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now it will be much easier to read.&lt;/p&gt;

&lt;p&gt;These are some of the main commands that you should know. I recommend that you check out this MongoDB Cheat Sheet and have a look at some other commands that might be useful to you:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/bradtraversy/f407d642bdc3b31681bc7e56d95485b6" rel="noopener noreferrer"&gt;https://gist.github.com/bradtraversy/f407d642bdc3b31681bc7e56d95485b6&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;As you can see MongoDB looks identical to JavaScript. They have similar syntax and are pretty easy to get the hang of.&lt;/p&gt;

&lt;p&gt;If you want to have a MongoDB database cluster production-ready, I strongly recommend using the new DigitalOcean managed MongoDB clusters which you can deploy with just the click of a button so that you won't have to worry about server maintenance, which can be very challenging sometimes.&lt;/p&gt;

&lt;p&gt;If you want you can use this referral code which gives you &lt;a href="https://m.do.co/c/122894dc3b82" rel="noopener noreferrer"&gt;free $100 DigitalOcean credit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you also want to learn more about SQL and how to use it, I highly recommend that you check out this &lt;a href="https://github.com/bobbyiliev/introduction-to-sql" rel="noopener noreferrer"&gt;Introduction to SQL&lt;/a&gt; opensource ebook. It helped me understand how to use SQL and I highly recommend it.&lt;/p&gt;

&lt;p&gt;I hope that this post has helped you get more comfortable with using MongoDB and getting the hang of it.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>database</category>
      <category>hackathon</category>
    </item>
    <item>
      <title>How To Write Your First Node.js Script</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Tue, 08 Jun 2021 12:31:50 +0000</pubDate>
      <link>https://forem.com/boiliev/how-to-write-your-first-node-js-script-h05</link>
      <guid>https://forem.com/boiliev/how-to-write-your-first-node-js-script-h05</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Until recently(if you think that 2009 is recently), we could only run JS code in a web browser. Node is a JavaScript runtime that executes code outside of the browser. We can use the same JS syntax we know and love to write server-side code, instead of relying on other languages like Python or Ruby. You can build Web Servers, Command Line Tools, Native Apps(VSCode is a Node app!), Video Games, Drone Software, and a whole lot more.&lt;/p&gt;

&lt;p&gt;In this post, I am going to show you how to write your first little Node script which will make you a directory with an HTML, CSS, and JavaScript file in it.&lt;/p&gt;

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

&lt;p&gt;First, you need to check if you have Node installed on your machine. If you don't know if you have it, just go to the terminal and write:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This will print out the Node.js version which is currently installed. If you see an error and nothing prints, then you don't have Node installed.&lt;/p&gt;

&lt;p&gt;In order to install Node, go to the node website and just press the download button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;https://nodejs.org/en/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installing Node, we need to create a JavaScript file. Let's call this file &lt;code&gt;script.js&lt;/code&gt;. In this file, we are going to write our script.&lt;/p&gt;

&lt;p&gt;Now that we have Node installed and our file created, it's time to write our script. For this script, we are going to need to know what the &lt;code&gt;process&lt;/code&gt; object is and how the &lt;code&gt;fs&lt;/code&gt; module works. &lt;/p&gt;

&lt;h1&gt;
  
  
  How To Run Node Files
&lt;/h1&gt;

&lt;p&gt;In order to run Node files, you just need to write &lt;code&gt;node&lt;/code&gt; and then the file name next to it in the terminal. Th file must be in the same folder that you're in, or you need to reference that full path relative to where you are at the moment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node script.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;code&gt;process&lt;/code&gt; &amp;amp; &lt;code&gt;argv&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;process&lt;/code&gt; is an object that's available which is in the global scope. It provides information about, and control over, the current Node.js process. It has a bunch of methods and properties. For example, we can see our current working directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;process.cwd()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a method called &lt;code&gt;process.argv&lt;/code&gt;. It returns an array containing the command line arguments passed when the Node.js process was launched. The first element will be the path where the node executable is, and the second will be the path to the JS file being executed. To call this method you need to go to your JS file and &lt;code&gt;console.log()&lt;/code&gt; it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(process.argv);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then after running your file, you should see this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node script.js
[ '/usr/local/bin/node', '/Users/ghostman/scripts/script.js' ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any remaining element will be additional command-line arguments. We can pass them as arguments into a script. Not a function, but it's a similar idea. I can pass in arguments to a script. &lt;/p&gt;

&lt;p&gt;Here is an example of a little script that prints out the additional command-line arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const args = process.argv.slice(2)  -&amp;gt; slice to remove first two items.

for(let arg of args){
    console.log(`Hello ${arg}`)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then when we run the file 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;node script.js Batman Superman
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ou output should look 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;Hello Batman
Hello Superman
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a fun little script to help you understand how the file and node work together and how they can be used. &lt;/p&gt;

&lt;p&gt;Now let's get to the fun part.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;fs&lt;/code&gt; Module
&lt;/h1&gt;

&lt;p&gt;The fs module enables interacting with the file system. It has hundreds of methods that you can use. Here is a list so you can see how much they are.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/dist/latest-v14.x/docs/api/fs.html" rel="noopener noreferrer"&gt;https://nodejs.org/dist/latest-v14.x/docs/api/fs.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order for us to use the &lt;code&gt;fs&lt;/code&gt; module, we have to &lt;code&gt;require&lt;/code&gt; it. We have to save it in a variable.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now that we have our &lt;code&gt;fs&lt;/code&gt; module, here are the methods that we will be needing for our script.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;fs.mkdirSync&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This method creates a directory in our current working directory. There is also an &lt;code&gt;fs.mkdir&lt;/code&gt; method, but we will be using the synchronous method because it will not execute anything else until this method is completed. Here is an example of our method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.mkdirSync('dirName')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;fs.writeFileSync&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This method creates files for us. Just like &lt;code&gt;fs.mkdirSync&lt;/code&gt;, this method will not let anything else run until it has finished its process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.writeFileSync('fileName')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check for errors with the &lt;code&gt;try..catch&lt;/code&gt; statements if your code doesn't seem to work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
    fs.writeFileSync('fileName')
} catch (e){
    console.log(e)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Writting Our Node Script
&lt;/h1&gt;

&lt;p&gt;Now that you have a basic knowledge of Node, try writing a script that creates a directory with three files inside it on your own. If you can't, that OK. Here is how to write your script:&lt;/p&gt;

&lt;p&gt;First, you need to require the &lt;code&gt;fs&lt;/code&gt; module. Then you must use &lt;code&gt;process.argv&lt;/code&gt; to set the name of your directory. After that, you need to use the &lt;code&gt;fs.mkdirSync&lt;/code&gt; method and the &lt;code&gt;fs.writeFileSync&lt;/code&gt; method to create the directory and the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs')
const folderName = process.argv[2] || 'Project'

try {
    fs.mkdirSync(folderName);
    fs.writeFileSync(`${folderName}/index.html`);
    fs.writeFileSync(`${folderName}/style.css`);
    fs.writeFileSync(`${folderName}/app.js`);
} catch (err) {
    console.log(`Error!`);
console.log(err)
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After writing the code for the script, we can run it 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;node script.js SecretProject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we don't give an additional command-line argument, it will automatically set the directory name to &lt;code&gt;Project&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Consclusion
&lt;/h1&gt;

&lt;p&gt;I hope that this post has helped you understand Node.js a little bit more and made you more comfortable with it. Don't be scared to try some new stuff and experiment with all those &lt;code&gt;fs&lt;/code&gt; module methods.&lt;/p&gt;

&lt;p&gt;Let me know if this has been of help to you through Twitter. You can follow me &lt;a href="https://twitter.com/bo_iliev21" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>developer</category>
    </item>
    <item>
      <title>8 Linux Commands Everyone Should Know</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Thu, 06 May 2021 07:25:17 +0000</pubDate>
      <link>https://forem.com/boiliev/8-linux-commands-everyone-should-know-1f2i</link>
      <guid>https://forem.com/boiliev/8-linux-commands-everyone-should-know-1f2i</guid>
      <description>&lt;h1&gt;
  
  
  Introduciton
&lt;/h1&gt;

&lt;p&gt;It's a well-known fact that developers use terminals. And using a terminal is something that everybody should know. It is a good thing to know and do because it will help you in so many ways. It will help you in that job interview, or just in your everyday life. You must at least have the basic knowledge of how to use a terminal. For example how to change directories and view them and how to create a file. &lt;/p&gt;

&lt;p&gt;In this post, I am going to show you some of the basic commands and how to get around in a terminal and not be completely lost. &lt;/p&gt;

&lt;h1&gt;
  
  
  1. &lt;code&gt;pwd&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; means &lt;strong&gt;Print Working Directory&lt;/strong&gt;. It shows you the full path to your current directory. This is used so you don't get lost in all those directories that you have. If you don't know what a directory is, it is pretty much like a folder. It stores other folders and files in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pwd
/Users/user1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  2. &lt;code&gt;ls&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;ls&lt;/code&gt; stands for &lt;strong&gt;List Files&lt;/strong&gt;. It will show you the files and directories that are in your current directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls
xmen avengers justiceLeague
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  3. &lt;code&gt;cd&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;Now that you know how to list your files in your working directory and how to print the path to it, you will need to &lt;strong&gt;Change Directory&lt;/strong&gt;. This is done by typing the &lt;code&gt;cd&lt;/code&gt; command. You just have to type it and then next to it type the directory you want to visit. But this command only moves forward and backward. This means you can't just type a directory name that is deep inside your files just by typing its name. You have to type the full path to that dir.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd avengers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to go in multiple dirs, you need to use &lt;code&gt;/&lt;/code&gt; after every dir, and then type the directory you want to visit inside the previous one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ironMan/suitMark85
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to go back one dir, you need to type &lt;code&gt;cd ..&lt;/code&gt;. You could mix this with other dir 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;cd ../../captainAmerica/steveRogers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or if you just type &lt;code&gt;cd&lt;/code&gt; by itself, it will send you to the home directory.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. &lt;code&gt;mkdir&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;Now that we know how to go to a directory and how to view what's inside them, we need to learn how to make one. It is done through the &lt;code&gt;mkdir&lt;/code&gt; command. You just type the command and add the new directory name next to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir secretDir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to create multiple dir at once, just type all of them next to each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir secretDir1 secretDir2 secretDir3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When doing these kinds of things be sure to use the &lt;code&gt;pwd&lt;/code&gt; command so you know in which dir you are so that you don't create the new dirs in the wrong one.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. &lt;code&gt;man&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;man&lt;/code&gt; command is used to check the manuals of a certain command. When you are not sure what a command does and what to have a detailed look at it, just type the &lt;code&gt;man&lt;/code&gt; command and add the other command next to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;man ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you are done viewing the manual, press &lt;code&gt;q&lt;/code&gt; so that you can leave the file.&lt;/p&gt;

&lt;h1&gt;
  
  
  6. &lt;code&gt;touch&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;touch&lt;/code&gt; command creates a file (or multiple). It is almost the same as &lt;code&gt;mkdir&lt;/code&gt;, but it's not used for making directories but for files with an extension(.txt, .html, .css ...).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch index.html style.css app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  7. &lt;code&gt;nano&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;nano&lt;/code&gt; is a text editor using a command-line interface. When you create a file and want to add something small to it, just use &lt;code&gt;nano&lt;/code&gt; to add it. &lt;/p&gt;

&lt;p&gt;In order to edit a file, just type &lt;code&gt;nano&lt;/code&gt; and the file name next to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that if there isn't such a file in your directory, for example, the &lt;code&gt;index.html&lt;/code&gt; one, it will create a new one. So this means that you wouldn't need to use the &lt;code&gt;touch&lt;/code&gt; command. bUt it's best to create a file with &lt;code&gt;touch&lt;/code&gt; and then go to your code editor and do your coding there. &lt;code&gt;nano&lt;/code&gt; is best used for those minor changes like for example a typo.&lt;/p&gt;

&lt;p&gt;There are some shortcuts that would be nice for you to know. I would recommend checking this post out on some of those shortcuts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devdojo.com/bobbyiliev/11-nano-shortcuts-that-you-should-know" rel="noopener noreferrer"&gt;11 Nano shortcuts that you should know&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  8. &lt;code&gt;rm&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;Now that we know how to view dirs, create them, create files and edit them, we need to learn how to delete them. Deleting a dir or file is done with the &lt;code&gt;rm&lt;/code&gt; command. You definitely want to be careful with this, because if you delete a file or dir, you won't be able to get it back. So if you want to delete a file just type &lt;code&gt;rm&lt;/code&gt; and then the file name. Or if you want to remove multiple files, just type their names next to each other&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm index.html style.css app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you want to remove a directory you can use &lt;code&gt;rmdir&lt;/code&gt;, but this will only remove a dir that is empty. In order to delete a dir that is not empty, use the &lt;code&gt;rm&lt;/code&gt; command with the flags &lt;code&gt;-rf&lt;/code&gt;. If you don't know what flags are, think of them as extra options for your command. The &lt;code&gt;ls&lt;/code&gt; command has lots of flags. I would recommend that you check the manual of the &lt;code&gt;ls&lt;/code&gt; command so that you can see all its available flags. &lt;/p&gt;

&lt;p&gt;So deleting a directory with other dirs or files inside should be done 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;rm -rf avengers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be very careful with these commands because if you delete a file or dir by accident, you won't be able to get them back&lt;/p&gt;

&lt;p&gt;If you want to see some examples and a more detailed explanation for some of these commands be sure to check out this video:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/HqdFvL74wqo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Knowing how to use a terminal is crucial. It is. a huge bonus to know at least these commands, which will help you a lot. &lt;/p&gt;

&lt;p&gt;I hope that this post has helped you and that you will be a little bit more confident the next time you see a terminal.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>terminal</category>
      <category>developer</category>
    </item>
    <item>
      <title>Introduction To JavaScript Promises</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Tue, 27 Apr 2021 15:23:09 +0000</pubDate>
      <link>https://forem.com/boiliev/introduction-to-javascript-promises-2oed</link>
      <guid>https://forem.com/boiliev/introduction-to-javascript-promises-2oed</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;A Promise is an object representing the eventual completion or failure of an async operation. A promise is a returned object to which you attach callbacks, instead of passing callback into a function. &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;new Promise&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;In order to make a new Promise you need to write &lt;code&gt;new Promise&lt;/code&gt; and then it will expect you to pass in a function with two arguments which are functions. The first one represents the resolution of this promise and the second one the rejection of this promise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const requestPromise = (url) =&amp;gt; {
    return new Promise((resolve, rejects) =&amp;gt; {
        const delay = Math.floor(Math.random() * (4500)) + 500;
        setTimeout(() =&amp;gt; {
            if(delay &amp;gt; 4000) {
                reject('Connection Timeout :(')
            } else {
                resolve(`Here is your fake data from ${url}`)
            }
        }, delay)
    })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in order to call the function multiple times with different URLs, we need to use the &lt;code&gt;then&lt;/code&gt; method. The &lt;code&gt;then&lt;/code&gt; method returns data if the async request is returned. But if the operation is failed, we must use the &lt;code&gt;catch&lt;/code&gt; method. This is how it should look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requestPromise('reddit.com/api/chicken/page1')
    .then(() =&amp;gt; {
        console.log('PAGE1 WORKED!!');
        requestPromise('reddit.com/api/chicken/page2')
            .then(() =&amp;gt; {
                console.log('PAGE2 WORKED!!');
                requestPromise('reddit.com/api/chicken/page3')
                    .then(() =&amp;gt; {
                        console.log('PAGE3 WORKED!!');
                    })
                    .catch(() =&amp;gt; {
                        console.log('PAGE3 ERROR!!');
                    })
                    .catch(() =&amp;gt; {
                        console.log('PAGE2 ERROR!!');
                    })
            })
            .catch(() =&amp;gt; {
                console.log('PAGE1 ERROR!!');
            })
    })  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can notice this is very long and repetitive. We can make it shorter and cleaner by using only one &lt;code&gt;catch&lt;/code&gt;.  In order for this to work, we need to return a promise from within our callback.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requestPromise('reddit.com/api/chicken/page1')
    .then(() =&amp;gt; {
      console.log('PAGE1 WORKED!!');
      return requestPromise('reddit.com/api/chicken/page2')
    })
    .then(() =&amp;gt; {
    console.log('PAGE2 WORKED!!');
    return requestPromise('reddit.com/api/chicken/page3')
    })
    .then(() =&amp;gt; {
        console.log('PAGE3 WORKED!!');
    })
    .catch(() =&amp;gt; {
        console.log('REQUEST FAILED!');
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Promises are resolved and rejected with values.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requestPromise('reddit.com/api/chicken/page1')
    .then((data) =&amp;gt; {
      console.log('PAGE1 WORKED!!');
        console.log(data);           
      return requestPromise('reddit.com/api/chicken/page2')
    })
    .catch((err) =&amp;gt; {
        console.log('REQUEST FAILED!');
        console.log(err);
    })


// IF IT WORKS IT WILL PRINT:
// PAGE 1 WORKED!!
// Here is your fake data from reddit.com/api/chicken/page1

// IF IT DOESN'T WORK:
// REQUEST FAILED!
// Connection Timeout :(
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is coming from a function.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;async&lt;/code&gt; Functions
&lt;/h1&gt;

&lt;p&gt;A newer and cleaner syntax for working with async code! It's still the same thing as a promise, but it's "prettier". There are two keywords that you need to know.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;async&lt;/code&gt; keyword
&lt;/h3&gt;

&lt;h5&gt;
  
  
  1. Async functions always return a promise
&lt;/h5&gt;

&lt;h5&gt;
  
  
  2. If the function returns a value. the promise will be resolved with that value.
&lt;/h5&gt;

&lt;h5&gt;
  
  
  3. If the function throws an exception, the promise will be rejected.
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function hello(){   
}
//-&amp;gt; returns a promise even if empty


const sing = async () =&amp;gt; {  
}
// -&amp;gt; we can use async arrow functions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const login = async (username, password) =&amp;gt; {
    if(!username || !password) 
    throw 'Missing Credentials'
    if(password === 'password') 
    return 'Welcome!'
    throw 'Invalid Password'
}

login('demonslayer64')
    .then(msg =&amp;gt; {
        console.log('LOGGED IN!')
        console.log(msg)
    })
    .catch(err =&amp;gt; {
        console.log('ERROR!')
        console.log(err)
    })

//Returns:
ERROR!
Missing Credentials
&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;login('demonslayer64', 'slayerdemon46')
    .then(msg =&amp;gt; {
        console.log('LOGGED IN!')
        console.log(msg)
    })
    .catch(err =&amp;gt; {
        console.log('ERROR!')
        console.log(err)
    })

//Returns:
ERROR!
Invalid Password
&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;login('demonslayer64', 'password')
    .then(msg =&amp;gt; {
        console.log('LOGGED IN!')
        console.log(msg)
    })
    .catch(err =&amp;gt; {
        console.log('ERROR!')
        console.log(err)
    })

//Returns:
LOGGED IN!
WELCOME!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;await&lt;/code&gt; keyword
&lt;/h2&gt;

&lt;h5&gt;
  
  
  1. The &lt;code&gt;await&lt;/code&gt; keyword is used inside of functions declared with async.
&lt;/h5&gt;

&lt;h5&gt;
  
  
  2. &lt;code&gt;await&lt;/code&gt; will pause the execution of the function, &lt;strong&gt;waiting for a promise to be resolved&lt;/strong&gt;.
&lt;/h5&gt;

&lt;p&gt;Here is an example with our function from earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function makeTwoRequests() {
    let data1 = await requestPromise('/page1');
    console.log(data1);
}

//Returns
&amp;lt;- &amp;gt;Promise {&amp;lt;pending&amp;gt;}
Here is your fake data from /page1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is pretty much the basics of JavaScript promises. Let me know if this has helped you at all. Any feedback will be greatly appreciated!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>async</category>
      <category>developer</category>
    </item>
    <item>
      <title>How To Write A Good README File</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Thu, 22 Apr 2021 07:20:31 +0000</pubDate>
      <link>https://forem.com/boiliev/how-to-write-a-good-readme-file-2c0d</link>
      <guid>https://forem.com/boiliev/how-to-write-a-good-readme-file-2c0d</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;If you're familiar with GitHub, then you know what a README file is. But if you don't know what it is, you can think of it as the introduction to your repository. It's very helpful that while looking at someone's repo you can just scroll down to their README file and have a look at what their project is all about. &lt;/p&gt;

&lt;p&gt;It's crucial that your project gets introduced properly because if it isn't, the chances of someone pressing on the repo are low. That's why having a good README file shouldn't be overlooked and you should spend a good amount of your time on it. &lt;/p&gt;

&lt;p&gt;In this post, I am going to share some tips with you about how you can improve your README file, and hopefully, it can help you with your repos.&lt;/p&gt;

&lt;h1&gt;
  
  
  Choose an easy name for your project
&lt;/h1&gt;

&lt;p&gt;Before we dive into the README.md file let's quickly mention the name of the project itself.&lt;/p&gt;

&lt;p&gt;When people search for different projects, the last thing they will want to see is: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;"cool-javascript-game-about-colors-and-rgb-colors-and-even-more-colors"&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Now I know that this example is a little over-exaggerated, but you get the point. No one is going to press on a repo with such a long name. It's best if you try to have a simple and short name for your project that gets right to the point. &lt;/p&gt;

&lt;p&gt;So for the example, above we could just use:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"javascript-color-game"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A name like this has a higher chance of getting clicked on and taken a look at. So make sure that your repos name is simple and straight to the point.&lt;/p&gt;

&lt;h1&gt;
  
  
  Give a descriptive summary of your project
&lt;/h1&gt;

&lt;p&gt;Now that we have the repo name cleared out, let's focus on the README.md file!&lt;/p&gt;

&lt;p&gt;When someone visits your repo they can scroll down and read the README file. It should have a description of what your project is. But you wouldn't want it to be too short. And neither should it be too long. Now if it's a very big project then by all means you should give a proper explanation of what it is and what it does. But in most cases, it should be a well-written and structured text. There are five steps that I would recommend you follow while writing your README file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step #1
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write a quick introduction to what the project is about&lt;/strong&gt;. For example, if you made a to-do list using JavaScript, write about that. But don't get into too much depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step #2
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write what your code uses&lt;/strong&gt;. For example HTML, CSS and JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step #3
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write a few more details about the project&lt;/strong&gt;. Write things that would make you take interest in the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step #4
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Write something about yourself&lt;/strong&gt;. You could say where you work, what your goals are, or share some of your previous projects. It's okay to share what you have created or what you are trying to accomplish &lt;/p&gt;

&lt;h2&gt;
  
  
  Step #5
&lt;/h2&gt;

&lt;p&gt;And finally, &lt;strong&gt;use images&lt;/strong&gt;. Show the reader what exactly the project is. Just by reading about it isn't going to get their full interest. But by seeing an image of it, they will be more likely to get more into it.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;And these are some tips about writing a good README file. It's very important that you get comfortable writing these things. It could help you change the level of interaction your GitHub repo gets.&lt;/p&gt;

&lt;p&gt;I hope that this post has helped you in improving your README files and I hope to see some great repos with great README files out on GitHub soon.&lt;/p&gt;

</description>
      <category>github</category>
      <category>readme</category>
    </item>
    <item>
      <title>5 Tips On How To Stay Motivated And Productive As A Developer</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Tue, 13 Apr 2021 08:00:15 +0000</pubDate>
      <link>https://forem.com/boiliev/5-tips-on-how-to-stay-motivated-and-productive-as-a-developer-mgp</link>
      <guid>https://forem.com/boiliev/5-tips-on-how-to-stay-motivated-and-productive-as-a-developer-mgp</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Whether you are a senior developer, or you have just started getting into code, there comes a time when you start losing motivation. It is normal to lose motivation and that lack of motivation can sometimes stick for a long time. Unfortunately, there can be hundreds of reasons that can make you lose motivation. For example, you can't get your code to run the way you want it to. This happens to a lot of us and it can be hard to get back to being productive.&lt;/p&gt;

&lt;p&gt;In this post, I would like to share with you some tips that you can try to help you stay motivated or get that motivation back.&lt;/p&gt;

&lt;h1&gt;
  
  
  Stay off your phone
&lt;/h1&gt;

&lt;p&gt;It's no secret that our mobile devices are very addictive. Of course, some people can't afford to stay off their phone because it is connected with their work. But for most of us, it is a big waste of time. When we surf the internet we can really lose motivation. Spending way too much time on social media, YouTube, or Netflix can make us lose motivation and even make us depressed. This is why when you start feeling down and feel that you are getting a little unproductive, just leave your phone at the other end of the room. &lt;strong&gt;Or just try to stay off of it for as long as you can&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I noticed that this really helped me to be more concentrated and made me enjoy much more the time I spent coding.&lt;/p&gt;

&lt;h1&gt;
  
  
  Set mini-goals for you to complete
&lt;/h1&gt;

&lt;p&gt;If you don't have a &lt;strong&gt;daily to-do list&lt;/strong&gt;, I highly recommend that you make one. You can add in it all the stuff that you want to achieve the next day. So the night before you go to bed make a list and add a few small tasks to it. Some that will be helpful for you, but at the same time not that hard. When you finish one of those tasks and see the progress that you've done when crossing it out from your list will give you a boost of motivation.&lt;/p&gt;

&lt;p&gt;Also, I would recommend that you try to complete the hardest tasks first. I personally prefer to get them out of the way first and then do the other stuff.&lt;/p&gt;

&lt;h1&gt;
  
  
  Wake up properly
&lt;/h1&gt;

&lt;p&gt;The worst thing to do when you wake up is to get straight away on your phone. You've just slept 7-10 hours and you're body is dehydrated and your brain is confused. And it's not the best idea for your eyes to be staring at a screen before they have even opened up yet.&lt;/p&gt;

&lt;p&gt;I would recommend that you lay in bed for 5 minutes so that you can fully wake up. Then go &lt;strong&gt;drink as much water as you can so that you can hydrate after a night of sleeping&lt;/strong&gt;. Try to stay off any screens for as long as you can in the morning so that your body and mind can get ready for the day. You will feel much more energetic and will have all the power to do all of the stuff that you have to.&lt;/p&gt;

&lt;h1&gt;
  
  
  Surround yourself with tech-related stuff
&lt;/h1&gt;

&lt;p&gt;Try to make the stuff you do during the day as connected to web development as possible. Seeing what other people create and the knowledge their share on all the different web dev community websites really makes you feel like you are a part of something big and lift you up. Try to chat with as many developers as you can. We have such an amazing community that just by getting surrounded by it can give you the motivation you need. Some of these sites are the &lt;a href="https://devdojo.com/" rel="noopener noreferrer"&gt;DevDojo&lt;/a&gt; website and &lt;a href="https://dev.to/"&gt;DEV&lt;/a&gt;. Also, another cool thing is the &lt;a href="https://daily.dev/" rel="noopener noreferrer"&gt;daily.dev&lt;/a&gt; extension.&lt;/p&gt;

&lt;p&gt;Try sharing some of your knowledge or share a project your working on. See all the feedback you get. You can learn so many things that way. Or you can help someone else learn something. It's really fun and it can really boost your motivation and productivity when you see other developers that have the same interests as you.&lt;/p&gt;

&lt;p&gt;And finally:&lt;/p&gt;

&lt;h1&gt;
  
  
  Look back at the things you have accomplished
&lt;/h1&gt;

&lt;p&gt;When you think that you are stuck and can't get anywhere, for example, if you don't know how to get your code to run properly, just sit for a moment and think of how you used to be when you started programming. Think of all the progress that you have made in the last couple of months. This can boost your motivation and productivity by seeing how far you've come.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;These things have really helped me stay motivated and productive. I kept losing motivation because I had to study for my exams and then I couldn't get motivated to code. When I started using these tips, I became more motivated than I have ever been. &lt;/p&gt;

&lt;p&gt;I hope that this post has helped you get more productive and motivated!&lt;/p&gt;

</description>
      <category>developer</category>
      <category>productivity</category>
      <category>motivation</category>
      <category>webdev</category>
    </item>
    <item>
      <title>DOM Event Listeners</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Mon, 05 Apr 2021 21:22:16 +0000</pubDate>
      <link>https://forem.com/boiliev/dom-event-listeners-5519</link>
      <guid>https://forem.com/boiliev/dom-event-listeners-5519</guid>
      <description>&lt;p&gt;JavaScript is probably one of the most reliable and most powerful programming languages. But what takes JS to the next level is the DOM. The DOM stands for &lt;strong&gt;Document Object Model&lt;/strong&gt;. In other words, with the DOM you can change the documents structure, style, and content. And with JavaScript doing that is very easy. Most of the websites that you use in your everyday life use JS. And they manipulate the DOM through it.&lt;/p&gt;

&lt;p&gt;In this post, I am going to talk about the different ways you can add &lt;strong&gt;DOM Event Listeners&lt;/strong&gt;. They allow JavaScript to register different event handlers on elements in an HTML document. Events are normally used in combination with functions, and the function will not be executed before the event occurs (such as when a user clicks a button).&lt;/p&gt;

&lt;p&gt;Let's start with our first type of event.&lt;/p&gt;

&lt;h1&gt;
  
  
  Inline Events
&lt;/h1&gt;

&lt;p&gt;This is not an ideal way to add Event listeners. Here the event is specified with a function as an attribute to the HTML tag. So let's say for example we want to add an event to our &lt;code&gt;h1&lt;/code&gt; tag that console logs a &lt;code&gt;Hello World!&lt;/code&gt; when pressed. We just have to add an &lt;code&gt;onclick&lt;/code&gt; event. This adds an event when an element is clicked. This is how it would look like:&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;h1 onclick="console.log('Hello World!')"&amp;gt;Click me&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want something more fun, you can add a function to be executed when pressed. So let's create our &lt;code&gt;greet()&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(){
    console.log('Hello World!');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add it to our &lt;code&gt;h1&lt;/code&gt;&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;h1 onclick="greet()"&amp;gt;Click me&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are better ways to add an event listener. Again, this isn't an ideal way, because it can be overwritten. But it's good to keep in mind. You can also add the &lt;code&gt;onclick&lt;/code&gt; event through JS.&lt;/p&gt;

&lt;p&gt;First, you have to make a function, because &lt;strong&gt;the code always has to be in a function in order to work!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we have to select our &lt;code&gt;h1&lt;/code&gt; tag and save it 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;let h1 = document.querySelector('h1'); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to add the &lt;code&gt;onclick&lt;/code&gt; event to our &lt;code&gt;h1&lt;/code&gt; variable, we have to write the variable, then add the event, and finally pass in the function that we want to be executed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1.onclick = greet;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can notice, we don't need to add parentheses&lt;code&gt;()&lt;/code&gt;. Now whenever we press our &lt;code&gt;h1&lt;/code&gt;, we will get a console log that says &lt;code&gt;'Hello World!'&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  addEventListener
&lt;/h1&gt;

&lt;p&gt;This is the best way to use event listeners. It is more diverse and it's easier to use once you get more used to it.&lt;/p&gt;

&lt;p&gt;You just have to select the element to which we want to add an event listener, then we add the &lt;code&gt;addEventListener&lt;/code&gt; to it and in its parenthesis, we add two arguments. The &lt;strong&gt;first argument is the type of the event&lt;/strong&gt;, and the &lt;strong&gt;second one is the function that we want to run&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's make our greet function run when our &lt;code&gt;h1&lt;/code&gt; tag is clicked. This is how it should look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1.addEventListener('click', greet);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, just like the &lt;code&gt;inline event&lt;/code&gt; we didn't need to add parenthesis to our function. We could also create a function inside the event listener.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1.addEventListener('click', function(){
    console.log('STOP CLICKING ME!')
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have an event that only needs to be triggered when pressed only by one element, then add the function in the event listener. There won't be a need to make a specific function outside of it that you will need to call again in another event.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;addEventListener&lt;/code&gt; can run two functions at the same time, while &lt;code&gt;onclick&lt;/code&gt; gets overwritten by the last function. So if we make a function called &lt;code&gt;name&lt;/code&gt; that console logs our name, and then a &lt;code&gt;hello&lt;/code&gt; function that console logs the string &lt;code&gt;"Hello"&lt;/code&gt; we can call them both at the same time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1.addEventListener('click', hello);
h1.addEventListener('click', name);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After we press the &lt;code&gt;h1&lt;/code&gt;, we will see this in our console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-&amp;gt; "Hello"
-&amp;gt; "DevDojo"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;addEventListener&lt;/code&gt; has more options as well. For example, we can run the event only once, and then actually make it remove the event listener by itself. This is done pretty easily. We just have to add a &lt;strong&gt;third argument&lt;/strong&gt;. We cover it in curly braces. In those curly braces, we add the keyword &lt;code&gt;once&lt;/code&gt; and then put a colon and put the boolean &lt;code&gt;true&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1.addEventListener('click', greet, { once: true });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the many options &lt;code&gt;addEventListener&lt;/code&gt; has. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I would recommend using &lt;code&gt;addEventListener&lt;/code&gt; because it is more secure and it is much more diverse. This is what almost everyone uses. But it's good to know the other ways you can add event listeners.&lt;/p&gt;

&lt;p&gt;I hope this post has helped you and I would love to hear some feedback from you. Make sure to follow me on &lt;a href="https://twitter.com/bo_iliev21" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; and get in touch with me.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>dom</category>
      <category>webdev</category>
    </item>
    <item>
      <title>6 YouTube Channels About Web Development</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Fri, 26 Mar 2021 14:35:38 +0000</pubDate>
      <link>https://forem.com/boiliev/6-youtube-channels-about-web-development-on3</link>
      <guid>https://forem.com/boiliev/6-youtube-channels-about-web-development-on3</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Everyone watches YouTube. You probably spend many hours every week. I mean how else are you gonna catch up with all those cat videos. But YouTube isn't just about cat vids and celebrity drama. There are some awesome and helpful Web-Dev channels out there. Some people may be aware that there are such channels, but some people may not be. &lt;/p&gt;

&lt;p&gt;I would like to share some of my favorite channels that help me out and I just enjoy watching daily.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UC29ju8bIPH5as8OGnQzwJyA" rel="noopener noreferrer"&gt;Traversy Media&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "Traversy Media features the best online web development and programming tutorials for all of the latest web technologies including Node.js, Angular 2, React.js, PHP, Rails, HTML, CSS and much more"
&lt;/h3&gt;

&lt;p&gt;I personally really love this channel, because of how nicely done their tutorials are. I highly recommend that you go and have a  look at some of their videos.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UCGfS15jIidDqpAk9pcCcAHw" rel="noopener noreferrer"&gt;DevDojo&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "The Dev Dojo is a resource to learn all things web development and web design. Learn on your lunch break or wake up and enjoy a cup of coffee with us to learn something new."
&lt;/h3&gt;

&lt;p&gt;DevDojo really helped me out while I was getting into web development. And the &lt;strong&gt;&lt;a href="https://devdojo.com/" rel="noopener noreferrer"&gt;DevDojo&lt;/a&gt;&lt;/strong&gt; website helped me even more. There are so many educating posts on all the different technologies. DevDojos creator is Tony Lea and he creates some awesome stuff. One of the stuff that he has created is &lt;strong&gt;&lt;a href="https://devdojo.com/tails" rel="noopener noreferrer"&gt;tails&lt;/a&gt;&lt;/strong&gt;. It is a drag'n'drop page creator built for TailwindCSS. I love creating some websites with tails and using them. Also, another cool thing about the website is that if you write a post on it, your post could get picked as one of the posts of the week and you could win 20$. So be sure to check out both the DevDojo channel and the DevDojo website.&lt;/p&gt;

&lt;p&gt;I would love it if Tony could bring back &lt;em&gt;Daily Developer Thoughts&lt;/em&gt;. In this series he talks about some really interesting topics and I really enjoyed them. I hope to see them back again soon.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/c/FlorinPop/featured" rel="noopener noreferrer"&gt;Florin Pop&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "Hello 👋, Florin here!
&lt;/h3&gt;

&lt;p&gt;### I love to create Coding Tutorials and to Code Live, so you'll see a lot of those on this channel!&lt;/p&gt;

&lt;h3&gt;
  
  
  Together we're going to learn a lot about web development (HTML, CSS, JavaScript, ReactJS, NodeJS, Animations, Components, APIs and all the cool stuff 😎).
&lt;/h3&gt;

&lt;h3&gt;
  
  
  I also love challenges. Here are a few that #### I completed so far:
&lt;/h3&gt;

&lt;h3&gt;
  
  
  - 100 Projects in 100 Days
&lt;/h3&gt;

&lt;h3&gt;
  
  
  - 31 Videos in 31 Days
&lt;/h3&gt;

&lt;h3&gt;
  
  
  - Conquered the Entire freeCodeCamp Curriculum in a Month (while recording everything)
&lt;/h3&gt;

&lt;h3&gt;
  
  
  - 7 Days 7 Websites
&lt;/h3&gt;

&lt;h3&gt;
  
  
  More to come! 😃
&lt;/h3&gt;

&lt;h3&gt;
  
  
  🔔 Subscribe and stay tuned!"
&lt;/h3&gt;

&lt;p&gt;Florin is one of the coolest YouTubers out there. You definitely need to check some of the challenges that he does and maybe try to do it yourself. In my opinion, he is one of the best web-dev YouTubers out right now.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UCQWmdHTeAO0UvaNqve9udRw" rel="noopener noreferrer"&gt;Bobby Iliev&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "I am a professional System Administrator with a demonstrated history of working in the internet industry."
&lt;/h3&gt;

&lt;p&gt;This is the smallest channel on this list, but it is one of the most helpful ones. Bobby does some really cool tutorials about Docker, Laravel, Nginx, Linux, and he has some courses about Introduction to Bash scripting, Docker Tips, and Building a blog with Laravel and Voyager.&lt;/p&gt;

&lt;p&gt;Be sure to check it out and subscribe to his channel.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UC5DNytAJ6_FISueUfzZCVsw" rel="noopener noreferrer"&gt;Code with Ania Kubów&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "Hello everyone. This channel is run by Ania Kubow. In this channel, I will be teaching you JavaScript, React, HTML, CSS, React-native, Node.js and so much more!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  A little bit about me:
&lt;/h3&gt;

&lt;h3&gt;
  
  
  My background is in the financial markets, where I worked as a derivates broker out of University. After starting my first startup I became obsessed with coding and knew it was my calling. I am currently the proud owner of this YouTube channel where I have no shame in teaching people hard concepts through the use of diagrams and cute drawings. My aim is to teach you how to code, not to care about how silly I look doing it.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  PLN from UAE then SGP now LDN 🇵🇱🇦🇪🇸🇬🇬🇧
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Please Like, Comment your thoughts, Share and Subscribe for upcoming releases, and don’t forget to press the bell icon.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  For contact:
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Twitter: &lt;a class="mentioned-user" href="https://dev.to/ania_kubow"&gt;@ania_kubow&lt;/a&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Instagram: @aniakubow"
&lt;/h3&gt;

&lt;p&gt;Ania is an awesome JavaScript developer. She makes some awesome videos and tutorials on all sorts of different stuff that you can create. She creates so many fun little projects. Be sure to definitely go and check out her channel.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UCaPX53JLxxSbwZz_Ra_cL0g" rel="noopener noreferrer"&gt;DigitalOcean&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Channel Description:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "DigitalOcean provides the easiest cloud platform to deploy, manage, and scale applications of any size, removing infrastructure friction and providing predictability so developers and their teams can spend more time building better software."
&lt;/h3&gt;

&lt;p&gt;DigitalOcean is a cloud infrastructure provider, but their community is awesome. They do some awesome tutorials, and they have a really interesting 1-hour Tech Talk in which they talk about what's new in the dev world. Be sure to go check their channel out as well.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;YouTube is amazing but unfortunately, sometimes it's hard to find channels that could help you out. All of these channels are the ones that I spend the most time on. They help me learn new stuff and I generally enjoy watching what all these creators share with us. Be sure to subscribe to all of them and let them know to keep up the good work.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>dev</category>
      <category>youtube</category>
    </item>
    <item>
      <title>Array Methods And Callbacks In Javascript</title>
      <dc:creator>Boyan Iliev</dc:creator>
      <pubDate>Wed, 03 Mar 2021 11:13:05 +0000</pubDate>
      <link>https://forem.com/boiliev/array-methods-and-callbacks-in-javascript-1p64</link>
      <guid>https://forem.com/boiliev/array-methods-and-callbacks-in-javascript-1p64</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;One of the most important things in JavaScript is arrays. 99% of the time there is going to be an array in someone's JS script. And if you take a look into someone else's code, you will likely see them use an array method or callbacks.&lt;/p&gt;

&lt;p&gt;Callbacks are functions that get passed on to another function as an argument.&lt;/p&gt;

&lt;p&gt;These methods are built-in functions in JavaScript that you can use for your array. &lt;/p&gt;

&lt;p&gt;In this post, we are going to talk about some of these callbacks and array methods and how to use them.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;forEach()&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;forEach()&lt;/code&gt; used to be a lot more used before the &lt;code&gt;for...of&lt;/code&gt; loop came out. This method allows us to run a function that runs our code once per item in some array.&lt;/p&gt;

&lt;p&gt;Let's first create our array. We are going to call it &lt;code&gt;numbers&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let numbers = [1, 2, 3, 4, 5];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now let's use the &lt;code&gt;forEach()&lt;/code&gt; method and print out all of the numbers in our array.&lt;/p&gt;

&lt;p&gt;This is what you will most commonly see. Defining a function inline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers.forEach(function (num){
    console.log(num);
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is very famous and is mainly used this way. We could pass in a name function that we have already created, but most of the time we will pass in a function that exists only for this.&lt;/p&gt;

&lt;p&gt;If you want to pass a function that already exists, it should look something 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;function print(el){
    console.log(el);
}

numbers.forEach(print);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is pretty uncommon. You will hardly see this in someone else's code.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;map()&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; function creates a new array with the results of calling a callback on every element of the array. Let's create our first 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 heroes = ['batman', 'spider-man', 'superman'];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's use the &lt;code&gt;map()&lt;/code&gt; method to create our new array called &lt;code&gt;superHeroes&lt;/code&gt; and use the &lt;code&gt;toUpperCase&lt;/code&gt; method.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;toUpperCase&lt;/code&gt;method returns the value to uppercase.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const superHeroes = heroes.map(function (t){
     return t.toUpperCase();
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's call our new array and see the results.&lt;br&gt;
&lt;/p&gt;

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

&amp;lt;- (3) ["BATMAN", "SPIDER-MAN", "SUPERMAN"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We just made a new array, in which all the values are in uppercase. You can do so much more with this method. Give it a try and see how much fun stuff you can do with it.&lt;/p&gt;

&lt;h1&gt;
  
  
  Arrow &lt;code&gt;=&amp;gt;&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;This method is probably one of the most useful ones. This is a newer syntax for defining functions. It allows us to write functions without actually having to write the keyword &lt;code&gt;function&lt;/code&gt;. How cool is that!&lt;/p&gt;

&lt;p&gt;They are super useful for when you have a short function to write for a one-time thing. &lt;/p&gt;

&lt;p&gt;Arrow functions are used to create function expressions. But they can only be created from a variable. This is how it looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sum = (x, y) =&amp;gt;{
    return x + y;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now to execute the function, it will be the same as executing any other function. That's because it is just like any other function, but with a nicer and cleaner syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sum(5, 5);

&amp;lt;- 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to write a function with no arguments, then you just have to add the empty parenthesis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const  greet = () =&amp;gt;{
    return 'Hello World!';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we can call this function back like any other function.&lt;br&gt;
&lt;/p&gt;

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

&amp;lt;- "Hello World!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have a function with only one argument, then you can write it without parenthesis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const square = x =&amp;gt;{
    return x * x;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then you have to call it back the same way as you usually do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;square(5);

&amp;lt;- 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So remember, if you have two or more arguments - use parenthesis. If you have zero arguments - use parenthesis again. But if you have only one argument - you don't need to use parenthesis.&lt;/p&gt;

&lt;p&gt;We can also make our arrow function even shorter with &lt;strong&gt;implicit returns&lt;/strong&gt;. What this means is that we can get rid of the &lt;code&gt;return&lt;/code&gt; keyword. We just have to turn our curly braces into parenthesis. So let's make our last function (&lt;code&gt;square&lt;/code&gt;) a little bit shorter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const square = x =&amp;gt;(
    x * x
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see we got rid of the &lt;code&gt;return&lt;/code&gt; keyword and it got a little bit shorter. &lt;strong&gt;It's very important to know that we can only do this if there is only one line of code with a single value.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If our function is a super short one, we can have it all on one line. We just have to remove the parenthesis. This is how it should look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const square = x =&amp;gt; x * x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see the arrow function makes it so much shorter and cleaner. This is very helpful for those short functions that you need in your code.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;filter()&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;filter()&lt;/code&gt; function creates a new array with all of the elements that the test implemented by the provided function. Let's create an array with some numbers in it.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Let's use the &lt;code&gt;arrow&lt;/code&gt; method and return the numbers that are greater than 2 while using the &lt;code&gt;filter()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newNumbers = numbers.filter(x =&amp;gt;{
    return x &amp;gt; 2;
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if we call the &lt;code&gt;newNumbers&lt;/code&gt; array that we just created, it's going to give us back all of the numbers that are greater than 2.&lt;br&gt;
&lt;/p&gt;

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

&amp;lt;- (3) [3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  every/some
&lt;/h1&gt;

&lt;p&gt;These two methods are put together because they are very similar. The &lt;code&gt;every&lt;/code&gt; method tests whether &lt;strong&gt;all&lt;/strong&gt; elements in the array pass the provided function. &lt;strong&gt;It returns a Boolean value&lt;/strong&gt;. As for the &lt;code&gt;some&lt;/code&gt; method, it does the same as &lt;code&gt;every&lt;/code&gt;, but it returns &lt;code&gt;true&lt;/code&gt; if &lt;strong&gt;any&lt;/strong&gt; of the array elements pass the test function. &lt;/p&gt;

&lt;p&gt;These two methods always return &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. Unlike the previous methods- &lt;code&gt;map()&lt;/code&gt; and &lt;code&gt;filter()&lt;/code&gt;, which return a new array.&lt;/p&gt;

&lt;p&gt;Let's create a new array. It is going to contain the result of an exam.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const results = [92, 85, 78, 96, 77, 71, 89];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's check if every student passes the exam. In order to pass it, they must have a score over 70.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;results.every(score =&amp;gt; score &amp;gt; 70);

&amp;lt;- true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get &lt;code&gt;true&lt;/code&gt; because all of the elements in the array are over 70. But now if we change the score of which you have to have to pass the exam to 75, we will get &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;some&lt;/code&gt; method will say true if any of the elements in the array pass the function. So this means if we change the minimum score to be 75, we are still going to get true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;result.some(score =&amp;gt; score &amp;lt; 75);

&amp;lt;- true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if none of the array elements pass, then we will get &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;These methods may seem intimidating and scary at first, or probably a bit useless, but the more you use them and get comfortable with them, the more awesome stuff you can create. And you can create them much easier. You just have to keep on practicing and applying these methods to your day-to-day coding sessions.&lt;/p&gt;

&lt;p&gt;I hope that this post has helped. I am currently learning all this stuff at the moment and I wanted to share them with the world. Any feedback will be greatly appreciated!&lt;/p&gt;

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