<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[devsurvival]]></title><description><![CDATA[devsurvival.com, a collection of stories, discussions, and courses about coding, web development,education , and computer science. I am an avid learner, so this blog is a documentation of the things I have learned. The goal is to share a little bit of this knowledge with the world 😊]]></description><link>https://www.devsurvival.com</link><generator>GatsbyJS</generator><lastBuildDate>Wed, 13 May 2020 23:09:09 GMT</lastBuildDate><item><title><![CDATA[Web Dev Bootcamp ∙ Request Routing And Building an API]]></title><description><![CDATA[Goals Learn how HTTP request works Requesting routing with Express JS Learn what an API is and how to build one What is an HTTP Request HTTP…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-api/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-api/</guid><pubDate>Fri, 08 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Goals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Learn how HTTP request works&lt;/li&gt;
&lt;li&gt;Requesting routing with Express JS&lt;/li&gt;
&lt;li&gt;Learn what an API is and how to build one&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What is an HTTP Request&lt;/h3&gt;
&lt;p&gt;HTTP requests are just messages sent between an &lt;strong&gt;HTTP Client&lt;/strong&gt; and a &lt;strong&gt;server&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;HTTP Client&lt;/strong&gt; is typically a website or anything that is able to send a HTTP request&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;HTTP server&lt;/strong&gt; is a backend application that is able to receive a HTTP request, authorize the request, and then send some response back to the HTTP Client&lt;/p&gt;
&lt;h3&gt;How does HTTP Request Works&lt;/h3&gt;
&lt;p&gt;A HTTP request consists of 3 things:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. The request line - this describes the request method and the request url&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt;Request Methods:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GET&lt;/strong&gt; - getting some data from a server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;POST&lt;/strong&gt; - posting or sending some data to a server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PUT&lt;/strong&gt; - update some data in the server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DELETE&lt;/strong&gt; - Delete some data in the server&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The request url is the access point that the server exposes to the HTTP Client&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Request Headers&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;request headers are additional information passed along with the HTTP request&lt;/p&gt;
&lt;p&gt;Some examples of headers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Accept-Charset&lt;/li&gt;
&lt;li&gt;Accept-Encoding&lt;/li&gt;
&lt;li&gt;Accept-Language&lt;/li&gt;
&lt;li&gt;Authorization&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;3. Finally we have the request body or message&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is just the &lt;strong&gt;main content&lt;/strong&gt; that we want to pass to the &lt;strong&gt;server&lt;/strong&gt; from our &lt;strong&gt;HTTP client&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Building an HTTP Server with Express&lt;/h3&gt;
&lt;h4&gt;Let’s create our server first&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Create a new project folder&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;32439629806494460000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir expressAPI
cd expressAPI`, `32439629806494460000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; expressAPI
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; expressAPI&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Install Express and Create our server&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;18447325866579243000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm init`, `18447325866579243000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; init&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;6500533650480089000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm install express`, `6500533650480089000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; express&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;70688178137490580000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch index.js`, `70688178137490580000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;inside of the index.js file, add the following&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;76245490996071500000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var express = require(&amp;quot;express&amp;quot;)
var app = express()
const PORT = 3000
app.listen(PORT, () =&gt; {
  console.log(\`listening on port \${PORT}\`)
})`, `76245490996071500000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; express &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;express&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;listening on port &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Run the server&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;67101700459127670000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`nodemon index.js`, `67101700459127670000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nodemon index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Creating Routes&lt;/h4&gt;
&lt;p&gt;Routes are like request url that you create to receive HTTP requests&lt;/p&gt;
&lt;p&gt;Inside of the index.js file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;43074653887509955000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.get(&amp;quot;/&amp;quot;, (req, res, next) =&gt; {
  res.status(200).json(&amp;quot;Hello from express server!&amp;quot;)
})`, `43074653887509955000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello from express server!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is telling our server that we are allow to receive a GET request to the root url and return a response with message : “Hello from express server!”&lt;/p&gt;
&lt;h3&gt;Testing our route&lt;/h3&gt;
&lt;p&gt;There are 2 ways to test your routes&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using &lt;a href=&quot;https://www.postman.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;postman&lt;/a&gt; - an HTTP Client that allows you to send requests to your server&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/c4376464e0fd85308aadb8f048a87f48/31d79/postman.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 49.69325153374233%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAABYlAAAWJQFJUiTwAAABYUlEQVQoz41Ri22FMAzMeF2kW3WD7tMF+ip45ANJSAgk4WqHPoRUtXqIk+0E7ny2MOoO1X1hkneEUWM2Et47LMvyJ2KM6LoOt89PaDXAaAmlFPq+hxinCUoTUYjIpWBd14Zt2/5FSgkhLtA+QdvQhObZQ0hi1kTICqw6DBLjOMIY03DNH1DaIFiDj5vFy5vF67vFXRn6d4AwQw9vJzjnSGFuMcSAEA60miLb5HvupDkgxGWFdCu0S0jUnR8NBM8t0MwK2a21npHB1q415/u+t7htueUAo9JbsIQZItcdORfwwx9cwV0x0Xn2kwc6n2j2hUgKneVM5Bt36cgybdg5C+c9HLVt2TpZ5KEztragfC6DLYdE92vCkihfIlYa0eZGOJq3mGjIvJSRYJSElhITXTRiEsopHqZad/W0f625axaz1kJwUUtGIaUTpH7YrE+h1mNkiToWR7Hj97M/DSZ9EH4DbCUILlgiTAQAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;postman&quot;
        title=&quot;postman&quot;
        src=&quot;/static/c4376464e0fd85308aadb8f048a87f48/a6d36/postman.png&quot;
        srcset=&quot;/static/c4376464e0fd85308aadb8f048a87f48/222b7/postman.png 163w,
/static/c4376464e0fd85308aadb8f048a87f48/ff46a/postman.png 325w,
/static/c4376464e0fd85308aadb8f048a87f48/a6d36/postman.png 650w,
/static/c4376464e0fd85308aadb8f048a87f48/e548f/postman.png 975w,
/static/c4376464e0fd85308aadb8f048a87f48/3c492/postman.png 1300w,
/static/c4376464e0fd85308aadb8f048a87f48/31d79/postman.png 1954w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Introduction to Node and Express JS]]></title><description><![CDATA[Goals Explain what NodeJS is Create a server using NodeJS What is NodeJS NodeJS is a server runtime that allows you to run javascript code…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/introduction-to-node/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/introduction-to-node/</guid><pubDate>Thu, 07 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Goals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Explain what NodeJS is&lt;/li&gt;
&lt;li&gt;Create a server using NodeJS&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What is NodeJS&lt;/h3&gt;
&lt;p&gt;NodeJS is a server runtime that allows you to run javascript code on the server.&lt;/p&gt;
&lt;p&gt;Prior to NodeJS, all Javascript code had to be run in the browser using the V8 engine provided by the browser&lt;/p&gt;
&lt;p&gt;Javascript became so popular that ideas of writing Javascript without a browser began circulating.&lt;/p&gt;
&lt;p&gt;In response, a group of very capable people designed NodeJS to enable developer to write JavaScript on the server.&lt;/p&gt;
&lt;p&gt;They also open sourced the technology, so new features and bug fixes are added every day&lt;/p&gt;
&lt;h3&gt;Nodejs Libraries&lt;/h3&gt;
&lt;p&gt;NodeJS is a low level framework that allows you to create a server. Hence, there are libraries that sits on top of NodeJS that makes sever management much easier&lt;/p&gt;
&lt;p&gt;There are many libraries to choose from, such as Express JS, Hapi, SailJS, and Meteor JS.&lt;/p&gt;
&lt;p&gt;In this course, we will be using Express JS&lt;/p&gt;
&lt;h4&gt;What is Express?&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Fast, unopinionated, minimalist web framework for Node.js&lt;/em&gt; - &lt;a href=&quot;https://expressjs.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;expressjs.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Express is simply a wrapper for NodeJS that makes developing in Node Js super easy&lt;/p&gt;
&lt;h3&gt;Installing Node&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Window&lt;/strong&gt; - use the &lt;a href=&quot;https://nodejs.org/en/download/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;installer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mac&lt;/strong&gt; - use brew to install Node and NPM&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;3794920029997572600&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew update
brew install node`, `3794920029997572600`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;brew update
brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; node&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt; - Install Node PPA and then isntall Node using terminal&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;5549138300582701000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -`, `5549138300582701000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; -sL https://deb.nodesource.com/setup_12.x &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; -E &lt;span class=&quot;token function&quot;&gt;bash&lt;/span&gt; -&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At the time of writing this the LTS version was 12.x.&lt;/p&gt;
&lt;p&gt;Then install node by running&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;33466825677265355000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sudo apt install nodejs`, `33466825677265355000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; nodejs&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;check if node and npm were installed successfully&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73799734651436860000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`node -v
npm -v`, `73799734651436860000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;node -v
&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Creating Our First Server&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;create a new project folder&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;78173198058153540000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir firstNodeServer
cd firstNodeServer`, `78173198058153540000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; firstNodeServer
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; firstNodeServer&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Add a package.json by running&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;64854913518146560000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npn init`, `64854913518146560000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;npn init&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;there will be a series of questions about the project. Feel free to use the defaults&lt;/p&gt;
&lt;p&gt;The package.json is a json file that contains a list of packages required to build our project&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Installing the Express package&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The Express package is the npm package that we need to create a node server using the Express JS framework&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;12449177988567372000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm install express`, `12449177988567372000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; express&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Create a new index.js file&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;58893705855888930000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch index.js`, `58893705855888930000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This file will contain our server initialization code to create a new server&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;Inside the index.js, add the following code&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;77143286930544430000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var express = require(&amp;quot;express&amp;quot;)
var app = express()
const PORT = 3000
app.listen(PORT, () =&gt; {
  console.log(\`listening on port \${PORT}\`)
})`, `77143286930544430000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; express &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;express&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;listening on port &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are importing the Express package that we just installed using &lt;code class=&quot;language-text&quot;&gt;var express = require(&amp;#39;express&amp;#39;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then we are creating a new app using express by calling &lt;code class=&quot;language-text&quot;&gt;var app = express()&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Next we have a &lt;code class=&quot;language-text&quot;&gt;const PORT&lt;/code&gt; that will tell our server to listen on a specific port&lt;/p&gt;
&lt;p&gt;Finally we are telling our app to listen on PORT = 3000 and console.log a message when the app is listening on that port&lt;/p&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;Start our server&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are two main ways of starting our server&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using standard node command. However, each time you make a change to your files, you have to restart the server&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;79984219643081850000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`node index.js`, `79984219643081850000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;node index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Using nodemon - a small npm package that allows you to hot-reload your server each time a change is detected&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;install by running:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;53156012353193430000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm install -g nodemon`, `53156012353193430000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g nodemon&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here the &lt;code class=&quot;language-text&quot;&gt;-g&lt;/code&gt; flag is telling npm to install nodemon globally =&gt; meaning we can run nodemon in any directory!&lt;/p&gt;
&lt;p&gt;Run our server again by using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;83742021058515580000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`nodemon index.js`, `83742021058515580000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nodemon index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;try changing the message in the console.log() to something else. Nodemon will automatically restart the server for you!&lt;/p&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Understand &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;request routing and building an API&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn Git]]></title><description><![CDATA[What is Git? Git is a version control software that allows you to keep track of changes to your project. It allows you to keep a history of…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-git/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-git/</guid><pubDate>Wed, 06 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;What is Git?&lt;/h3&gt;
&lt;p&gt;Git is a version control software that allows you to keep track of changes to your project.&lt;/p&gt;
&lt;p&gt;It allows you to keep a history of the changes you’ve made to a project&lt;/p&gt;
&lt;p&gt;Why is this useful?&lt;/p&gt;
&lt;p&gt;Bugs are typically introduced when new changes are introduced. Hence, being able to pinpoint when a bug occurred based on when the changes was made can be a time saver&lt;/p&gt;
&lt;p&gt;You can also deploy your code to a remote server, such as Github, and other people can look at your code and contribute if they want to.&lt;/p&gt;
&lt;h3&gt;Installing Git&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Window&lt;/strong&gt; - use the &lt;a href=&quot;https://gitforwindows.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;installer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mac&lt;/strong&gt; - use the brew package manager to &lt;a href=&quot;https://git-scm.com/download/mac&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;install&lt;/a&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73199349086900110000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew install git`, `73199349086900110000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt; - use the terminal to &lt;a href=&quot;https://git-scm.com/book/en/v2/Getting-Started-Installing-Git&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;install&lt;/a&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;46152799649041730000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sudo apt install git-all`, `46152799649041730000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; git-all&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Creating a new git repo&lt;/h3&gt;
&lt;p&gt;In your root project directory, run&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;38134961250173500000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git init`, `38134961250173500000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; init&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Cloning a repository&lt;/h3&gt;
&lt;p&gt;cloning a repository is like making a contained copy a repository for personal use&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;29636447013545464000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git clone LINK_TO_GIT_REPO`, `29636447013545464000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone LINK_TO_GIT_REPO&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Stage, Commit, and Push&lt;/h3&gt;
&lt;p&gt;There are 3 stages to deploying your change to a remote server.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first is staging.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Staging is the processing of adding changes to a file to a stage or an Index location&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;66610583388217260000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git add &lt;filename&gt;`, `66610583388217260000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;filename&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;you can also add all changes to the Index using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;96724303957671890000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git add .`, `96724303957671890000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;The second step is committing these changes&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Committing a set of changes, is simply a way of saying : I really want to keep these changes&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;35025120209187110000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git commit -m &amp;quot;first commit&amp;quot;`, `35025120209187110000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit -m &lt;span class=&quot;token string&quot;&gt;&quot;first commit&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note: you have to include a message with every commit using the &lt;code class=&quot;language-text&quot;&gt;-m &amp;quot;your message goes here&amp;quot;&lt;/code&gt;. The message should be descriptive of the changes you have made&lt;/p&gt;
&lt;p&gt;You can also make multiple commits in a single workflow&lt;/p&gt;
&lt;p&gt;Ideally, each commit should contain a set of related changes, such as a bug fix or a small feature&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;The final step is making your changes visible in the remote server&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;1338631941742685200&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git push origin master`, `1338631941742685200`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If this is a new repository that you created locally, you have to add a remote server first before pushing&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;16116491315299998000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git remote add origin &lt;link to the server&gt;`, `16116491315299998000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;git remote add origin &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;link to the server&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Branches&lt;/h3&gt;
&lt;p&gt;Every time you create git repo, it automatically generates a branch called the master branch.&lt;/p&gt;
&lt;p&gt;Given the name, the master branch is the most valuable and should always be the most up to date&lt;/p&gt;
&lt;p&gt;A branch is just a copy of another branch.&lt;/p&gt;
&lt;p&gt;here is how you can &lt;strong&gt;create a branch&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;59314148728834110000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git checkout -b &lt;name of your new branch&gt;`, `59314148728834110000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout -b &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;name of your new branch&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assuming that you are in the master branch, this command will create a new branch from the master branch.&lt;/p&gt;
&lt;p&gt;You can create a branch from any branch; it doesn’t have to be your master branch&lt;/p&gt;
&lt;p&gt;you can &lt;strong&gt;switch between branches&lt;/strong&gt; using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;16299023780673071000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git checkout &lt;name of your branch&gt;`, `16299023780673071000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;name of your branch&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can check the &lt;strong&gt;available branches&lt;/strong&gt; as well as the current branch that you are in using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;30263801827409550000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git branch`, `30263801827409550000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The current branch that you are in will have an &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt; before it&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To switch back to the master branch&lt;/strong&gt;, run&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;8179294019677430000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git checkout master`, `8179294019677430000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To &lt;strong&gt;delete a branch&lt;/strong&gt;, run&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;26028996950480330000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git branch -d &lt;name of branch&gt;`, `26028996950480330000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; branch -d &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;name of branch&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Pushing a branch to the remote server&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Did you noticed before how we push our changes to the remote server?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;16440308323155839000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git push origin master`, `16440308323155839000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin master&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are pushing the master branch to the &lt;code class=&quot;language-text&quot;&gt;origin&lt;/code&gt; server&lt;/p&gt;
&lt;p&gt;you can check the servers linked to the git repo by running&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;75497875602574210000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git remote -v`, `75497875602574210000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; remote -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Turns out, you can push other branches to the remote server&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;45819194461610290000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git push origin &lt;name of your branch&gt;`, `45819194461610290000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; push origin &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;name of your branch&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Pulling changes from remote branches&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let’s say someone else made some changes and pushed them to the remote server.&lt;/p&gt;
&lt;p&gt;How do you get those changes? (Please don’t say copy and paste…)&lt;/p&gt;
&lt;p&gt;What’s the opposite of push?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;59053815918944700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git pull`, `59053815918944700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; pull&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will do a &lt;code class=&quot;language-text&quot;&gt;fetch&lt;/code&gt; and a &lt;code class=&quot;language-text&quot;&gt;merge&lt;/code&gt; into the current branch&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fetching&lt;/strong&gt; is the process of pinging the remote server for new changes, but doesn’t actually pull the changes to your local repo&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Merging&lt;/strong&gt; Will attempt to merge the new changes with your local repo&lt;/p&gt;
&lt;p&gt;Sometimes you want to merge some changes from one local repo to another repo&lt;/p&gt;
&lt;p&gt;You can do that by running&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;29305859450525710000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git merge &lt;destination branch&gt;`, `29305859450525710000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; merge &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;destination branch&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will merge the current branch into the destination branch&lt;/p&gt;
&lt;h4&gt;When to create a branch?&lt;/h4&gt;
&lt;p&gt;If you are working by yourself on a small project, then branching might not be necessary.&lt;/p&gt;
&lt;p&gt;However, it does start making sense or even become essential when you are working in a collaborative environment on a large scale project.&lt;/p&gt;
&lt;p&gt;Each person can work on a separate feature or a fixing a different bug at the same time.&lt;/p&gt;
&lt;p&gt;There is no need to wait for a person to finish their part before you can start working on yours.&lt;/p&gt;
&lt;p&gt;A good rule of thumb is that each feature should be its own branch, typically called the feature branch.&lt;/p&gt;
&lt;p&gt;Stick to a consistent branch naming convention, such as&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;62365687619127770000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git checkout -b feature/adddeletefunctionality`, `62365687619127770000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout -b feature/adddeletefunctionality&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Similar for bugs,&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;99283011002238860000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git checkout -b bug/pagedoesnotload`, `99283011002238860000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; checkout -b bug/pagedoesnotload&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Git Status and Logs&lt;/h3&gt;
&lt;p&gt;Sometimes you want to check the status of your git repo, such as files that are staged, run&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;13215628415493198000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git status`, `13215628415493198000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; status&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also access the log by running&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;66520347958159335000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`git log`, `66520347958159335000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Introduction to &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;node&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn Bash]]></title><description><![CDATA[What is Bash? Bash is a command terminal where you can type in some command and your operating system will execute the command Here is what…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-bash/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-bash/</guid><pubDate>Wed, 06 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;What is Bash?&lt;/h3&gt;
&lt;p&gt;Bash is a command terminal where you can type in some command and your operating system will execute the command&lt;/p&gt;
&lt;p&gt;Here is what a typical bash looks like
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/0ef7e/bash.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 43.558282208588956%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAlklEQVQoz82SwQrDIAyGff/H2mDDQ7EoqKgXT8VLa6WVnvqPZLAn8LDARxKS/CEQ8VQP6FlDzQpKfZmmib18vyClhDEGWms45xBjQggB1lr2MUaGYpoRwQdOvPdIKSHnzA3LsqCUwmzbhtYa9n1HrZVZ1/UXE1SjhQID7bouiPu+MYrjOMYJkp3n+eeCw0/uvY8VpFf6APlkuzLEjTLdAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;bash&quot;
        title=&quot;bash&quot;
        src=&quot;/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/a6d36/bash.png&quot;
        srcset=&quot;/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/222b7/bash.png 163w,
/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/ff46a/bash.png 325w,
/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/a6d36/bash.png 650w,
/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/e548f/bash.png 975w,
/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/3c492/bash.png 1300w,
/static/b7bf70e6f2ad18fe9f23ddc2b9175c91/0ef7e/bash.png 1594w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Common Bash Commands&lt;/h3&gt;
&lt;h4&gt;ls&lt;/h4&gt;
&lt;p&gt;List all directories and files in a directory&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;37007360410345540000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`ls`, `37007360410345540000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;cd&lt;/h4&gt;
&lt;p&gt;Changing directories&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73651664756168740000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`cd myDirectoy
cd directory1/directory2/...`, `73651664756168740000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; myDirectoy
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; directory1/directory2/&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;you can also navigate into multiple nested directories by typing a forward slash followed by the directory name&lt;/p&gt;
&lt;p&gt;you can also go back one directory by typing &lt;code class=&quot;language-text&quot;&gt;cd ..&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;mkdir&lt;/h4&gt;
&lt;p&gt;Making new directories&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;10237297602930395000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir myNewDirectory`, `10237297602930395000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; myNewDirectory&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;touch&lt;/h4&gt;
&lt;p&gt;creating files&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;36947262081412325000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch index.js`, `36947262081412325000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;rm&lt;/h4&gt;
&lt;p&gt;removing files and directories&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;55802350572495870000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`rm index.js
rm myDirectory`, `55802350572495870000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; index.js
&lt;span class=&quot;token function&quot;&gt;rm&lt;/span&gt; myDirectory&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note: you can only use &lt;code class=&quot;language-text&quot;&gt;rm myDirectory&lt;/code&gt; if the directory is empty.&lt;/p&gt;
&lt;p&gt;To delete the directory including all files and sub directories inside of it use &lt;code class=&quot;language-text&quot;&gt;rm -rf myDirectory&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;More Information&lt;/h3&gt;
&lt;p&gt;there are a lot of commands, but these are the ones that you will probably used the most often&lt;/p&gt;
&lt;p&gt;here is a good resource to &lt;a href=&quot;https://ss64.com/bash/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;learn more&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Learn &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;git&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn Javascript Part 2 ∙ ES6]]></title><description><![CDATA[Goals understand what ES6 is Learn the most common ES6 features What is ES6? ES6 is the next version of Javascript following ES5. It was…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-javascript-part3/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-javascript-part3/</guid><pubDate>Tue, 05 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Goals&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;understand what ES6 is&lt;/li&gt;
&lt;li&gt;Learn the most common ES6 features&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What is ES6?&lt;/h3&gt;
&lt;p&gt;ES6 is the next version of Javascript following ES5. It was released in 2011 an introduced many useful changes for developers&lt;/p&gt;
&lt;h3&gt;ES6 Features&lt;/h3&gt;
&lt;h4&gt;Let keyword&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;let&lt;/code&gt; is an alternative to &lt;code class=&quot;language-text&quot;&gt;var&lt;/code&gt; that allows you to scope a variable to a block as opposed to the global/function scope of a &lt;code class=&quot;language-text&quot;&gt;var&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;34349347938878250000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function fn() {
  var globalVar = 2
  if (true) {
    let blockVar = 3 // can only be accessed inside this if block
    console.log(globalVar, blockVar)
  }
  console.log(globalVar)
  console.log(blockVar) // will produce an error because blockVar is not been defined in the function scope
}

fn() // will generate error`, `34349347938878250000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; globalVar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; blockVar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// can only be accessed inside this if block&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;globalVar&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; blockVar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;globalVar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;blockVar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will produce an error because blockVar is not been defined in the function scope&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will generate error&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/fc81b8ba35c91efe69068d2e6cfc7c71/4ad3a/undefined.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 10.429447852760736%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAbUlEQVQI1z2Myw6DMBAD+f/vQ4TmQBM1QFX6gFAuSOx0FyoOI1vWyMUaIhIjVBVS11CW4Bw0zUHbQn+HW4JrgNcbpoyMEyiW3cWzqPNUt5A8I8MAISDeH2fase0zQs77wYn6hvyxvtn+XXikxA+pzpe7fxSAwQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;undefined&quot;
        title=&quot;undefined&quot;
        src=&quot;/static/fc81b8ba35c91efe69068d2e6cfc7c71/a6d36/undefined.png&quot;
        srcset=&quot;/static/fc81b8ba35c91efe69068d2e6cfc7c71/222b7/undefined.png 163w,
/static/fc81b8ba35c91efe69068d2e6cfc7c71/ff46a/undefined.png 325w,
/static/fc81b8ba35c91efe69068d2e6cfc7c71/a6d36/undefined.png 650w,
/static/fc81b8ba35c91efe69068d2e6cfc7c71/e548f/undefined.png 975w,
/static/fc81b8ba35c91efe69068d2e6cfc7c71/4ad3a/undefined.png 1152w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;const keyword&lt;/h4&gt;
&lt;p&gt;the &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt; keyword lets us create variables that can only be assigned once and can not be changed&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;83464945050907920000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const myConst = &amp;quot;Dogs are great!&amp;quot;

myConst = &amp;quot;no they are not&amp;quot; // will generate an error because we are trying to change a constant`, `83464945050907920000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myConst &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Dogs are great!&quot;&lt;/span&gt;

myConst &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;no they are not&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will generate an error because we are trying to change a constant&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d585a08848ecf4c5e5af52c987b6c370/4ad3a/constant.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 10.429447852760736%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAeklEQVQI1x2N0QrCMBRD9/8/qAwcRVe3tlvbbbgWtPd49SEkHELSVe/IT0MwFw5rWMyVEmaIEVkWZNsQzcSEpPTnlIKUCrXSXifJOdp5EqaJ7j17mB0MBvoebgPcH8iko1pkXcF7RIUPytR/J/sO+0HLmWwtHz0L48gXHhKYTJciCj0AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;constant&quot;
        title=&quot;constant&quot;
        src=&quot;/static/d585a08848ecf4c5e5af52c987b6c370/a6d36/constant.png&quot;
        srcset=&quot;/static/d585a08848ecf4c5e5af52c987b6c370/222b7/constant.png 163w,
/static/d585a08848ecf4c5e5af52c987b6c370/ff46a/constant.png 325w,
/static/d585a08848ecf4c5e5af52c987b6c370/a6d36/constant.png 650w,
/static/d585a08848ecf4c5e5af52c987b6c370/e548f/constant.png 975w,
/static/d585a08848ecf4c5e5af52c987b6c370/4ad3a/constant.png 1152w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Arrow functions&lt;/h4&gt;
&lt;p&gt;Arrow functions are used to simplify how we write functions and to make them more concise&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;70131327598606890000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`//traditional function

function double(num) {
  return num * 2
}

double(2) // 4

//rewritten using arrow function

var double = num =&gt; num * 2

double(2) // 4`, `70131327598606890000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//traditional function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 4&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//rewritten using arrow function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Arrow functions are denoted by &lt;code class=&quot;language-text&quot;&gt;=&amp;gt;&lt;/code&gt;. On the left side we have the parameters and on the right side be have the function definition&lt;/p&gt;
&lt;p&gt;There are several caveat we have to be aware of when using arrow functions&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Multiple parameters require a &lt;code class=&quot;language-text&quot;&gt;()&lt;/code&gt; ex.&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;42724793533271925000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const singlePara = param1 =&gt; console.log(param1)

const multiplePara = (param1, param2) =&gt; console.log(param1, param2)`, `42724793533271925000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;singlePara&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;param1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;param1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;multiplePara&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;param1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; param2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;param1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; param2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Function definitions that do not use &lt;code class=&quot;language-text&quot;&gt;{}&lt;/code&gt; are implicitly saying ‘return whatever is in the definition’&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;ex.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;66734410076445270000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const double = num =&gt; num * 2 // since we are not using {} to encase the function definition, we are saying do num*2 and return it
const doSomething = () =&gt; ({
  name: &amp;quot;charlie&amp;quot;,
  type: &amp;quot;dog&amp;quot;,
}) // Not using {}, but since we are returning something that spans multiple line we are using ()
// Inside the (), we have an object {name : &apos;charlie&apos;, type: &apos;dog&apos;} which will be returned

const fn = () =&gt; {
  // some code here

  return result
} // Now we are using {} to encase the function definition, so we have to add a return statement if we want to return something`, `66734410076445270000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// since we are not using {} to encase the function definition, we are saying do num*2 and return it&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;doSomething&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;charlie&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Not using {}, but since we are returning something that spans multiple line we are using ()&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Inside the (), we have an object {name : &apos;charlie&apos;, type: &apos;dog&apos;} which will be returned&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// some code here&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; result
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Now we are using {} to encase the function definition, so we have to add a return statement if we want to return something&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;We can also pass arrow functions to other function&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;49970439210412570000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var arr = [1, 2, 3]
// passing function using anonymous function
arr.map(function(currentElement) {
  return currentElement * 2
})
// the new way of doing things...
arr.map(currentElement =&gt; currentElement * 2)`, `49970439210412570000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// passing function using anonymous function&lt;/span&gt;
arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// the new way of doing things...&lt;/span&gt;
arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;classes&lt;/h4&gt;
&lt;p&gt;classes are part of OOP(object orientated programming) paradigm. This design insists that data should be represented as human readable objects or classes&lt;/p&gt;
&lt;p&gt;Let’s learn how to create classes in Javascript&lt;/p&gt;
&lt;p&gt;Declaring a class&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;27229411341866115000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`class MyClass {}`, `27229411341866115000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyClass&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Member variables and functions&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;10802133155022254000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`class MyClass {
  name
  age
  constructor(n, a) {
    this.name = n
    this.age = a
  }

  toString() {
    return \`name: \${this.name} age: \${this.age}\`
  }
}`, `10802133155022254000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyClass&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  name
  age
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;n&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; n
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; a
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;name: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; age: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we have two public member variables &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;age&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;We are initializing these members using the &lt;code class=&quot;language-text&quot;&gt;constructor&lt;/code&gt;. Each class can only have one constructor.&lt;/p&gt;
&lt;p&gt;The purpose of the constructor is to initialized our object. Here we are assigning our &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;age&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;We have a member function called &lt;code class=&quot;language-text&quot;&gt;toString()&lt;/code&gt; which prints the name and age of our object&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating an object from class&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;18709593025185976000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var obj = new MyClass(&amp;quot;devsurvival&amp;quot;, 1) // we use the new keyword to create a new object and pass in the name and the age for the constructor
console.log(obj.toString()) // accessing the member function toString()
console.log(obj.name) // getting the name
obj.age = 2 // setting age`, `18709593025185976000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// we use the new keyword to create a new object and pass in the name and the age for the constructor&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// accessing the member function toString()&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// getting the name&lt;/span&gt;
obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// setting age&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Setters/Getters and Private Members&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There is a rule of thumb in programming that states that all member variables should be private and they can only be modified or accessed via setters and getters.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;33628635068921774000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`class MyClass {
  #name
  #age
  constructor(name, age) {
    this.#name = name
    this.#age = age
  }
  set name(n) {
    this.#name = n
  }
  get name() {
    return \`name: \${this.#name}\`
  }

  #myPrivateFunction() {
    console.log(
      &amp;quot;this is private and can only be accessed inside the class body&amp;quot;
    )
  }
}

var obj = new MyClass(&amp;quot;devsurvival&amp;quot;, 2)
obj.name = &amp;quot;charlie&amp;quot; // using setter to set the name
console.log(obj.name) // using getter to get the name
obj.#age = 2 // will generate an error
obj.myPrivateFunction() // will generate an error`, `33628635068921774000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyClass&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  #name
  #age
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;#name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;#age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;#name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; n
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;name: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;#name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;#myPrivateFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token string&quot;&gt;&quot;this is private and can only be accessed inside the class body&quot;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;charlie&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// using setter to set the name&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// using getter to get the name&lt;/span&gt;
obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;#age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will generate an error&lt;/span&gt;
obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;myPrivateFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will generate an error&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Default&lt;/h4&gt;
&lt;p&gt;defaults allows to optionally pass in a parameter&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;76039405384175880000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function fn(value = 0) {
  console.log(value)
}

fn() // 0
fn(1) //1`, `76039405384175880000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 0&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;For of loop&lt;/h4&gt;
&lt;p&gt;allows you to loop over the elements on an array without explicitly knowing the length of the array&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;44425175048298635000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var arr = [1, 2, 3]
for (let v of arr) {
  console.log(v)
}

// prints 1, 2,3`, `44425175048298635000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; v &lt;span class=&quot;token keyword&quot;&gt;of&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;v&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// prints 1, 2,3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;For in loop&lt;/h4&gt;
&lt;p&gt;looping through the keys of an object&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;18915944280680886000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var object = { name: &amp;quot;devsurvival&amp;quot;, age: 2 }

for (let key in object) {
  console.log(object[key])
}`, `18915944280680886000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; object &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; key &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; object&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;object&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Tempate Strings&lt;/h4&gt;
&lt;p&gt;You can embedded variable inside of strings without using messy string concatenation&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;42958149942315570000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`//traditional Javascript

var str = &amp;quot;hello &amp;quot; + name + &amp;quot;You wanted &amp;quot; + donuts + &amp;quot; donuts&amp;quot;

// ES5

var str = \`hello \${name}. You wanted \${donuts} donuts\``, `42958149942315570000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//traditional Javascript&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;You wanted &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; donuts &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; donuts&quot;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// ES5&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;hello &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;. You wanted &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;donuts&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; donuts&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;variables used in template string are encased in a &lt;code class=&quot;language-text&quot;&gt;${}&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;Destructuring&lt;/h4&gt;
&lt;p&gt;destructing allows you parse an object and get certain keys&lt;/p&gt;
&lt;p&gt;let’s say you want to get the key: ‘name’ from the object, traditionally you would do &lt;code class=&quot;language-text&quot;&gt;obj.name&lt;/code&gt; each time you want to access the name&lt;/p&gt;
&lt;p&gt;Wouldn’t it be better to parse the name once and use it? That is what destructuring allows you to do&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;98429420382323490000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var obj = { name: &amp;quot;devsurvival&amp;quot;, age: 2 }

const { name } = obj`, `98429420382323490000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; obj&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also provide an alias for a key!&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;54397380333356770000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var obj = { name: &amp;quot;devsurvival&amp;quot;, age: 2 }

const { name: nameAlias } = obj
console.log(nameAlias) // nameAlias is an alias for the name key`, `54397380333356770000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; nameAlias &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; obj
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nameAlias&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// nameAlias is an alias for the name key&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Spread Operator&lt;/h4&gt;
&lt;p&gt;The spread operator is used to spread an array or an object. Let me explain using an example&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;43978609108113600000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var arr1 = [1, 2, 3]
var arr2 = [4, 5, 6]
// let&apos;s say we want to append arr2 to arr1
arr2.forEach(currentElement =&gt; arr1.push(currentElement))

// using spread operator, we can right this more concisely

var arr1 = [...arr1, ...arr2] // we are spreading the values of each array into a new array`, `43978609108113600000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// let&apos;s say we want to append arr2 to arr1&lt;/span&gt;
arr2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; arr1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;currentElement&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// using spread operator, we can right this more concisely&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;arr1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;arr2&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// we are spreading the values of each array into a new array&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;How About Objects?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;you can also spread objects!&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;80122746095066970000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function addKeys(obj1, obj2) {
  return { ...obj1, ...obj2 }
}
var obj = { name: &amp;quot;devsurvival&amp;quot; }
var obj2 = { age: 2, favoriteFood: &amp;quot;donut&amp;quot; }
addKeys(obj, obj2)`, `80122746095066970000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;addKeys&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;obj1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; obj2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;obj1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;obj2 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; obj2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; favoriteFood&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;donut&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;addKeys&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; obj2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here we created a function &lt;code class=&quot;language-text&quot;&gt;addKeys&lt;/code&gt; that takes the key value pairs in the second object and spread them into the first object&lt;/p&gt;
&lt;h4&gt;Rest operator&lt;/h4&gt;
&lt;p&gt;The rest operators is kinda like &lt;code class=&quot;language-text&quot;&gt;spread&lt;/code&gt; counter part. Instead of spreading things, it gathers them!&lt;/p&gt;
&lt;p&gt;let’s see some use cases&lt;/p&gt;
&lt;p&gt;we can use rest operators in functions to pass a variable number of parameters&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;48817659903228240000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function fn(firstParam, ...otherParams) {
  console.log(firstParam)
  console.log(otherParams)
}

fn(1, 2, 3, 4)

// prints 1
// prints [2,3,4]`, `48817659903228240000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;firstParam&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;otherParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;firstParam&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;otherParams&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// prints 1&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// prints [2,3,4]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It can also be used to gather the keys in an object&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;66124451616298140000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const object = { name: &amp;quot;devsurvival&amp;quot;, age: 3, food: &amp;quot;chicken nuggets&amp;quot; }

const { food, ...restOfTheKeys } = object

// food = &apos;chicken nuggets&apos;
// restOfTheKeys = {name: &amp;quot;devsurvival&amp;quot;, age: 3}`, `66124451616298140000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; object &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; food&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;chicken nuggets&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; food&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restOfTheKeys &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; object

&lt;span class=&quot;token comment&quot;&gt;// food = &apos;chicken nuggets&apos;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// restOfTheKeys = {name: &quot;devsurvival&quot;, age: 3}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;import and export&lt;/h4&gt;
&lt;p&gt;importing and exporting are how we share codes across multiple files&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;84198286610560240000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// file1.js

//named export
export function fn() {
  console.log(&amp;quot;function from file1&amp;quot;)
}

// file2.js

import { fn } from &amp;quot;file1.js&amp;quot;

fn()`, `84198286610560240000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// file1.js&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//named export&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;function from file1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// file2.js&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; fn &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;file1.js&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;default export&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;35518194235101320000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// file1.js

export default function() {
  console.log(&amp;quot;another function from file 1&amp;quot;)
}

// file2.js
import fn from &amp;quot;file1.js&amp;quot;

fn()`, `35518194235101320000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// file1.js&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;another function from file 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// file2.js&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; fn &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;file1.js&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Sets and Map&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Sets&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;are just a list of unique things. A set can contain numbers and strings&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;81350722726654330000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var set = new Set()
set.add(1)
set.add(&amp;quot;one&amp;quot;)
set.add(1) // will not be added again since 1 already exists in the set

// set = [1, &amp;quot;one&amp;quot;]`, `81350722726654330000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;one&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// will not be added again since 1 already exists in the set&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// set = [1, &quot;one&quot;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Map&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Maps are like dictionaries that allows you to search for a key and get the value based on the key&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;60019328833566780000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var map = new Map()
const key = &amp;quot;name&amp;quot;
map.set(key, &amp;quot;devsurvival&amp;quot;)
map.get(key) // name: &apos;devsurvival&apos;`, `60019328833566780000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; map &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;name&quot;&lt;/span&gt;
map&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;devsurvival&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
map&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// name: &apos;devsurvival&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;setTimeout and setInterval&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;setTimeout&lt;/code&gt; allows you to execute some code after a specified amount of milliseconds has passed&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;19549100312249946000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const timeoutId = setTimeOut(() =&gt; {
  console.log(&amp;quot;one second has passed!&amp;quot;)
}, 1000)

// it will print out the message after one second has passed`, `19549100312249946000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; timeoutId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeOut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;one second has passed!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// it will print out the message after one second has passed&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What if something happens and we want to cancel the setTimeout?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;72891430413515240000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const timeoutId = setTimeOut(() =&gt; console.log(&amp;quot;one second has passed!&amp;quot;), 1000)

clearTimeout(timeoutId) // each setTimeout() returns an id of the timeout which is used for clearing/cancelling the timeout`, `72891430413515240000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; timeoutId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeOut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;one second has passed!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;clearTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;timeoutId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// each setTimeout() returns an id of the timeout which is used for clearing/cancelling the timeout&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;setInterval&lt;/code&gt; is used to perform some operation with a given time interval&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;20199843564510077000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const setIntervalId = setInterval(
  () =&gt; console.log(&amp;quot;another second has passed&amp;quot;),
  1000
)

// this will print the message every second`, `20199843564510077000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; setIntervalId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;another second has passed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// this will print the message every second&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Promises&lt;/h4&gt;
&lt;p&gt;promises are asynchronous operations meaning they do not block the program execution after being invoked.&lt;/p&gt;
&lt;p&gt;This is commonly used when fetching data from some external source which is unpredictable in how long it takes to respond. It could be instantaneous, 2 seconds, or a couple of hours. We just don’t know&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;21124121195619193000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(&amp;quot;doing something...&amp;quot;)
console.log(&amp;quot;fetched data: &amp;quot;, fetchData()) // this is asynchronous
console.log(&amp;quot;finished doing something...&amp;quot;)

//output:

// &amp;quot;doing something...&amp;quot;
// &amp;quot;finished doing something...&amp;quot;
// &amp;quot;fetched data: ...&amp;quot;`, `21124121195619193000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;doing something...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;fetched data: &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetchData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// this is asynchronous&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;finished doing something...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//output:&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// &quot;doing something...&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// &quot;finished doing something...&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// &quot;fetched data: ...&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the program above, Javascript will not wait for fetching the data to complete before printing ‘finished doing something…’&lt;/p&gt;
&lt;p&gt;How do we wait to get a response before proceeding?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;34919912515261096000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(&amp;quot;doing something...&amp;quot;)
fetchData()
  .then(data =&gt; {
    console.log(&amp;quot;fetched data: &amp;quot;, data)
    console.log(&amp;quot;finished doing something...&amp;quot;)
  })
  .catch(error =&gt; {
    console.log(&amp;quot;there was an error :( &amp;quot;, error)
  })`, `34919912515261096000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;doing something...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;fetchData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;fetched data: &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;finished doing something...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;there was an error :( &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We use &lt;code class=&quot;language-text&quot;&gt;.then()&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;.catch()&lt;/code&gt;. &lt;code class=&quot;language-text&quot;&gt;.then()&lt;/code&gt; will wait for fetching data to complete and pass the result into the &lt;code class=&quot;language-text&quot;&gt;data&lt;/code&gt; parameter&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;.catch()&lt;/code&gt; will catch any error that is returned&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating a Promise&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;15010881576118161000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var newProm = new Promise((resolve, reject) =&gt; {
  // do something ...
  if (2 === 2) {
    resolve(2)
    // if error
    reject(&amp;quot;sorry&amp;quot;)
  }
})

newProm.then(res =&gt; console.log(res)) // prints 2`, `15010881576118161000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; newProm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; reject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// do something ...&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// if error&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;reject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;sorry&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

newProm&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Async and Await&lt;/h4&gt;
&lt;p&gt;What happens when we have a series of request that depends of the result of the previous request&lt;/p&gt;
&lt;p&gt;using .then()&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;75410295098554040000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function makeRequests() {
  request1().then(result =&gt; {
    request2(result).then(result =&gt; {
      request3(result).then(result =&gt; {
        request(4).then(result =&gt; {
          //...
        })
      })
    })
  })
}`, `75410295098554040000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;makeRequests&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;request1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;request2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;request3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;this nesting is hard to read and harder to debug.&lt;/p&gt;
&lt;p&gt;To avoid this, they introduced Async and Await&lt;/p&gt;
&lt;p&gt;Same implementation using Async and Await&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;18893502859222712000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`async function makeRequests() {
  const result1 = await request1()
  const result2 = await request2(result1)
  const result3 = await request3(result2)
  const result4 = await request4(result3)
}`, `18893502859222712000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;makeRequests&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;request1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;request2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result3 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;request3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; result4 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;request4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result3&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use &lt;code class=&quot;language-text&quot;&gt;await&lt;/code&gt; to wait for our requests, we have to mark the function with &lt;code class=&quot;language-text&quot;&gt;async&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Cool right? But there are some caveats when using async functions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;All functions marked with &lt;code class=&quot;language-text&quot;&gt;async&lt;/code&gt; returns a promise&lt;/li&gt;
&lt;li&gt;Don’t stick an &lt;code class=&quot;language-text&quot;&gt;await&lt;/code&gt; in front of every promises! If you don’t really care about the return value, just let them be asynchronous.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Error Handling&lt;/h4&gt;
&lt;p&gt;How do we handle errors?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50378847850021950000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`try {
  // do something that can cause an error
  // let&apos;s see.. I know! let&apos;s reference a variable that doesn&apos;t exists!&apos;
  value / 0
} catch (err) {
  console.log(err)
}`, `50378847850021950000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// do something that can cause an error&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// let&apos;s see.. I know! let&apos;s reference a variable that doesn&apos;t exists!&apos;&lt;/span&gt;
  value &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Start learning &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;bash commands&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Become a Web Developer With a Free Web Dev Bootcamp!]]></title><description><![CDATA[Start on your journey to become a web developer! I have been working on a web development bootcamp to try and share some of the knowledge…]]></description><link>https://www.devsurvival.com/new-web-dev-bootcamp/</link><guid isPermaLink="false">https://www.devsurvival.com/new-web-dev-bootcamp/</guid><pubDate>Mon, 04 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Start on your journey to become a web developer!&lt;/h3&gt;
&lt;p&gt;I have been working on a web development bootcamp to try and share some of the knowledge about web development that I have acquired over the years.&lt;/p&gt;
&lt;p&gt;It is nothing fancy, just a series of blog posts covering a certain aspect of web development.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If this bootcamp or part of it helps at least one person, then it would have been worth it.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;/courses/&quot;&gt;learn more&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn Javascript Part 2 ∙ ES5]]></title><description><![CDATA[Goal Here we will learn some new Javascript features that were introduced in ES5 that will be useful when developing our React and Nodejs…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-javascript-part2/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-javascript-part2/</guid><pubDate>Mon, 04 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Goal&lt;/h3&gt;
&lt;p&gt;Here we will learn some new Javascript features that were introduced in ES5 that will be useful when developing our React and Nodejs apps.&lt;/p&gt;
&lt;h3&gt;What is ES5&lt;/h3&gt;
&lt;p&gt;ES5 is a set of new features added to Javascript in 2009 to enhance productivity and to enable certain features natively without the need to hack it or code it out yourself&lt;/p&gt;
&lt;h3&gt;ES5 Features&lt;/h3&gt;
&lt;p&gt;Note: all of these features can be implemented using basic Javascript, but they exists to save you time.&lt;/p&gt;
&lt;p&gt;We will walk through a couple of these features and see how they can be implemented using basic Javascript. I am not suggesting that you should develop that way , but it can shed light on how these features were constructed&lt;/p&gt;
&lt;h4&gt;String.trim()&lt;/h4&gt;
&lt;p&gt;allows you to trim whitespaces from the start and end of a string.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;41569729298012700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var str = &amp;quot; Hi There   &amp;quot;
var trimmedStr = str.trim() // &amp;quot;Hi There&amp;quot;`, `41569729298012700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; Hi There   &quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; trimmedStr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;Hi There&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Array.isArray()&lt;/h4&gt;
&lt;p&gt;checks if a variable is an array&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;30333450688008700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var arr = []
var str = &amp;quot;[]&amp;quot;

Array.isArray(arr) // true
Array.isArray(str) // false`, `30333450688008700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;[]&quot;&lt;/span&gt;

Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;
Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Array.forEach()&lt;/h4&gt;
&lt;p&gt;loops through the elements on an array and run some code for each item, but it does not change the original array or return anything&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50810833060553380000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var arr = [1, 2, 3]
arr.forEach(function(element, index, arr, thisArg) {
  if (element === arr[index]) {
    console.log(element)
  }
})`, `50810833060553380000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;element&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; thisArg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;element &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;forEach is part of the &lt;code class=&quot;language-text&quot;&gt;Array&lt;/code&gt; prototype object and as such, you can invoke &lt;code class=&quot;language-text&quot;&gt;forEach&lt;/code&gt; using the &lt;code class=&quot;language-text&quot;&gt;.&lt;/code&gt; operator on any array &lt;code class=&quot;language-text&quot;&gt;[].forEach()&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;What is the function that we are passing to &lt;code class=&quot;language-text&quot;&gt;forEach&lt;/code&gt; ?&lt;/p&gt;
&lt;p&gt;It is an anonymous function that accepts four parameters:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the current element&lt;/li&gt;
&lt;li&gt;the index of the current element&lt;/li&gt;
&lt;li&gt;the entire array&lt;/li&gt;
&lt;li&gt;finally the &lt;code class=&quot;language-text&quot;&gt;thisArg&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For most of your work, you will be concerned with only the first three parameters.&lt;/p&gt;
&lt;p&gt;Let’ try to recreate the forEach() function using regular Javascript&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;25903498595236905000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function forEach(arr, fn) {
  var i = 0
  while (i &lt; arr.length) {
    fn(arr[i], i, arr, this)
    i++
  }
  return
}`, `25903498595236905000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Can you figure out what is happening in this function…&lt;/p&gt;
&lt;p&gt;Here is what is happening:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;we declared a function called forEach(arr, fn) that accepts an array and a function&lt;/li&gt;
&lt;li&gt;we loop through each element in the array using a &lt;code class=&quot;language-text&quot;&gt;while&lt;/code&gt; loop&lt;/li&gt;
&lt;li&gt;in each iteration we are invoking the function &lt;code class=&quot;language-text&quot;&gt;fn&lt;/code&gt; that we passed in and passing the current element &lt;code class=&quot;language-text&quot;&gt;arr[i]&lt;/code&gt;, the current index &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt;, the array &lt;code class=&quot;language-text&quot;&gt;arr&lt;/code&gt; , and a &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; reference&lt;/li&gt;
&lt;li&gt;once the loop terminates, we return nothing&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s trying calling it&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;54283150698913370000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`forEach([1, 2, 3], function(currentElement, currentIndex, array, thisArg) {
  console.log(currentElement, currentIndex)
})

/* 
Output:
1 0
2 1
3 2
*/`, `54283150698913370000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; currentIndex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; array&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; thisArg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;currentElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; currentIndex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/* 
Output:
1 0
2 1
3 2
*/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Array.map()&lt;/h4&gt;
&lt;p&gt;Array.map() is similar to Array.forEach(), but it maps each element of the array to a new item and returns a new array with those new items&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;13115529341529975000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var newArray = [1, 2, 3].map(function(
  currentElement,
  currentIndex,
  array,
  thisArg
) {
  return currentElement * 2
})

// newArray = [2,4,6]`, `13115529341529975000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  currentIndex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  array&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  thisArg&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// newArray = [2,4,6]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are mapping over an array, and returning each value doubled&lt;/p&gt;
&lt;h4&gt;Array.filter()&lt;/h4&gt;
&lt;p&gt;Used when trying to filter certain elements from the array&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;43490259657133620000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var filteredArr = [1, 2, 3].filter(function(
  currentElement,
  currentIndex,
  array,
  thisArg
) {
  return currentElement &gt; 2
})

// filteredArr = [3]`, `43490259657133620000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; filteredArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  currentIndex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  array&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  thisArg&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// filteredArr = [3]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When filtering an array using Array.filter(), if the function that we pass in returns true, then that element is included in the new array. otherwise, it is excluded from the new array.&lt;/p&gt;
&lt;h4&gt;Array.reduce()&lt;/h4&gt;
&lt;p&gt;This one is a little complicated because there are many ways to use it.&lt;/p&gt;
&lt;p&gt;You can use it to map and filter at the same time&lt;/p&gt;
&lt;p&gt;Here is an implementation using just map and filter that filters out value that are &lt;code class=&quot;language-text&quot;&gt;&amp;gt;=2&lt;/code&gt; and maps those values to a new value that is doubled the original&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;16811142847984374000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var newArr = [1, 2, 3]
  .filter(function(currentElement) {
    return currentElement &gt;= 2
  })
  .map(function(currentElement) {
    return currentElement * 2
  })

//output: newArr = [4,6]`, `16811142847984374000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; newArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//output: newArr = [4,6]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The downside to doing this, is that you are performing filter and map sequentially meaning you are revisiting certain elements twice! Once for filtering and another time to map().&lt;/p&gt;
&lt;p&gt;This is generally ok for small amount of data, but what if you have a set of millions of values? Doing it this way can be quite expensive&lt;/p&gt;
&lt;p&gt;Wouldn’t it be better to visit each value, check if it should be filtered out and doubling it at the same time? we would only have to visit each element once!&lt;/p&gt;
&lt;p&gt;Here is the same functionality implemented using Array.reduce():&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9755108028111215000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var newArr = [1, 2, 3].reduce(function(
  accumulator,
  currentElement,
  currentIndex,
  arr,
  thisArg
) {
  if (currentElement &gt;= 2) {
    accumulator.push(currentElement * 2)
  }
  return accumulator
},
[])

// output: newArr = [4,6]`, `9755108028111215000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; newArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token parameter&quot;&gt;accumulator&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  currentElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  currentIndex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  arr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  thisArg&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;currentElement &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    accumulator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;currentElement &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; accumulator
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// output: newArr = [4,6]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;invoking the reduce() function on our array &lt;code class=&quot;language-text&quot;&gt;[1,2,3]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;passing in a function that accepts an &lt;code class=&quot;language-text&quot;&gt;accumulator&lt;/code&gt;, the currentElement, the currentIndex, the array, and the thisArg&lt;/li&gt;
&lt;li&gt;We are also passing in an empty array as a second argument to the reduce() function. This empty array is our accumulator&lt;/li&gt;
&lt;li&gt;In each iteration, we check if the currentElement is greater than or equal to 2&lt;/li&gt;
&lt;li&gt;If it is, then we add the doubled value of the currentElement to the accumulator&lt;/li&gt;
&lt;li&gt;Then we return the accumulator&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note: always make sure to return a accumulator&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;learn more&lt;/a&gt; about &lt;code class=&quot;language-text&quot;&gt;Array.reduce()&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;Array.every()&lt;/h4&gt;
&lt;p&gt;Checks if every element in the array meets a condition and returns a boolean&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;43877631616558710000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var res = [1, 2, 3].every(function(currentElement) {
  return currentElement &lt; 5
})

// res = true, every element is less than 5

var res2 = [1, 2, 3].every(function(currentElement) {
  return currentElement &lt; 2
})
// res2 = false, not every element is less than 2, because 3 is greater than 2`, `43877631616558710000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;every&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// res = true, every element is less than 5&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; res2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;every&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// res2 = false, not every element is less than 2, because 3 is greater than 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Array.some()&lt;/h4&gt;
&lt;p&gt;Checks if at least one element meets a condition and returns a boolean&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;58488365861063890000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`;[1, 2, 3].some(function(currentElement) {
  return currentElement === 1
}) // true because there is at least one element that is equal to 1`, `58488365861063890000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;currentElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; currentElement &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// true because there is at least one element that is equal to 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note: the function will terminate when it encounters the first element that meets the condition&lt;/p&gt;
&lt;h4&gt;Object Properties Access Using Strings&lt;/h4&gt;
&lt;p&gt;Prior to ES5 object members are accessed using the &lt;code class=&quot;language-text&quot;&gt;.&lt;/code&gt; operator, such as &lt;code class=&quot;language-text&quot;&gt;person.name&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;In ES5 the equivalent can be written as &lt;code class=&quot;language-text&quot;&gt;person[&amp;#39;name&amp;#39;]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Why would you write write it this way? It looks more complicated and doesn’t seem to do anything different, then why?&lt;/p&gt;
&lt;p&gt;This is useful when you are given the object key as a string&lt;/p&gt;
&lt;h4&gt;Multiline String Literals&lt;/h4&gt;
&lt;p&gt;You can now create multiline string literals using: ``&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;87781626975038670000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var str = \`line 1
            line 2
            line 3\``, `87781626975038670000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;line 1
            line 2
            line 3&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;More information&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://speakingjs.com/es5/ch25.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;list&lt;/a&gt; of all ES5 features&lt;/p&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Learn more advanced Javascript features in &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;ES6&lt;/a&gt;!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn Javascript part 1 ∙ Basics]]></title><description><![CDATA[What is Javascript Javascript is an interpreted language built for the web. Interpreted here means that there is no compilation of the code…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-javascript/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-javascript/</guid><pubDate>Sun, 03 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;What is Javascript&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Javascript&lt;/a&gt; is an interpreted language built for the web. Interpreted here means that there is no compilation of the code into binary before it is executed.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;You can try this out by opening a browser, and then opening up the console. For google chrome, you can use &lt;code class=&quot;language-text&quot;&gt;fn12&lt;/code&gt; to open the developer tool bar&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/c1d7f13ceca5d17039e8d2fc0a63746c/11b93/console.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 28.22085889570552%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAABYlAAAWJQFJUiTwAAAA1UlEQVQY052P646DIBCFef931FaqMggKFqOuiqcMzW5M/3UnOZnM7TsgiAjDMEBrDdW2GJzHvXqgpQ7OOSil4L1Hm2a8w72maUCkc38cRzyfIfdZQlZVWqT3sncwboQkB6ksbrd7BrFhCAHTNGFZllyXZQkpJeq6zmBWURQQShFId9Bdh9karH2Pnz7lKWBZV2zbhn3fcZ4nYoxZx3FkMGtNO795nmcImwDG2PRcj5iOYzrO+YjgYNAVxuL6GtbaxDB5JvgbTGfXP8AF9K3E1enT+T/xArdk0HaWr/MfAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;console&quot;
        title=&quot;console&quot;
        src=&quot;/static/c1d7f13ceca5d17039e8d2fc0a63746c/a6d36/console.png&quot;
        srcset=&quot;/static/c1d7f13ceca5d17039e8d2fc0a63746c/222b7/console.png 163w,
/static/c1d7f13ceca5d17039e8d2fc0a63746c/ff46a/console.png 325w,
/static/c1d7f13ceca5d17039e8d2fc0a63746c/a6d36/console.png 650w,
/static/c1d7f13ceca5d17039e8d2fc0a63746c/e548f/console.png 975w,
/static/c1d7f13ceca5d17039e8d2fc0a63746c/11b93/console.png 1124w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Why Learn Javascript&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;It is very easy to learn&lt;/li&gt;
&lt;li&gt;most of the web runs javascript as the main scripting language to make website more interactive&lt;/li&gt;
&lt;li&gt;You can write Javascript on the frontend and the backend using NodeJS&lt;/li&gt;
&lt;li&gt;If you want to become a web developer, Javascript is standard knowledge.&lt;/li&gt;
&lt;li&gt;There are a lot of popular frameworks and libraries (React) that uses Javascript&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Goal&lt;/h3&gt;
&lt;p&gt;The goal is to cover the basic of Javascript, especially the skills you need to be successful when doing frontend work in React and backend work with NodeJS&lt;/p&gt;
&lt;p&gt;Hence, we will not cover everything there is to know about Javascript (which is quite a bit). However, feel free to do personal research and learn more about it at your own leisure.&lt;/p&gt;
&lt;h3&gt;Getting Started&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Creating a Javascript file&lt;/strong&gt; is super easy. Let’s create a new folder for this session&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;93217807052838130000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir learn-Javascript`, `93217807052838130000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; learn-Javascript&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let’s navigate into the folder&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;79822878508024740000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`cd learn-Javascript`, `79822878508024740000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; learn-Javascript&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create two files &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt;. Note: the Javascript file ends with a &lt;code class=&quot;language-text&quot;&gt;.js&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50124256140523225000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch index.js index.html`, `50124256140523225000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; index.js index.html&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now let’s write some Javascript. Inside the &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file, type in the following&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;98231562550953500000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// index.js
alert(&amp;quot;hey there&amp;quot;)`, `98231562550953500000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// index.js&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hey there&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;this will create an alert when the page opens. In order for this to work, we have to attach the JS file to the HTML page. In the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of the &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt; file, add the following: &lt;code class=&quot;language-text&quot;&gt;&amp;lt;script src=&amp;quot;index.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;. Now, when you open the &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt; file inside the browser, you should get a popup that saids “hey there”&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/dfb176e4051ce98c11aa24e871e6632e/9a1cf/alert.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 30.67484662576687%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAABYlAAAWJQFJUiTwAAAArklEQVQY051QwQ2DMAzMJF2m6kgdg3W6AQPwpo++IkpVipQ4CQnJEQdRqS9QTzrZD/t8PkHGQGsNIoLO5Gqthfce0zQdZggB4zhC8HLfv9B1HaSUhXzgKGIC5rj2RZCIHRKG4VMubUgp7TJP/Yib/K1wzhW7/OIc4yGhTWzO9urW4dZY1Hdf4hIs9C9cAC7VG6frE+dqWAU5L86R7TK536Mx9rvTSo3moXIlKKWwAKJZ0Z1rys6HAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;alert&quot;
        title=&quot;alert&quot;
        src=&quot;/static/dfb176e4051ce98c11aa24e871e6632e/a6d36/alert.png&quot;
        srcset=&quot;/static/dfb176e4051ce98c11aa24e871e6632e/222b7/alert.png 163w,
/static/dfb176e4051ce98c11aa24e871e6632e/ff46a/alert.png 325w,
/static/dfb176e4051ce98c11aa24e871e6632e/a6d36/alert.png 650w,
/static/dfb176e4051ce98c11aa24e871e6632e/9a1cf/alert.png 924w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Congratulations, you have ran your first Javascript code!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Printing to the console&lt;/h3&gt;
&lt;p&gt;You will find yourself printing to the console many times because it was the first way that most of us where taught to debug code. The idea of printing something to the console is common to most languages, such as C or Java.&lt;/p&gt;
&lt;p&gt;To print to the console use&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;6153338548131426000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(&amp;quot;hey there&amp;quot;)`, `6153338548131426000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hey there&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also pass in variables:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;99316669632344420000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(myVar1, myVar2)`, `99316669632344420000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;myVar1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; myVar2&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;The semi-colon debate&lt;/h3&gt;
&lt;p&gt;If you noticed from other programming languages, such as C, each statements are typically ended by a &lt;code class=&quot;language-text&quot;&gt;;&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;56392617816637290000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`printf(&amp;quot;hello there&amp;quot;);`, `56392617816637290000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hello there&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, Javascript does not enforce this practice and you can omit the semi-colon and it makes no difference. &lt;code class=&quot;language-text&quot;&gt;console.log(&amp;quot;cat&amp;quot;)&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;console.log(&amp;quot;dog&amp;quot;);&lt;/code&gt; are both the same in terms of output.&lt;/p&gt;
&lt;h3&gt;Variables&lt;/h3&gt;
&lt;p&gt;Variables are how we store data in programming.&lt;/p&gt;
&lt;p&gt;Variables in Javascript are stored in a data type called a &lt;code class=&quot;language-text&quot;&gt;var&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Number&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;52842154271886655000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var num = 2
var num2 = num + 1`, `52842154271886655000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; num2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;String&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;12452040859584580000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var str = &amp;quot;hi there&amp;quot;
var strCat = str + &amp;quot; hieu&amp;quot;
var singleQuoteStr = &amp;quot;hi there hieu&amp;quot;`, `12452040859584580000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hi there&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; strCat &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; hieu&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; singleQuoteStr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hi there hieu&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Floats&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;77488962108685930000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var float = 3.14
var res = float * 2`, `77488962108685930000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; float &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3.14&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; float &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Boolean&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;26740251331482747000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var isTrue = true
var isFale = false`, `26740251331482747000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; isTrue &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; isFale &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Objects&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;objects are used when you want to store multiple related data types inside one location.&lt;/p&gt;
&lt;p&gt;Object consists of key value pairs.&lt;code class=&quot;language-text&quot;&gt;{Key: Value}&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;27877852645240100000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var emptyObject = {} // empty object
var dog = {
  breed: &amp;quot;golden retriever&amp;quot;,
  age: 2,
  isCute: true,
  isDog: true,,
}

//accessing member Variables

console.log(&amp;quot;dog breed &amp;quot;, dog.breed)
console.log(&amp;quot;dog&apos;s age&amp;quot;, dog[&apos;age&apos;])
if(dog.isDog){
    console.log(&amp;quot;It is a dog!&amp;quot;)
}`, `27877852645240100000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; emptyObject &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// empty object&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; dog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  breed&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;golden retriever&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  isCute&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  isDog&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//accessing member Variables&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dog breed &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dog&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;breed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dog&apos;s age&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dog&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;age&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dog&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isDog&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;It is a dog!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;you can access a member of an object using the &lt;code class=&quot;language-text&quot;&gt;.&lt;/code&gt; operator or the access operator &lt;code class=&quot;language-text&quot;&gt;object[&amp;#39;NAME_OF_KEY&amp;#39;]&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;Declaring a variable&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;87910730887683240000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var declaredVar`, `87910730887683240000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; declaredVar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Assigning a variable&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;16612165078326190000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`declaredVar = 2`, `16612165078326190000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;declaredVar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Comments&lt;/h3&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;56493684777597860000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// this is a single line comments
/* 
    this is a
    multiline comment
 */`, `56493684777597860000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// this is a single line comments&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;/* 
    this is a
    multiline comment
 */&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Operators&lt;/h3&gt;
&lt;p&gt;Operators are how you perform calculations.&lt;/p&gt;
&lt;h4&gt;Arithmetic operators&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;14765408476886432000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var sum = 1 + 2 //3
var difference = 2 - 1 //1
var product = 5 * 100 //500
var quotient = 10 / 2 //5
var remainder = 5 % 4 // 1 because 4 goes into 5 one time with a remainder of 1
var exponent = 5 ** 2 // 25  = 5^2`, `14765408476886432000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; sum &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//3&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; difference &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//1&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; product &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//500&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; quotient &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//5&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; remainder &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1 because 4 goes into 5 one time with a remainder of 1&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; exponent &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 25  = 5^2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Incrementing and Decrementing&lt;/h4&gt;
&lt;p&gt;sometimes you just want to add or subtract by some value.&lt;/p&gt;
&lt;h5&gt;Incrementing&lt;/h5&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;29447824593505520000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var value = 10
value = value + 1 // increment by 1 =&gt; value = 11`, `29447824593505520000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// increment by 1 =&gt; value = 11&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are adding 1 to &lt;code class=&quot;language-text&quot;&gt;value&lt;/code&gt; and assigning it back to &lt;code class=&quot;language-text&quot;&gt;value&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;a shortcut for this is:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;81393239692451760000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`value++ // this will return the previous value`, `81393239692451760000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;value&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// this will return the previous value&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What is &lt;code class=&quot;language-text&quot;&gt;++&lt;/code&gt; doing?&lt;/p&gt;
&lt;p&gt;Here we are saying increase the value by one and return the previous value, which is also called pre-increment&lt;/p&gt;
&lt;p&gt;Why?&lt;/p&gt;
&lt;p&gt;Sometimes you want to increase a value by one but temporarily reference the previous value&lt;/p&gt;
&lt;p&gt;Another way of incrementing is called the post-increment&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;97726826476635290000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`++value // this will return the value after adding 1`, `97726826476635290000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;value &lt;span class=&quot;token comment&quot;&gt;// this will return the value after adding 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is similar to pre-increment except that it returns the new value instead of the previous value.&lt;/p&gt;
&lt;h4&gt;Decrementing&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;29409466499877390000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var value = 9
value = value - 1 // decrease the value by 2 and then assign it back to value`, `29409466499877390000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// decrease the value by 2 and then assign it back to value&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;shortcut:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;8440707121213364000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`value-- // pre-decrement
--value // post-decrement`, `8440707121213364000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;value&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// pre-decrement&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;value &lt;span class=&quot;token comment&quot;&gt;// post-decrement&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Assignment Operators&lt;/h4&gt;
&lt;p&gt;Before we were just incrementing and decrementing by a fixed value of 1. What if we want to multiply or divide? What if we want to do it with some other value besides 1?&lt;/p&gt;
&lt;p&gt;That is were assignment operators come in&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;80503321095988850000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var value = 100
value *= 2 // multiply value by 2 and assign it back to value
value /= 2 // divide value by 2 and assign it back to value
value -= 10 // subtract 10 from value and assign the result back to value
value += 20 // add 20 to value and assign the result back to value
value %= 3 // take the result of value%3 and assign it back to value
value **= 2 // raise value to the power of 2 and assign the result back to value`, `80503321095988850000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// multiply value by 2 and assign it back to value&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;/=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// divide value by 2 and assign it back to value&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// subtract 10 from value and assign the result back to value&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// add 20 to value and assign the result back to value&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;%=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// take the result of value%3 and assign it back to value&lt;/span&gt;
value &lt;span class=&quot;token operator&quot;&gt;**=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// raise value to the power of 2 and assign the result back to value&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;String Operator&lt;/h4&gt;
&lt;p&gt;you can concat or add two strings by using &lt;code class=&quot;language-text&quot;&gt;+&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;6534375794434211000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var str1 = &amp;quot;hello&amp;quot;
var newStr = str1 + &amp;quot; Devsurvival!&amp;quot;
console.log(newStr) // &amp;quot;hello Devsurvival!&amp;quot;`, `6534375794434211000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; newStr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; str1 &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; Devsurvival!&quot;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newStr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;hello Devsurvival!&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;shortcut:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;30194212019059520000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var str1 = &amp;quot;hello&amp;quot;
str1 += &amp;quot; Devsurvival&amp;quot; //  concat &amp;quot;hello&amp;quot; and &amp;quot; Devsurvival&amp;quot; and assign the result to str1`, `30194212019059520000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; str1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello&quot;&lt;/span&gt;
str1 &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; Devsurvival&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//  concat &quot;hello&quot; and &quot; Devsurvival&quot; and assign the result to str1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also add string and numbers&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;92176627234165060000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var donuts = &amp;quot; donuts&amp;quot;
var quantity = 2
console.log(quantity + donuts) // &amp;quot;2 donuts&amp;quot;`, `92176627234165060000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; donuts &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; donuts&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; quantity &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;quantity &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; donuts&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;2 donuts&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Comparison Operators&lt;/h4&gt;
&lt;p&gt;How to tell if two things are the same or different? We use comparison operators&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;==&lt;/code&gt; - equal, and doesn’t care if they are not the same type&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;62815975995677565000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var sameValue = 2 == &amp;quot;2&amp;quot; // same value but not the same type
// true`, `62815975995677565000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; sameValue &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// same value but not the same type&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;===&lt;/code&gt; - equal, and does care if they are the same type&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;53615256036663615000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var sameValue = 2 === &amp;quot;2&amp;quot; // same value but not the same type
// false`, `53615256036663615000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; sameValue &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// same value but not the same type&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;!=&lt;/code&gt; - not equal to&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;89316081378955740000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var notEqual = 3 != &amp;quot;3&amp;quot; // they are the same value
// false`, `89316081378955740000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; notEqual &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// they are the same value&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;!=&lt;/code&gt; - not equal to and also not the same type&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9565147634966120000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var notEqual = 3 !== &amp;quot;3&amp;quot; // they are the same value, but they are not the same type
// true`, `9565147634966120000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; notEqual &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// they are the same value, but they are not the same type&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;gt;&lt;/code&gt; - greater than&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;79367798293126630000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var greater = 1 &gt; 2
// false`, `79367798293126630000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; greater &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;&lt;/code&gt; - less than&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;63172113767348400000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var less = 1 &lt; 2
// true`, `63172113767348400000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; less &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;gt;=&lt;/code&gt; - greater than or equal to&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;34318881871763420000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var greaterOrEqual = 2 &gt;= 2 // not greater , but it is equal to 2
// true`, `34318881871763420000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; greaterOrEqual &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// not greater , but it is equal to 2&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;=&lt;/code&gt; - less than or equal to&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;91789753388637620000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var lessThanOrEqual = 2 &lt;= 1
//false`, `91789753388637620000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lessThanOrEqual &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Ternary operator&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;85899285654082720000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var res = 1 &gt; 2 ? &amp;quot;greater&amp;quot; : &amp;quot;less than&amp;quot;
// res = &amp;quot;less than&amp;quot;`, `85899285654082720000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;greater&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;less than&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// res = &quot;less than&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;what is going on here?&lt;/p&gt;
&lt;p&gt;we are checking if &lt;code class=&quot;language-text&quot;&gt;1 &amp;gt; 2&lt;/code&gt;. If that is true , we return “greater” , else we return “less than”&lt;/p&gt;
&lt;p&gt;What does &lt;code class=&quot;language-text&quot;&gt;res&lt;/code&gt; contains?&lt;/p&gt;
&lt;p&gt;Since 1 is not greater than 2, the condition is false. Since it is false, we return “less than”&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ternary Formula&lt;/strong&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;52909435831813110000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`CONDITION  ? if true, return something here : if false, return something here`, `52909435831813110000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;CONDITION&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; something here &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; something here&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Logical Operator&lt;/h4&gt;
&lt;p&gt;Logic operators are how we check more than one conditions at the same time. Let’s say we want to check if the person is over 18 AND owns a car. We can use the &lt;code class=&quot;language-text&quot;&gt;&amp;amp;&amp;amp;&lt;/code&gt; operator&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;90425911541509160000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var isOver18AndHaveACar = age &gt;= 18 &amp;&amp; hasCar`, `90425911541509160000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; isOver18AndHaveACar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; hasCar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;How to check if a person is over 18 OR owns a car&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;65898949074141360000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var isOver18OrHaveACar = age &gt;= 18 || hasCar`, `65898949074141360000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; isOver18OrHaveACar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; hasCar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;How to check if a person does not have car?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;49705585535476770000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var doesNotHaveCar = hasCar === false`, `49705585535476770000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; doesNotHaveCar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; hasCar &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;but there is an easier way&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;82602703499129620000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var doesNotHaveCar = !hasCar`, `82602703499129620000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; doesNotHaveCar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;hasCar&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;the &lt;code class=&quot;language-text&quot;&gt;!&lt;/code&gt; operator flips the condition&lt;/p&gt;
&lt;h3&gt;Array&lt;/h3&gt;
&lt;p&gt;Array are just a list of items&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;83391433595560260000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var strArr = [&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;]
var numArr = [1, 2, 3]`, `83391433595560260000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; strArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;one&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;two&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;three&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; numArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;getting an element in array&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;65738253048733350000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(arr[0]) // prints the first element in array`, `65738253048733350000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints the first element in array&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;getting the length of arrays&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;44873262905270300000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`console.log(arr.length) // prints the length of the array`, `44873262905270300000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints the length of the array&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Loops&lt;/h3&gt;
&lt;p&gt;loops are how we iterate over an array&lt;/p&gt;
&lt;h4&gt;For loop&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;49690740342465050000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var i
for (i = 0; i &lt; arr.length; i++) {
  console.log(arr[i])
}`, `49690740342465050000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;here we are initializing &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; to 0.&lt;/li&gt;
&lt;li&gt;We check if &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; is less than the length of the array&lt;/li&gt;
&lt;li&gt;If &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; is less than the length of the array, we enter the loop and print the current item at index &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;We are done with the loop and increment &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; by 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the general format of a for loop:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;71767310730944640000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`for ( STARTING_VALUE ; CONDITION ; UPDATE THE STARTING CONDITION){
    // if CONDITION is true
    some code to run here...
    // once the code inside the loop is done, we update the starting condition and check the condition again,
    // if the condition fails at any point, the loop terminates
}`, `71767310730944640000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;STARTING_VALUE&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;CONDITION&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;UPDATE&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;THE&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;STARTING&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;CONDITION&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// if CONDITION is true&lt;/span&gt;
    some code to run here&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// once the code inside the loop is done, we update the starting condition and check the condition again,&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// if the condition fails at any point, the loop terminates&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;While Loop&lt;/h4&gt;
&lt;p&gt;Similar to a for loop, a while loop is used to repeat some code until a certain condition is met&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;67024582192940010000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var i = 0

while (i &lt; arr.length) {
  console.log(arr[i])
  i++
}`, `67024582192940010000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In a while loop, we check for some condition. If that condition is true. we enter the loop. We keep repeating until the condition is no longer true and we exit the loop&lt;/p&gt;
&lt;h4&gt;Do While Loop&lt;/h4&gt;
&lt;p&gt;A do while loop is similar to a while except, it does executes the code inside the loop at least once regardless of the condition&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;79675963389699600000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`var i = 0
do {
  // do something...
} while (i &gt; 0)`, `79675963389699600000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// do something...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here you can see that we execute the code inside the &lt;code class=&quot;language-text&quot;&gt;do&lt;/code&gt; block and then check the condition. When we check the condition &lt;code class=&quot;language-text&quot;&gt;i&amp;gt;0&lt;/code&gt;, we know this is false, and the loop will execute only once.&lt;/p&gt;
&lt;h3&gt;Condition Statements&lt;/h3&gt;
&lt;p&gt;Conditional statements are ways we can conditionally perform something.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;69437330186895040000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`if (age &gt;= 18) {
  // do something that people over 18 can do
}`, `69437330186895040000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// do something that people over 18 can do&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The above is an &lt;code class=&quot;language-text&quot;&gt;if&lt;/code&gt; statement. It checks a condition, and if the condition is true, it executes the code block inside the parenthesis &lt;code class=&quot;language-text&quot;&gt;{}&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;Else if and Else&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;else if&lt;/code&gt; is used following an &lt;code class=&quot;language-text&quot;&gt;if&lt;/code&gt; statements to check if it satisfies another condition. You can have multiple &lt;code class=&quot;language-text&quot;&gt;else if&lt;/code&gt;, but they all have to follow an &lt;code class=&quot;language-text&quot;&gt;if&lt;/code&gt; statement.&lt;/p&gt;
&lt;p&gt;an &lt;code class=&quot;language-text&quot;&gt;else&lt;/code&gt; statement is used at the very end of the &lt;code class=&quot;language-text&quot;&gt;else if&lt;/code&gt; statement when the condition does not satisfies the &lt;code class=&quot;language-text&quot;&gt;if&lt;/code&gt; and none of the &lt;code class=&quot;language-text&quot;&gt;else if&lt;/code&gt; statements.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;24595478390194647000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`if (age &gt;= 18) {
  // if they are over 18
} else if (likesDog) {
  // if they are not over 18, check if they like dogs
} else if (playsVideoGames) {
  // if they are not over 18 and do not like dogs, check if they play video games
} else {
  // if they are not over 18, do not like dogs, and do not play video games
}`, `24595478390194647000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// if they are over 18&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;likesDog&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// if they are not over 18, check if they like dogs&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playsVideoGames&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// if they are not over 18 and do not like dogs, check if they play video games&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// if they are not over 18, do not like dogs, and do not play video games&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Switch&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;switch&lt;/code&gt; are often used when you have many conditions to check for.&lt;/p&gt;
&lt;p&gt;For instance&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;32590135454471400000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`switch (favoriteFood) {
  case &amp;quot;pizza&amp;quot;:
    console.log(&amp;quot;you liked pizza!&amp;quot;)
    break

  case &amp;quot;donuts&amp;quot;:
    console.log(&amp;quot;you like donuts!&amp;quot;)
    break
  case &amp;quot;steak&amp;quot;:
    console.log(&amp;quot;you like steak!&amp;quot;)
    break
  default:
    console.log(&amp;quot;you like&amp;quot;, favoriteFood)
}`, `32590135454471400000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;favoriteFood&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pizza&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;you liked pizza!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;donuts&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;you like donuts!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;steak&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;you like steak!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;you like&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; favoriteFood&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here you are testing the variable &lt;code class=&quot;language-text&quot;&gt;favoriteFood&lt;/code&gt; and you have a set of cases that you are testing for &lt;code class=&quot;language-text&quot;&gt;pizza, donuts, and steak&lt;/code&gt;. If the case matches, you enter the statement, execute the code, and then &lt;code class=&quot;language-text&quot;&gt;break&lt;/code&gt; which exits from the switch. Make sure you have a break at the end of each case statement.&lt;/p&gt;
&lt;p&gt;You can also provide a default case which will be executed if none of the cases matches the test value.&lt;/p&gt;
&lt;h3&gt;Functions&lt;/h3&gt;
&lt;p&gt;Functions are reusable blocks of code that we can pass different parameters into and get a different output.&lt;/p&gt;
&lt;p&gt;Let’s see how we can create a function&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;22180725606404760000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function bark() {
  console.log(&amp;quot;woof!&amp;quot;)
}`, `22180725606404760000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;woof!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we have a function called &lt;code class=&quot;language-text&quot;&gt;bark&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;How do we use it? simple.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;2673695868965820000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`bark() // invoking or calling the function bark();`, `2673695868965820000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// invoking or calling the function bark();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Passing parameters&lt;/h4&gt;
&lt;p&gt;you can make a function for dynamic by passing parameters&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50741139245909370000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function bark(nameOfDog) {
  console.log(nameOfDog + &amp;quot; barked!&amp;quot;)
}`, `50741139245909370000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;nameOfDog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nameOfDog &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; barked!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here we are passing in the &lt;code class=&quot;language-text&quot;&gt;nameOfDog&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;console.log(nameOfDog + &amp;quot; barked!&amp;quot;)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Invoked the function:&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;97780341266753180000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`barked(&amp;quot;Charlie&amp;quot;) // &amp;quot;Charlie barked!&amp;quot;`, `97780341266753180000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;barked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Charlie&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;Charlie barked!&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Returning a value&lt;/h4&gt;
&lt;p&gt;It is great that a function can perform things, but what about getting some return value from it? Javascript functions can also return a value after performing some kind of calculations&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9886960522400168000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function double(num) {
  return num * 2
}

var doubledValue = double(3) // doubledValue = 6`, `9886960522400168000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; doubledValue &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// doubledValue = 6&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This function accepts a &lt;code class=&quot;language-text&quot;&gt;num&lt;/code&gt; and returns the number after it has been doubled.&lt;/p&gt;
&lt;h4&gt;Anonymous Functions&lt;/h4&gt;
&lt;p&gt;Anonymous functions are functions without a name&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;48641817141455830000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// normal functions
function fnNAme(){

}
//anonymous functions
function(){

}`, `48641817141455830000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// normal functions&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fnNAme&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//anonymous functions&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;When To Use Anonymous Function?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When you need to pass a function definition into a another function without declaring the function explicitly. Let’s learn with an example&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;94622772477277860000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`// traditional way of passing a function to another function

function fn1() {
  console.log(&amp;quot;this is function 1&amp;quot;)
}

function run(fn) {
  fn() // invoked the function that was passed in
}
// passing fn1 to run()

run(fn1)

// The code above can be simplified using anonymous function

function run(fn) {
  // same as before
  fn()
}

// passing in the anonymous function
run(function() {
  console.log(&amp;quot;this is function 1&amp;quot;)
})`, `94622772477277860000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// traditional way of passing a function to another function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fn1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;this is function 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// invoked the function that was passed in&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// passing fn1 to run()&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fn1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// The code above can be simplified using anonymous function&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// same as before&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// passing in the anonymous function&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;this is function 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is useful when you want to pass in a function that will not be referenced anywhere else and will only be used temporarily.&lt;/p&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;Learn some advanced Javascript using ES5 and ES6 in &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;part 2&lt;/a&gt; of learning Javascript&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Authentication In Node (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/authentication-in-node/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/authentication-in-node/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Introduction To React (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/introduction-to-react/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/introduction-to-react/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Deploying App To Heroku (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/deploying-app-to-heroku/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/deploying-app-to-heroku/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Introduction To MongoDb And Mongoose(Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/learn-mongodb/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-mongodb/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Managing State With Redux (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/managing-state-with-redux/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/managing-state-with-redux/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Review And Conclusion (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/review-and-conclusion/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/review-and-conclusion/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Connecting React Client with Node API (Coming Soon!)]]></title><link>https://www.devsurvival.com/web-dev-bootcamp/connecting-react-to-api/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/connecting-react-to-api/</guid><pubDate>Sat, 02 May 2020 22:40:02 GMT</pubDate><content:encoded></content:encoded></item><item><title><![CDATA[C Programming ∙ Introduction (Coming Soon!)]]></title><description><![CDATA[Sign up for updates and be notified when new content is being released]]></description><link>https://www.devsurvival.com/c-programming/introduction/</link><guid isPermaLink="false">https://www.devsurvival.com/c-programming/introduction/</guid><pubDate>Fri, 01 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;p&gt;Sign up for &lt;a href=&quot;/newsletter/&quot;&gt;updates&lt;/a&gt; and be notified when new content is being released&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Introduction]]></title><description><![CDATA[Introduction Welcome to the Web Dev Bootcamp! If you have an interest in web development or are trying something new, then you are in the…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/introduction/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/introduction/</guid><pubDate>Fri, 01 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Welcome to the Web Dev Bootcamp!&lt;/p&gt;
&lt;div class=&quot;gatsby-resp-iframe-wrapper&quot; style=&quot;padding-bottom: 75%; position: relative; height: 0; overflow: hidden; margin-bottom: 1.0725rem&quot; &gt; &lt;iframe src=&quot;https://giphy.com/embed/xUPGGDNsLvqsBOhuU0&quot; frameborder=&quot;0&quot; class=&quot;giphy-embed&quot; allowfullscreen style=&quot; position: absolute; top: 0; left: 0; width: 100%; height: 100%; &quot;&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href=&quot;https://giphy.com/gifs/animation-cool-hello-xUPGGDNsLvqsBOhuU0&quot;&gt;via GIPHY&lt;/a&gt;&lt;/p&gt; &lt;/div&gt;
&lt;p&gt;If you have an interest in web development or are trying something new, then you are in the right place.&lt;/p&gt;
&lt;br/&gt;
&lt;h3&gt;Curriculum&lt;/h3&gt;
&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Learn the standard web technologies - HTML, CSS, and Javascript&lt;/li&gt;
&lt;li&gt;Advanced Javascript ES5 and ES6 features&lt;/li&gt;
&lt;li&gt;Bash Commands&lt;/li&gt;
&lt;li&gt;Overview of Git&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Backend&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Introduction to NodeJS and ExpressJS&lt;/li&gt;
&lt;li&gt;Understand how API and requests works&lt;/li&gt;
&lt;li&gt;Database with MongoDB and Mongoose&lt;/li&gt;
&lt;li&gt;Authentication in Node&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Frontend&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Learning React - components, states, styling&lt;/li&gt;
&lt;li&gt;Connecting React with Redux&lt;/li&gt;
&lt;li&gt;Connecting React client to API&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Deploying App&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Learn how to deploy web app to heroku&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Conclusion&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Review&lt;/li&gt;
&lt;li&gt;What to do after completing the course&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Getting Help&lt;/h3&gt;
&lt;p&gt;You can get help by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;following me on &lt;a href=&quot;https://twitter.com/HieuNgu11332621&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;submitting a github &lt;a href=&quot;https://github.com/htnguy/webdevbootcamp/issues/new&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;issue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;join the Devsurvival discord &lt;a href=&quot;https://discordservers.com/server/706606099444400220&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;post your question in the discussion section below each post&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Getting Source Code&lt;/h3&gt;
&lt;p&gt;You will find all relevant source code for this bootcamp &lt;a href=&quot;https://github.com/htnguy/webdevbootcamp&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Good Luck and Have Fun 😄&lt;/h4&gt;
&lt;h3&gt;&lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;Start Learning&lt;/a&gt;&lt;/h3&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn CSS]]></title><description><![CDATA[What is CSS CSS or Cascading Style Sheets is a language for describing how your website looks. With CSS you can alter the color, spacing…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-css/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-css/</guid><pubDate>Fri, 01 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;h3&gt;What is CSS&lt;/h3&gt;
&lt;p&gt;CSS or &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Cascading Style Sheets&lt;/a&gt; is a language for describing how your website looks. With CSS you can alter the color, spacing, orientation, size, shape, and so on.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;CSS is the design language of the web, and it is not as easy to use as it ought to be, and it can be confusing, especially if you are new to it. ~ Jeffrey Zeldman&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No worries. You don’t need to be an expert at CSS to be a web developer. You just need the basic and a little practice and the rest will take care of itself.&lt;/p&gt;
&lt;h3&gt;Goal&lt;/h3&gt;
&lt;p&gt;Learn the basics of CSS.&lt;/p&gt;
&lt;p&gt;It will not cover everything there is to know about CSS because you don’t need to know everything.&lt;/p&gt;
&lt;p&gt;It will just cover the fundamentals of CSS and most of the commonly used properties.&lt;/p&gt;
&lt;h3&gt;Creating CSS file&lt;/h3&gt;
&lt;p&gt;CSS files have the &lt;code class=&quot;language-text&quot;&gt;.css&lt;/code&gt; extension. Inside this file is a list of selectors and css properties.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;39165838407132700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`div.blue-box {
  color: blue;
  font-size: 24px;
  width: 100px;
  height: 100px;
  border: 1px solid blue;
}`, `39165838407132700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;div.blue-box&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; blue&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px solid blue&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we have a selector of &lt;code class=&quot;language-text&quot;&gt;div.blue-box&lt;/code&gt; we are targeting all div with class &lt;code class=&quot;language-text&quot;&gt;blue-box&lt;/code&gt; .&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;color: blue&lt;/code&gt; - makes the text blue&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;font-size&lt;/code&gt; - making the font 24px&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;width: 100px&lt;/code&gt; - the box is 100px wide&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;height: 100px&lt;/code&gt; - the box is 100px tall&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;border: 1px solid blue&lt;/code&gt; - it has a 1px thick blue border&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is what it looks like&lt;/p&gt;
&lt;div style=&quot;color: blue;
  font-size: 24px;
  width: 100px;
  height: 100px;
  border: 1px solid blue;&quot;&gt;
  Blue Things
&lt;/div&gt;
&lt;br/&gt;
&lt;h3&gt;Selectors&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Class&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;.round { border-radius: 25%; }&lt;/code&gt;. Notice that the class: &lt;code class=&quot;language-text&quot;&gt;round&lt;/code&gt; is pre-pended with a &lt;code class=&quot;language-text&quot;&gt;.&lt;/code&gt;. This will target any element with class: &lt;code class=&quot;language-text&quot;&gt;round&lt;/code&gt;. In other words, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;span class=&amp;quot;round&amp;quot;&amp;gt;&lt;/code&gt; , &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div class=&amp;quot;round&amp;quot;&amp;gt;&lt;/code&gt; , and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;p class=&amp;quot;round&amp;quot;&amp;gt;&lt;/code&gt; will all have the property &lt;code class=&quot;language-text&quot;&gt;border-radius&lt;/code&gt; with value &lt;code class=&quot;language-text&quot;&gt;25%&lt;/code&gt; applied to them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;id&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;#my-id { color: red }&lt;/code&gt; - this will make the element with id of &lt;code class=&quot;language-text&quot;&gt;my-id&lt;/code&gt; have a red font.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Immediate descendant&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div &amp;gt; a {color: pink}&lt;/code&gt; - the &lt;code class=&quot;language-text&quot;&gt;&amp;gt;&lt;/code&gt; tells the browser to make all immediate descendant that is an anchor tag of any div have the color pink. Immediate descendant are like your grandparent’s children (your parents), so it does not include the grandchildren(you or your siblings).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;All descendant&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div * {font-weight: bold}&lt;/code&gt; - here we are saying make all descendants of any div have a &lt;code class=&quot;language-text&quot;&gt;font-weight: bold&lt;/code&gt;. Now this is more inclusive than the immediate descendants because it includes you and everyone else related.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;here is a complete &lt;a href=&quot;https://www.w3schools.com/cssref/css_selectors.asp&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;list&lt;/a&gt; of CSS selectors&lt;/p&gt;
&lt;h3&gt;Common Properties&lt;/h3&gt;
&lt;p&gt;Here are a list of commonly used properties. Note: there are a lot more, but you don’t need to memorize any of them or know all of them. Just know that they exists and your good to go!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;color&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div {color: blue}&lt;/code&gt; - font-color&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;background&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div { background: pink}&lt;/code&gt; - changes the background. You can also use an image as a background using &lt;code class=&quot;language-text&quot;&gt;div {background-image: IMAGE_SRC}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;border&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div {border: 1px solid blue}&lt;/code&gt; - adding borders to an element. &lt;code class=&quot;language-text&quot;&gt;border: 1px solid blue&lt;/code&gt; is a shortcut that means &lt;em&gt;give me a 1px thick blue border&lt;/em&gt;. You can also add border to one side: &lt;code class=&quot;language-text&quot;&gt;div { border-left: 1px solid black}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;margin&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div { margin: 10px}&lt;/code&gt; - add margins to an element. Here we are adding a 10px margin to all side of div’s&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;padding&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div {padding: 10px}&lt;/code&gt; - add paddings between the border of a bloc and its content&lt;/p&gt;
&lt;p&gt;Here is a good visualization of margins and padding&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 286px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/22c5f6d7c0e4cb1dffe173bbf486a8a1/357e3/margin.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 49.69325153374233%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACNklEQVQoz22S/U9SURzG7x/ZnGtrFYgiUaKAwOXNDLiXixAvIqDNXKWCuHhrK9zsvZ9qtRUoOdv6wQJUdGtcmArn6dzLzLR++Ow8O9/vec55zjnM1mGs8fkw3q60ZsVdhMQj8JSpP3TgE/cQlmsdCOdqZ/jEFvj23snUPrMPf3v9kxexJR8yxUnk12xI5YxI5Y29MWdAsmBHMm+TdW/ujBXat7hqwpuPTvwC12KO6a6pjBk6rYPcdk4Tk/EuUSpYorjGEpXSShTXLUQ34ia6m5OyVg1Y5fkeLBlS2Uh/3w0SiOjRgtBkTuhxV/IGXL0yTiLCBhai25gP9RBsG/BayogJX5GgCGwZgrUMnj2lBJ/zG7QankTv3cIRPRxzgKD4KOvA6IiLRL1bmC9UMfd2FwvvdhEu1sDlqgjSMfiM6nwVgac1JNZriL+oI5rfQYT7jnF9iMTum1HtBkWmIRs6MUYNg64KZtI7iL+uI/68htBaDW5q4i/W4aeG7kINAWo++7KOBO2ZefJDNjQZwrLhzw41lCKnaWSV0kKEiTI4ay+KFMlrlSKWMM1VEPVsylqwndZL4NgvEJzb0A7TyHNSZK/ISE++uGpG3yU10Qw7oB48j0ppw9goD73OgwGq/64NDdqhUTtxuV9LglH5UUSmCW/r/eYEHqRMJJk1YjlzgccGLGXtWM5aZf1Pna55mDaTVx+kb8M3mUaXE0XcQRtu0oYHFzmGC/Wun164T9b/6+mtdaHR5cXflyFNZvb3XWkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;margin and padding&quot;
        title=&quot;margin and padding&quot;
        src=&quot;/static/22c5f6d7c0e4cb1dffe173bbf486a8a1/357e3/margin.png&quot;
        srcset=&quot;/static/22c5f6d7c0e4cb1dffe173bbf486a8a1/222b7/margin.png 163w,
/static/22c5f6d7c0e4cb1dffe173bbf486a8a1/357e3/margin.png 286w&quot;
        sizes=&quot;(max-width: 286px) 100vw, 286px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;width&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div { width: 100px}&lt;/code&gt; - determines the width of an element.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;height&lt;/strong&gt; - &lt;code class=&quot;language-text&quot;&gt;div {height: 100px}&lt;/code&gt; - determines the height of an element&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;here are &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;more&lt;/a&gt; commonly used css properties. Again, I don’t expect anyone to memorize these things. It is more of a &lt;em&gt;look-up-when-I-need-it&lt;/em&gt; kind of thing.&lt;/p&gt;
&lt;h3&gt;Flex-box&lt;/h3&gt;
&lt;p&gt;For most of this bootcamp, I will be using flex-box to layout the UI and components.&lt;/p&gt;
&lt;p&gt;Flex-box is simply a way of laying out components on a webpage. here is a really good &lt;a href=&quot;https://css-tricks.com/snippets/css/a-guide-to-flexbox/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;tutorial&lt;/a&gt; on this topic.&lt;/p&gt;
&lt;h3&gt;How to test your CSS sheet?&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In your &lt;code class=&quot;language-text&quot;&gt;WebDevBootcamp&lt;/code&gt; folder, create a new folder called &lt;code class=&quot;language-text&quot;&gt;learn-CSS&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;create two files &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;style.css&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;add the boiler code to the &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt; file&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;90129389970229260000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;&lt;/body&gt;
&lt;/html&gt;`, `90129389970229260000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;in the head of the html file add &lt;code class=&quot;language-text&quot;&gt;&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;style.css&amp;quot;&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You are all done. Now your css in &lt;code class=&quot;language-text&quot;&gt;style.css&lt;/code&gt; will target any element you declared in &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;More Information&lt;/h3&gt;
&lt;p&gt;Here is is another great resource for learning more about CSS: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn/CSS/First_steps&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;MDN CSS Doc&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What’s next&lt;/h3&gt;
&lt;p&gt;Start learning &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;Javascript&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Java ∙ Introduction (Coming Soon!)]]></title><description><![CDATA[Sign up for updates and be notified when new content is being released]]></description><link>https://www.devsurvival.com/java/introduction/</link><guid isPermaLink="false">https://www.devsurvival.com/java/introduction/</guid><pubDate>Fri, 01 May 2020 22:40:02 GMT</pubDate><content:encoded>&lt;p&gt;Sign up for &lt;a href=&quot;/newsletter/&quot;&gt;updates&lt;/a&gt; and be notified when new content is being released&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Web Dev Bootcamp ∙ Learn HTML]]></title><description><![CDATA[What is HTML HTML is a Hyper Text Markup Language that tells the browser how our website is layed out. It describes the structure and the…]]></description><link>https://www.devsurvival.com/web-dev-bootcamp/learn-html/</link><guid isPermaLink="false">https://www.devsurvival.com/web-dev-bootcamp/learn-html/</guid><pubDate>Fri, 01 May 2020 22:40:01 GMT</pubDate><content:encoded>&lt;h3&gt;What is HTML&lt;/h3&gt;
&lt;p&gt;HTML is a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Hyper Text Markup Language&lt;/a&gt; that tells the browser how our website is layed out. It describes the structure and the elements in our webpage. A typical button is represented as&lt;/p&gt;
&lt;h3&gt;Goal&lt;/h3&gt;
&lt;p&gt;Understand the basics of HTML&lt;/p&gt;
&lt;p&gt;This section will not cover everything there is to know about HTML because you don’t need to know everything to be successful.&lt;/p&gt;
&lt;p&gt;It will just cover the basics and just enough to get you started&lt;/p&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;You need a code editor to write your code in. I prefer &lt;a href=&quot;https://code.visualstudio.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;vs code&lt;/a&gt;, but feel free to use any editor you like.&lt;/p&gt;
&lt;p&gt;As a good coding practice, always start your project by creating a project folder. This helps to organize your code. For the purpose of this bootcamp, we are going to have one master folder to store all of our codes, and create nested folders if we feel the need to separate things.&lt;/p&gt;
&lt;p&gt;create a folder named something along the line of “WebDevBootcamp”&lt;/p&gt;
&lt;h4&gt;Mac and Linux:&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;1882631195994721800&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir WebDevBootcamp`, `1882631195994721800`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; WebDevBootcamp&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note: Here I am using a bash command to create the folder. I will go into more depth later about bash commands.&lt;/p&gt;
&lt;h4&gt;Window:&lt;/h4&gt;
&lt;p&gt;just use your file explorer to create the folder.&lt;/p&gt;
&lt;h3&gt;Creating your first HTML file&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;inside of the “WebDevBootcamp” folder, create another folder called “learn-HTML” or anything else you want to call it.&lt;/li&gt;
&lt;li&gt;inside the “learn-HTML” folder, create an HTML file &lt;code class=&quot;language-text&quot;&gt;index.html&lt;/code&gt;. Here “index” is the name of the file and “.html” is the file type&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add boiler plate. A HTML file contains a set of tags. There are two types of tags:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Opening and closing tags: &lt;code class=&quot;language-text&quot;&gt;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Self closing tags: &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img/&amp;gt;&lt;/code&gt;. Self-closing tags do not need an additional closing tag&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;30779740297098510000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;&lt;/body&gt;
&lt;/html&gt;`, `30779740297098510000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&amp;lt;!DOCTYPE html&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt; tag is used to wrap our entire HTML file
inside the HTML file, we have two element &lt;code class=&quot;language-text&quot;&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&lt;/code&gt; The head contains meta data and scripts tags that the browser runs when we load the HTML file. The body contains the content of our HTML page&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;
&lt;p&gt;Lets add a title&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Inside the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt;, add a title =&gt; &lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&amp;gt;Dogs are Great!&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;To view your HTML file, the easiest way is to drag and drop it anywhere inside your google chrome browser.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 311px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/cf7b7f2e1ac25de015b236e3f77d8b61/ffa0f/change-title.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 12.883435582822086%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAgklEQVQI132M2wrCMBBE8/8fpaDWSxVjS32wYJN3SzAJISEkGXWh0Af1wMCyZxg2CAnnHB7jCO89QggUay1FKUXeGIOn1vhQSsHEdOecod8dtliuaGx/qLHeVGjaFl13RX08QUgJfmlw5hzVdof7IH4OppRw63uwuYwxkvjHvP/t9wIGaOXftV/9fwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;change title&quot;
        title=&quot;change title&quot;
        src=&quot;/static/cf7b7f2e1ac25de015b236e3f77d8b61/ffa0f/change-title.png&quot;
        srcset=&quot;/static/cf7b7f2e1ac25de015b236e3f77d8b61/222b7/change-title.png 163w,
/static/cf7b7f2e1ac25de015b236e3f77d8b61/ffa0f/change-title.png 311w&quot;
        sizes=&quot;(max-width: 311px) 100vw, 311px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Congrats! you have officially created your very first HTML file.&lt;/p&gt;
&lt;h3&gt;Elements&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&lt;/code&gt; - contains the content that will appear on the webpage&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt; - storing the title of the webpage&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;h1&amp;gt;&amp;lt;/h1&amp;gt;&lt;/code&gt; - headers are large text usually used for article titles and titles. There is also h2, h3, h4, h5, h6 tags
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 193px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/bad6288840979d02278cd45c07182338/6d2d1/headers.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 195.09202453987731%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAnCAYAAAAPZ2gOAAAACXBIWXMAAAsSAAALEgHS3X78AAAD0ElEQVRIx61W/VMaVxTlP237QzuddtDqKNYoceIHVRxUtAaMaK0pdqI0mpk2GvzIJE0UJzbRCNRYxQZIgnwsLMsuILuc7r6ym13E6WJ5Mzv77p33zjvvnnvvrgENHoZyuQz1Q0aVXRaEj3O1v2pOAKtPkDfLb0F8y0NQ+ZTDVWAEsFgoIJfLgeM4MAxT8xppKoVC8eKSXwIqlUpahseBA5h7euH9bQXWkQkUi0UkEgkk4nFQGVqkVUJb81fY3Q+CSiWRTCYRCoUgbX/90oee3gECxPM8ATW8PTnCJ59+hqlJO1rbTPimuQkW6wjuuefw+Rdfoq+vH+YbHfja2ASj0QjzTTO6evogBSJ8+gbNre0KIGH4JrCP7pu38Hj9Ibq6uzE4NIxH65swtRrRJh7wncUC66AF7aYOLHruY2baiQcPvWRz4GAP7R2dGoEM+TyHdCaDLE2DybHIcyzSadHOZsGyHIqFPGLn52SxdF1aWsfkCAibY0h4Li4+xtFw3XxTK6sRRUoB6f7SIwiqnKz41WkiqHwyiFCVo4aqY1RJDk1sqghdYqjkYex9BIf+APx+P7RLeOz4fBpPJp2Cz7eLYom/EtSw92wDTS0mmLu7YB224f7yMqannLjtcKClpRmj9nGMjdqwuv4EpQIL+9gYKIa7GjC4/wIzc3cxN+vC+PeTcN+dx43OTozYJ8TNo3A4pzB9x4mj0wjOjgOwT9wGT3DKtQHrVZYIUdUQtN2mopyklqyYbJfLQsXPKyD/KYrakNNCkYW/uqtc2Q+zdIYUO8NyijOboZDjCoodjUbA5Qu6QA17vmcwfduBfrFmlzxL+GF2BhbLAG719sPhcOL0bRi/Li/h6c7ev6xV/bEmYDT8N55vb8Pr9WJrcwMejwera4+wtrqKjY0t0GK9Bv2HCEc/6GP4f+q3JqAkhNR1pUcSRJ7Ltlr9hjLUw44AhkN/YWXlgVjLASRTKfzpf43Nx08RjYRFm8K2GF8pfXRfOSh2XZvNhsmJcdxxzcI2bEVv3wDm53/E8UkILpcLxQtePyBZVFkoxw1V7UrvdTUf+hpBuySGLoba5nqZUd2lx2RpvHv3vtJcy6AoiszoTBoZOlv/lQ9e7mJocAiLi/fgXnDDMmTDL2K1BAOHePHHK6Vp6AYsiJ/JtMgqfh5DLHaOeDxBWEp/ECzL1c+wUQmtVVnVZOXPZK1fNd2AjWJHAI8OX8H98wLWvFtYcP+EHbHUnvz+XFT+w/WuzDJZRCIRnJyGcHZ2JgoTIzXNcfnrATZSECWGcs+TS+26gtTdsfWMfwAVi5efY2MbeAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;headers&quot;
        title=&quot;headers&quot;
        src=&quot;/static/bad6288840979d02278cd45c07182338/6d2d1/headers.png&quot;
        srcset=&quot;/static/bad6288840979d02278cd45c07182338/222b7/headers.png 163w,
/static/bad6288840979d02278cd45c07182338/6d2d1/headers.png 193w&quot;
        sizes=&quot;(max-width: 193px) 100vw, 193px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt; - paragraph&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Attributes&lt;/h3&gt;
&lt;p&gt;Attributes are like special properties that you pass to an HTML tag to alter its functionality or how it is displayed&lt;/p&gt;
&lt;p&gt;Ex.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;11586962122651378000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;img src=&amp;quot;cutedog.jpeg&amp;quot; alt=&amp;quot;cute dog&amp;quot; /&gt;`, `11586962122651378000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cutedog.jpeg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cute dog&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 407px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/523c52e3c10c106db741619b4e9a5ef9/0ff56/cutedog.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 86.50306748466258%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAADqklEQVQ4y62UfUzUdRzHf5fHg4ccHAdxHAfc706uO+GAIw4kRR7qeJZEIEizNCZqc2L90YYuS1GU6TxY/dFmGTgFBJLH5R+NubY2Y+JmzZk8FBiIV3OUh7U2Hl795GCtrb+sz/b+57N9X3u9P398hVn3Ix64XMzMzOB2u1lYWODJLC4u8jQj/Oya5vo3g3z37S2mH7j+O/Dflk8LWwJO35/i5tAN7tz5nkfu2SXDubk55ufn/xlpN7ec+ZXM/50VCYH/cZ5AhcmJKa50dtHe3krr5Ra6erroldLX20NPdycDV3vp6+6hrbWVpqYmLjSdp6u9hb6OFr74vIVrfW1c6+/g8azbY1hfX48gCHj7yJCtEkiN30DG85vQaoPRaRVsijVRmBCJUSXHqNNgjTYQ4i0QpRCIUQlkis+Qa1Zwb2x4BViLIBMIUCtQSY8s0SayUvLIWO/AJGoosml5N0vLsdIkJm4OMvf4Tz6rP8pbaTpy1qlYLyrZbAtjcnzUA6w9cXTJMNlqx2QwIfMSCAoKpMRRQUa0kWyDL/lGBYdeyWDy9hB//PqQwf7LVKXq2JUcgsOiJj9Bx9T4mAfY4HQiaiNwpBUQa7YSLZrxUcjQhqiJ02hI1/nwkiGQ+CAZHx3azdfdn1CaLLIxUkmu0Y/N5jWkGZWMjy5Xbmw8Tag6AIPBQHJiKukpmRJURBOqocC+kWy9guIYNQ5zKF91tTFxa4gofznxIV6khPlil6KX7j02uly57uSxpcprVN74qxRoIwIR9eEYxAgSjSI2lYwdjiRm7t6gqfEsjXW1dH54nNy4cOzPyknUq7Gt0/PTxI8eoNN5AplcAgYqWK1chX+QFwHBXqiD/Xn5xUIqS3LYkmXj09PvU1WWx7bCdM43HMduDMWiliOXZBQ+3oyOjHiAp07VLhmG6ZQEh64mUO2LUrJVBflTU13N9YEv6W9t5r2De8l5IY5kycYoVUy3mSjPz2JneTFWy1qGh+8uGzbU4RcgYE1QYo7xI1JUoBf9sDwXwp5KB1daPub+yDC/Sz/SxXPnyM5MJTEujKR4LVvzYqg5kE/V65lM3vvBA7zUXI89VkZxoY7crGAKczVsLdJSsSVKShivlRmo2rmBjuazMPsbrpHbkm0RZQUa3qwQ2VGiZ3tJNK7pCQ9w4OpJavYpcX5g5cjbUbxTZaB6t4Fd5eHsezWKg5U69mzTsHe7hQuNB+i/6OSN0jgq8jUc2R/LmcNWDu+38vAXD/Avqj6CNF0iB0YAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;cute dog&quot;
        title=&quot;cute dog&quot;
        src=&quot;/static/523c52e3c10c106db741619b4e9a5ef9/0ff56/cutedog.png&quot;
        srcset=&quot;/static/523c52e3c10c106db741619b4e9a5ef9/222b7/cutedog.png 163w,
/static/523c52e3c10c106db741619b4e9a5ef9/ff46a/cutedog.png 325w,
/static/523c52e3c10c106db741619b4e9a5ef9/0ff56/cutedog.png 407w&quot;
        sizes=&quot;(max-width: 407px) 100vw, 407px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;here the &lt;code class=&quot;language-text&quot;&gt;src&lt;/code&gt; is the location of the image and &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; is the text that will appear if the image failed to load&lt;/p&gt;
&lt;p&gt;Here are a list of common attributes that&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;disabled - if true, then the element is disabled&lt;/li&gt;
&lt;li&gt;href url to another website&lt;/li&gt;
&lt;li&gt;id id of an element&lt;/li&gt;
&lt;li&gt;src url of image location&lt;/li&gt;
&lt;li&gt;style - styling an element&lt;/li&gt;
&lt;li&gt;title -tooltip when you hover an element&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Styling&lt;/h3&gt;
&lt;p&gt;styling allows you to customize the look of an element&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;30072576049620590000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;body style=&amp;quot;background:red;&amp;quot;&gt;&lt;/body&gt;`, `30072576049620590000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token style-attr language-css&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt; &lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;red&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here we gave the body a style attribute and gave it the style &lt;code class=&quot;language-text&quot;&gt;background:red;&lt;/code&gt; which will make the background red&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 416px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/21df8e2d92d95849c2fe490e1eaedaea/b0122/redbackground.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 140.4907975460123%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAcCAYAAABh2p9gAAAACXBIWXMAAAsSAAALEgHS3X78AAAEO0lEQVRIx62Ve0xbdRzFL+toe2/bW/qmLZSupdAXRVpKgQGyBy8z5DGYKcl4GHUPjRnZXExc2Jga42PxDxP/MHFGTTQ+NpzRbOqcUZfJMoQ5xSxzGjRx6tgCbDDcmB6/t/fyitFYZpPT3+/eX/u55/T8ei8zqmEwSbrJM7hGGqP5DI1XaRwnTfHiujD+FzG9CgZPKhn0cQyeEeak11kG36gZHKZz15MFDqgY9JO+IB3lxPmXpN8Icl4tuk4KCHqbk3Z+Ps0n7y4BFOKdJkfHSR+Sw+/I1ddqETS5lN/wICdGfZd0iDRE4GEJOJWku79H5sWGp/nknc0B36DIH3FiyyfJ3bklFLEI+KNabFMA/UqQy5qlu0sAL0gbeEzSUiCLgO9RVEEfcOJmnrhVhwsL+Z2/NVgC+AkV8TnpNLm7pJkvZMkOhZvDRY0Iu6r5Hxz+TF++IBUyyf+LJNf/tD4lrTGDnPhXE7bMdGJTpyRiX9MsEL9AC89J81mYMDIzenniylfoxCiBR+kCl2kcI/A4Pz9OaFMwkbYsIeF4oRY5rHM4UcIrEJIzuHOFC135YWzIzUa1XYOugBNdPhdWaVkEGAZB0kr6XA3dlVpMMmzxcHjAzeJsWgpuCB0IQN7MYblWDoaadhCwdnULfMEIDJlaREPZ2FSVg40r7di9fSveOtCH9tZ6lHt4FDo5FGarUOPX4IyO7vizQJYi6tM4uDMd0GhksJrMaK1uR120ApVZCnQVaLFtrQ8XhwchvEaGTqFnXQAdhUYCG3GH34JhgwwzagmoN2iR781HZawKBoMeClYGe7oJMacLRaZUVLt41PlM2L/3QZwbOIYXdt+PhqAFLeSsKU9H6xzOUOQ5h+XRIoTzChEOhVESqUCeN0jQ5agIlWBVFo8GrxYues483NWCnwY/Q65egRwqqsSmRLmDQ66RxUly96f0YGNYVQpk9JCy2izIdmchP+BDZoYNMX8QpVYVRTLhned60X/4EPo/PoYnuu9DbcCCYqsCRU4dgk4LvjKk4uZsZHM6BxUvRyqBWWpPZ1LCaFYj7A+htjCI1bc5cPTtl/Fsz0MoK/Di075XsTacAy8BDJwM6bwSA/wy/DEbWW9UgteLSjOw0NExS+U01TbgzZdexPNP7cHmeD3idWVoXhNFVWkBbs93o7Y4hOJIBEa1Cic4MfIVIbLZxsLpUcLjVcFOv4nZSg6NHNY3luH9A6/gl/Pf49LICJ7e24uAx4kMiwohnx3NNRE8/kgH7tlQiSG9bL6UWDgNsSiPijI9SouptTUWrKvOwF2NTnS0+fHorg4cObgfmBjHt6dOYFf3ejTW2BBvyES82Y22ehfO2uS4oZKAOzdb8diOAHZuzcK2e13Y1LkCnfEMtDdZsWWjHW2NOrQ1e3DktX20B4+jp7sFrTVGdN/twZ7tQezozMEPDiWucyLwL6wsJ23mJiY0AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;red background&quot;
        title=&quot;red background&quot;
        src=&quot;/static/21df8e2d92d95849c2fe490e1eaedaea/b0122/redbackground.png&quot;
        srcset=&quot;/static/21df8e2d92d95849c2fe490e1eaedaea/222b7/redbackground.png 163w,
/static/21df8e2d92d95849c2fe490e1eaedaea/ff46a/redbackground.png 325w,
/static/21df8e2d92d95849c2fe490e1eaedaea/b0122/redbackground.png 416w&quot;
        sizes=&quot;(max-width: 416px) 100vw, 416px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Comments&lt;/h3&gt;
&lt;p&gt;comments are little notes to yourself, but do not show up on the webpage&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;69790357122339390000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;!-- Dogs are awesome! --&gt;`, `69790357122339390000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Dogs are awesome! --&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;
&lt;h3&gt;Links&lt;/h3&gt;
&lt;p&gt;use an anchor tag &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt; and provide a &lt;code class=&quot;language-text&quot;&gt;href&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;11569794540801714000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;a href=&amp;quot;http://google.com&amp;quot;&gt;google&lt;/a&gt;`, `11569794540801714000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://google.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;google&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Table&lt;/h3&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;21225019505224794000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;name&lt;/th&gt;
    &lt;th&gt;favorite food&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Bob&lt;/td&gt;
    &lt;td&gt;Donuts&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Sara&lt;/td&gt;
    &lt;td&gt;Ice cream&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;`, `21225019505224794000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;name&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;favorite food&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Bob&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Donuts&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Sara&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Ice cream&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here is what it looks like:&lt;/p&gt;
&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;name&lt;/th&gt;
    &lt;th&gt;favorite food&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Bob&lt;/td&gt;
    &lt;td&gt;Donuts&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Sara&lt;/td&gt;
    &lt;td&gt;Ice cream&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;h3&gt;List&lt;/h3&gt;
&lt;h4&gt;Ordered List&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;39743998082558706000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;ol&gt;
  &lt;li&gt;item 1&lt;/li&gt;
  &lt;li&gt;item 2&lt;/li&gt;
  &lt;li&gt;item 3&lt;/li&gt;
&lt;/ol&gt;`, `39743998082558706000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ol&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 3&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ol&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here is what it looks like:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;item 1&lt;/li&gt;
  &lt;li&gt;item 2&lt;/li&gt;
  &lt;li&gt;item 3&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Unordered list&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;97103557352885880000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;ul&gt;
  &lt;li&gt;item 1&lt;/li&gt;
  &lt;li&gt;item 2&lt;/li&gt;
  &lt;li&gt;item 3&lt;/li&gt;
&lt;/ul&gt;`, `97103557352885880000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;item 3&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here is what it looks like:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;item 1&lt;/li&gt;
  &lt;li&gt;item 2&lt;/li&gt;
  &lt;li&gt;item 3&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Block&lt;/h3&gt;
&lt;p&gt;Blocks are like containers for a group of related elements.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;8985047137554636000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;div&gt;
  &lt;h1&gt;This is a container for my cookie&lt;/h1&gt;
  &lt;p&gt;flavor: chocolate&lt;/p&gt;
&lt;/div&gt;`, `8985047137554636000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;This is a container for my cookie&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;flavor: chocolate&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here is what it looks like:&lt;/p&gt;
&lt;div&gt;
  &lt;h1&gt;This is a container for my cookie&lt;/h1&gt;
  &lt;p&gt;flavor: chocolate&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Classes, id, and names&lt;/h3&gt;
&lt;p&gt;These are typically identifiers that helps add specificity to an element. for instance, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div class=&amp;quot;dog animal&amp;quot;&amp;gt;Woof&amp;lt;/div&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div class=&amp;quot;cat animal&amp;quot;&amp;gt;Meow&amp;lt;/div&amp;gt;&lt;/code&gt; are div. One with class “dog” and the other “cat”, and they both have class “animal”&lt;/p&gt;
&lt;p&gt;Note: you can assign more than one class to an element by separating them with a space&lt;/p&gt;
&lt;p&gt;Having this specificity is useful when you want to target a specific element by its class and style it a specific way without affecting other similar elements&lt;/p&gt;
&lt;p&gt;Ranking by specificity, &lt;code class=&quot;language-text&quot;&gt;id&lt;/code&gt; is the most specific, follow by &lt;code class=&quot;language-text&quot;&gt;class&lt;/code&gt;, and finally &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Form and inputs&lt;/h3&gt;
&lt;p&gt;A form is how to obtain data from the users. A form will typically consists of one or more inputs and a submit button&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;20387388192530700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;form action=&amp;quot;/receive-form&amp;quot; method=&amp;quot;POST&amp;quot;&gt;
  &lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;name&amp;quot; placeholder=&amp;quot;Enter your name&amp;quot; /&gt;
  &lt;label for=&amp;quot;name&amp;quot;&gt;Name:&lt;/label&gt;

  &lt;input type=&amp;quot;email&amp;quot; id=&amp;quot;email&amp;quot; placeholder=&amp;quot;enter your email&amp;quot; /&gt;
  &lt;label for=&amp;quot;email&amp;quot;&gt;Email:&lt;/label&gt;

  &lt;input type=&amp;quot;password&amp;quot; id=&amp;quot;password&amp;quot; placeholder=&amp;quot;enter your password&amp;quot; /&gt;
  &lt;label for=&amp;quot;password&amp;quot;&gt;Password:&lt;/label&gt;

  &lt;button type=&amp;quot;submit&amp;quot;&gt;submit&lt;/button&gt;
&lt;/form&gt;`, `20387388192530700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/receive-form&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;POST&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Enter your name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Name:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;enter your email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Email:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;enter your password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Password:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;submit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;submit&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we have three inputs. a text input for the name, an email input, and a password input. We also have a submit button. When the user clicks &lt;code class=&quot;language-text&quot;&gt;submit&lt;/code&gt; a &lt;code class=&quot;language-text&quot;&gt;POST&lt;/code&gt; request will be sent to the &lt;code class=&quot;language-text&quot;&gt;/receive-form&lt;/code&gt; route on the server&lt;/p&gt;
&lt;h3&gt;More information&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://eastmanreference.com/complete-list-of-html-tags&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;complete list of tags&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;MDN Introduction to HTML&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What’s next&lt;/h3&gt;
&lt;p&gt;Start learning &lt;a href=&quot;/courses/web-dev-bootcamp/&quot;&gt;CSS&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Guide to Showcasing Your Project]]></title><description><![CDATA[You ready to go public ? Here at Devsurvival we provide a free and easy way to showcase your projects to the community. Why you should join…]]></description><link>https://www.devsurvival.com/showcase-learn-more/</link><guid isPermaLink="false">https://www.devsurvival.com/showcase-learn-more/</guid><pubDate>Wed, 29 Apr 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;You ready to go public ?&lt;/h3&gt;
&lt;p&gt;Here at Devsurvival we provide a free and easy way to showcase your projects to the community.&lt;/p&gt;
&lt;h3&gt;Why you should join?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;it is free&lt;/li&gt;
&lt;li&gt;quick and easy to set up&lt;/li&gt;
&lt;li&gt;get feedbacks &lt;/li&gt;
&lt;li&gt;acquire lead&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;/create-showdev/&quot;&gt;Start Now&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[My Love And Hate Relationship With Hackathons]]></title><description><![CDATA[My First Hackathon I was hanging out at one of my favorite developer communities, devto, and I ran into a post written by one of the admins…]]></description><link>https://www.devsurvival.com/my-love-and-hate-relationship-with-hackathons/</link><guid isPermaLink="false">https://www.devsurvival.com/my-love-and-hate-relationship-with-hackathons/</guid><pubDate>Sun, 26 Apr 2020 13:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;My First Hackathon&lt;/h3&gt;
&lt;p&gt;I was hanging out at one of my favorite developer communities, &lt;a href=&quot;https://dev.to/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;devto&lt;/a&gt;, and I ran into a post written by one of the admins at Devto announcing that Twilio was hosting their 2020 hackathon at &lt;a href=&quot;https://dev.to/devteam/announcing-the-twilio-hackathon-on-dev-2lh8&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Devto&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The hackathon is hosted online, so you don’t have to relocate to participate. I happen to be in quarantine during the COVID-19 pandemic, so given my abundance of time and boredom, I joined my first hackathon.&lt;/p&gt;
&lt;h3&gt;What is a hackathon?&lt;/h3&gt;
&lt;p&gt;Feel free to skip this part if you already know what it is or if you want to validate what I am saying is for the most part accurate.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“A hackathon is simply a gathering of developers who share similar interests and are trying to solve some problem in society using current technologies” ~ Hieu Nguyen&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The general gists of it is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;They propose a theme.&lt;/li&gt;
&lt;li&gt;You brainstorm some ideas around that theme by yourself or with other people.&lt;/li&gt;
&lt;li&gt;Once you have an idea, start planning and implementing it.&lt;/li&gt;
&lt;li&gt;Testing and fine tuning your application.&lt;/li&gt;
&lt;li&gt;Show time - there is usually a chance for you to present your project or post it on some forum for others to see&lt;/li&gt;
&lt;li&gt;Receive feedbacks - this is very useful because other developers (some are a lot better than you. Trust me, I learned from personal experience) will look at your application and point of things that you might have missed or complement you on the things they liked.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The goal is not to produce a battle tested application with many features. It is about working together and building something minimally functional to showcase your ideas. Think of it as planting the seed.&lt;/p&gt;
&lt;h3&gt;Theme and Brainstorming&lt;/h3&gt;
&lt;p&gt;For this particular hackathon the themes were:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;COVID-19 Communications&lt;/strong&gt;: an app to help folks communicate during this challenging time, either to stay connected or to help resolve COVID-19 related challenges.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Engaging Engagements&lt;/strong&gt;: an app that a company could implement to better engage with their customers or to manage their business.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Interesting Integrations&lt;/strong&gt;: an app that integrates Twilio with at least one other API.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Exciting X-Factors&lt;/strong&gt;: an innovative or unexpected app that doesn’t necessarily fit any of the above categories, but is a clear winner nonetheless.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://dev.to/devteam/announcing-the-twilio-hackathon-on-dev-2lh8&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;learn more&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; you have to integrate one of the &lt;a href=&quot;https://www.twilio.com/docs/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Twilio API&lt;/a&gt; into your application. Otherwise, it wouldn’t be called the Twilio Hackathon.&lt;/p&gt;
&lt;h4&gt;My approach to comming up with an idea&lt;/h4&gt;
&lt;p&gt;I did not rush head first into the hackathon like many people would. Yes there was a time limit. However, it is entirely up to you to manage your own project, so I waited a good week or so.&lt;/p&gt;
&lt;p&gt;During this time, I was searching for ideas and looking at other people’s submissions to gain some inspiration. The worst thing that can happen is you did something that some else did. To avoid this, do your research and really think outside the box. Some questions you might asks are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What problems am I facing that I can solve using technology?&lt;/li&gt;
&lt;li&gt;Do other people also have this problem?&lt;/li&gt;
&lt;li&gt;Are there existing technologies that fix or alleviate this problem?&lt;/li&gt;
&lt;li&gt;Can the existing solution to this problem be improved and maybe I can make it better?&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;My humble beginnings&lt;/h4&gt;
&lt;p&gt;Since this was my first hackathon, I decided to take the safe route and choose something very simple.&lt;/p&gt;
&lt;p&gt;A lot of people think that at every hackathon, you have to build something complex with a lot of functionalities.&lt;/p&gt;
&lt;p&gt;Yes there will be submissions that are crazy advanced and complicated, but bare in mind that it is &lt;strong&gt;YOUR&lt;/strong&gt; hackathon experience. You are free to go at your own pace.&lt;/p&gt;
&lt;p&gt;So in this spirit, I built an app that lets you sign up for an account with your phone number, set a timer, and once the timer runs out, you get a text message telling you get off your electron device and offers a suggestion for something else you can do.&lt;/p&gt;
&lt;p&gt;I called it: &lt;strong&gt;&lt;a href=&quot;https://dreamy-easley-c0f78a.netlify.app/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Device Police&lt;/a&gt;&lt;/strong&gt;. I know not the greatest idea or name for that matter, but it suited my level of experience and was achievable within the time constraint.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://dev.to/htnguy/twiliohackathon-devicepolice-app-5h06/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;view full submission&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What I love about hackathons&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Own your ideas&lt;/strong&gt; - the nature of a hackthon to challenge your critical thinking and creativity really helps you to think of new ideas.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You are your own boss&lt;/strong&gt; - Unlike a school project or a work project, a hackathon project is for the most part controlled entirely by you.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Besides the theme and several criteria that they imposed, you are not really restricted by any schedule or standards.&lt;/p&gt;
&lt;p&gt;You want to build it the night before the submission deadline? Go at it! The internet is your oyster.&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;&lt;strong&gt;Meeting awesome people&lt;/strong&gt; - Sometimes you get to team up with complete strangers with a completely different set of perspectives and skills.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is really good because whatever skill you lack, that person might be able to compensate, and vice versa.&lt;/p&gt;
&lt;p&gt;Many of these relationships can last a lifetime. They could be your future co-worker at a startup or a friend who considers coding as a conversational topic.&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;&lt;strong&gt;Building presense&lt;/strong&gt; - Think of a hackathon as an audition for programmers. You prepare your act, polish it, show up on audition day, and cross your finger hoping you pass.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Hackathons provide a stage and an audience that may include potential employers.&lt;/p&gt;
&lt;p&gt;Even if you don’t win it, being present and making something cool and useful is enough to turn a couple eyes in your direction.&lt;/p&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;&lt;strong&gt;Free and unlimited membership&lt;/strong&gt; - Most of the time, a hackathon is sponsored by some big company who are willing to spare a small percentage of their fortune to scout potential hires or to establish interests in a certain field.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For you, that means admission is typically free. The only thing you pay is time, passion, and maybe a little dignity.&lt;/p&gt;
&lt;p&gt;You will make mistakes, but don’t let that discourage or prevent you from joining a hackathon. Keep in mind that you are surrounded by people who makes a living by fixing bugs or faults in an application that is how you learn.&lt;/p&gt;
&lt;h3&gt;What I don’t like about Hackathons&lt;/h3&gt;
&lt;p&gt;Note: Some of these do not apply to hackathons hosted online, but they are fair expectations of an in-person hackathon.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Unrealistic time constraint&lt;/strong&gt; - a lot of hackathons tends to span a day or two. This small window translates to sloppy code and bugs. Many projects fall through because they could not accommodate a roadblock or a nasty bug.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Toxic environment&lt;/strong&gt; - If you’ve attended a hackathon in person, then you probably have noticed that they are usually not organized with health and productivity in mind. You are in this crowded space. Lots of talking and cursing(a natural tendency when your codes doesn’t work). When it comes to food offerings, don’t expect a michelin star meal. They often prep pizzas, caffeinated drinks, and other unhealthy food.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too much socializing and not enough coding&lt;/strong&gt; - One of the perks of being at a hackathon is meeting people. However, like they always say: too much of a good things is a bad thing. It can become very distracting when you are trying to complete your project and socialize at the same time.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Should you join a hackathon?&lt;/h3&gt;
&lt;p&gt;If you haven’t been to one before, then I would definitely advise to try it at least once.&lt;/p&gt;
&lt;p&gt;If you have previous experiences with hackathons, then make your best judgement and considered how much value you gained from attending it.&lt;/p&gt;
&lt;p&gt;If it wasn’t good, what could you have done differently? How could the organizers make it better? Would you consider doing an online hackathon?&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How To Earn A Free Ticket To A Computer Science Internship]]></title><description><![CDATA[Who is this post for? If you are a computer science student who’s actively looking for an internship or preparing to do so, definitely keep…]]></description><link>https://www.devsurvival.com/how-to-earn-a-free-ticket-to-a-computer-science-internship/</link><guid isPermaLink="false">https://www.devsurvival.com/how-to-earn-a-free-ticket-to-a-computer-science-internship/</guid><pubDate>Wed, 22 Apr 2020 23:46:37 GMT</pubDate><content:encoded>&lt;h3&gt;Who is this post for?&lt;/h3&gt;
&lt;p&gt;If you are a computer science student who’s actively looking for an internship or preparing to do so, definitely keep reading.&lt;/p&gt;
&lt;p&gt;If you have a genuine interest in computer science and are considering a career as a developer, feel free to keep reading.&lt;/p&gt;
&lt;p&gt;If none of the above applies to you, but your curiosity is killing you, I guess I can’t stop you &lt;span style=&quot;font-size: 30px&quot;&gt;🤷&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Background&lt;/h3&gt;
&lt;p&gt;I have done multiple internships. The first internship was the harder job search of the two, which was expected because I did not have any relevant job experience.&lt;/p&gt;
&lt;p&gt;After doing multiple interviews and hopping around different companies, I have noticed things that were helping me land more interviews and ultimately more job opportunities.&lt;/p&gt;
&lt;p&gt;In this session, I am going to share some tips on how to land your internship and things that I have done to greatly increase the chances.&lt;/p&gt;
&lt;h3&gt;New fish in the sea&lt;/h3&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 640px;&quot;
    &gt;
      &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.87116564417178%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIDAQT/xAAWAQEBAQAAAAAAAAAAAAAAAAAEAgP/2gAMAwEAAhADEAAAAVjnO8jECNP/xAAZEAACAwEAAAAAAAAAAAAAAAABAgAREzH/2gAIAQEAAQUC3saAwtEplbs//8QAFREBAQAAAAAAAAAAAAAAAAAAEGH/2gAIAQMBAT8Bh//EABgRAAIDAAAAAAAAAAAAAAAAAAABERIh/9oACAECAQE/Aap6iD//xAAXEAADAQAAAAAAAAAAAAAAAAAQESEA/9oACAEBAAY/Aq9Q0f/EABoQAQADAAMAAAAAAAAAAAAAAAEAESFBYXH/2gAIAQEAAT8hVp6UxAcvId4Eo0DIKln/2gAMAwEAAgADAAAAEGcv/8QAGBEBAQADAAAAAAAAAAAAAAAAAQARITH/2gAIAQMBAT8QHeXYL//EABcRAQEBAQAAAAAAAAAAAAAAAAEAETH/2gAIAQIBAT8QwcCRf//EAB4QAAICAQUBAAAAAAAAAAAAAAERACExQVFhcaHh/9oACAEBAAE/ELuSNAj2DCwDREUXJ38mZdXZCjMQtUAoYhX9n//Z&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;fish in the sea&quot;
        title=&quot;fish in the sea&quot;
        src=&quot;/static/2fe07b1898addf9494f8b3e8ba5ced79/c08c5/shark.jpg&quot;
        srcset=&quot;/static/2fe07b1898addf9494f8b3e8ba5ced79/d2f63/shark.jpg 163w,
/static/2fe07b1898addf9494f8b3e8ba5ced79/c989d/shark.jpg 325w,
/static/2fe07b1898addf9494f8b3e8ba5ced79/c08c5/shark.jpg 640w&quot;
        sizes=&quot;(max-width: 640px) 100vw, 640px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;credits to
&lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@sense_photo?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from Sense&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;Sense&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Just like a freshman in highschool, you are the small fish in the vast, diverse tech industry. I mean a really small fish, like a sardine compared to shark.&lt;/p&gt;
&lt;p&gt;The shark has years of experience in the sea. It knows how the environments behaves and how to adapt.&lt;/p&gt;
&lt;p&gt;As a newcomer, it can be tough to fit in and dig a room for yourself in this rapidly changing environment. If you started out feeling this way, then we were born in the same school of fish.&lt;/p&gt;
&lt;p&gt;However, we consume, learn, and ultimately grow. With each stage of our growth, we must find a new shell or hole to fit in.&lt;/p&gt;
&lt;p&gt;In this post, I am going to show you how to find your next hole or internship as a small fry in the sea.&lt;/p&gt;
&lt;h3&gt;Cutting to the chase&lt;/h3&gt;
&lt;p&gt;Here is a list of things to follow to guarantee your next internship.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;1. The extra mile&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;There is only so much stuff that a computer science degree can teach you. When most universities are designing their computer science curriculums they are asking: What should I teach that will provide the most fundamental skills and will remain relevant 20 years from now?&lt;/p&gt;
&lt;p&gt;9 times out of 10, a highly demanding programming framework or a trending language does not make the cut. The reason why they are not taught is simply because in the next couple of years, something else will replace it, which means they have to redesign their course.&lt;/p&gt;
&lt;p&gt;For these reasons, I implore you to not wait for your professor to feed you all the technical knowledge you need to succeed.&lt;/p&gt;
&lt;p&gt;Those who are successful are the same ones going the extra mile to obtain the skills needed in the REAL world. &lt;strong&gt;How?&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Start by finding your interests. It could be a coding language or a technology. For instance, I was interested in web development, so I choose to learn HTML, CSS, and Javascript&lt;/li&gt;
&lt;li&gt;Research your topic and gather resources&lt;/li&gt;
&lt;li&gt;Train and Apply - use online tutorials, courses, and documentation as a learning aid. Once you know it enough, start applying it by building something or teaching it to someone else(blog, video tutorial, answering question).&lt;/li&gt;
&lt;li&gt;After you have apply what you’ve learned to build or produce something tangible, you can start leveraging it in your interviews and on your resume.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;&lt;strong&gt;2. Cast a wide net&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;This one is a no-brainer. Don’t apply to just your favorite companies or the ones that shows up in the top 500 fortune companies list. By doing so, you are limiting your own chances of scoring an internship.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;3. Networking&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Having a presence in the tech industry can be pivotal in getting an internship. Many of your connections can help provide a direct line to new job opportunities and a beneficial relationships with potential employers.&lt;/p&gt;
&lt;p&gt;They say it is always easier to ask a favor from someone you know as oppose to a stranger. &lt;strong&gt;How?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;a href=&quot;https://www.linkedin.com/?trk=organization_guest_nav-header-logo&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;LinkedIn&lt;/a&gt; account and reach out to potential employers.&lt;/li&gt;
&lt;li&gt;Join a developer community like &lt;a href=&quot;https://dev.to/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;devto&lt;/a&gt; or &lt;a href=&quot;https://www.reddit.com/r/programming/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;reddit&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Build a profolio website and share it&lt;/li&gt;
&lt;li&gt;Get involved in social events and conferences.&lt;/li&gt;
&lt;li&gt;Join a hackathon - many employers will search for potential hires at a hackathon. Regardless, it is a good experience to have on your resume.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;strong&gt;4. “NEVER GIVE UP”&lt;/strong&gt;&lt;/h2&gt;
&lt;div class=&quot;gatsby-resp-iframe-wrapper&quot; style=&quot;padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; margin-bottom: 1.0725rem&quot; &gt; &lt;iframe src=&quot;https://giphy.com/embed/h99SOT2cABIUE&quot; frameborder=&quot;0&quot; class=&quot;giphy-embed&quot; allowfullscreen style=&quot; position: absolute; top: 0; left: 0; width: 100%; height: 100%; &quot;&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href=&quot;https://giphy.com/gifs/never-give-up-h99SOT2cABIUE&quot;&gt;via GIPHY&lt;/a&gt;&lt;/p&gt; &lt;/div&gt;
&lt;p&gt;Let’s face it. You are going to be turned down once or twice, but don’t let that overshadow how much success is in store for you once you’ve earned a ticket to your internship.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[NCL Exploitation Root Cause Write Up]]></title><description><![CDATA[This was my first time competing in an event like the competition hosted by the National Cyber League (NCL) and I had a lot of fun going…]]></description><link>https://www.devsurvival.com/NCL-Exploitation-Root-Cause-Write-Up/</link><guid isPermaLink="false">https://www.devsurvival.com/NCL-Exploitation-Root-Cause-Write-Up/</guid><pubDate>Mon, 20 Apr 2020 13:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This was my first time competing in an event like the competition hosted by the National Cyber League (NCL) and I had a lot of fun going through each of the categories from Wifi Pentesting, Network Analysis, Exploitation, Web App Security and many more. &lt;/p&gt;
&lt;p&gt;There were many tricky challenges that ranged from Easy to Hard, but the category that I found most interesting is the “Enumeration and Exploitation” category. The challenges in this category involved reverse engineering software/malware or retrieving files from a machine. &lt;/p&gt;
&lt;p&gt;There was a challenge in the Spring 2020 Preseason that I really enjoyed solving called “Root Cause”. During the preseason I noticed that there was around ten players that managed to solve the Root Cause problem in the beginning unlike many of the other challenges where there were many people with a 100% completion in different categories. I saw this as a challenge and began to solve it and become one of the top players.&lt;/p&gt;
&lt;p&gt;You are given the option between downloading either a x32 or x64 binary file to solve the problem. So my first instinct was to open the debugger of my choice and at the time I used Ghidra a tool that was developed by the NSA.&lt;/p&gt;
&lt;p&gt;You can also follow along with binary file to download &lt;a href=&quot;https://ap3x.github.io/Blog/assets/download/root-x64.zip&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once you open Ghidra you want to start a new project and import the binary file into you project.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/54edb60111764269765bd7838d7c255a/2ad15/Screenshot1.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 75.4601226993865%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsSAAALEgHS3X78AAAB20lEQVQ4y62Ta28SQRSG538Wta0YCVEbEj/orzJqbLAX2y57YW/d27A3FmhJCoW08bOQ5fXMgNpqGtrGTZ6cmXfOOTs7+w6rPK1i40kVFWKjshw/26phc7smY/31W+w03uNN4x1q9QZpL7Ep1m9CudUXr7D1vA6mmQE03YJpedBPXTicIy+GyIpzYog0HyDJCIpp90xqy7XbiBqeFGB7yjd8PWoh5F1EJPC0hygu/iC0pCeTb+l/0Un7MJ0Q7NA8wLF5Kht6QYwwyhDTYkyNH4L4EsulhoraRnP/AF/2FRyqFhTThx3lsMMV0RpkXkZH1YVKtezE7aDZDrBrRPhscHwyOvioRQ/mg8bRVF2wq+vv+F9Pf3AONp5cyUlZLrBYPI6yLGWPvBiATabXcjKbzTCfzx/FD6r93dB0AvrlPYzGU1yMLilOMLqc3h+qG1McXkzQsjgZ2w6xe2KjRQY3TA+OH5P3+uQt8mOyjj5CypPQWKUeTDMcHCsGdPJiwHMiW8V1UB55NuzkRFca37DINkIUCUuxdy/ErfDCBG3blw3F1RQ7PtIcsCQ/Q0zCXdzVVH7yjavH6SWWS2fY0un8NAuq7uDXWFmh0tzxOPwopR39i79C7FbsVNFd/AQh5BT7me3f2AAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot1&quot;
        title=&quot;Screenshot1&quot;
        src=&quot;/static/54edb60111764269765bd7838d7c255a/a6d36/Screenshot1.png&quot;
        srcset=&quot;/static/54edb60111764269765bd7838d7c255a/222b7/Screenshot1.png 163w,
/static/54edb60111764269765bd7838d7c255a/ff46a/Screenshot1.png 325w,
/static/54edb60111764269765bd7838d7c255a/a6d36/Screenshot1.png 650w,
/static/54edb60111764269765bd7838d7c255a/2ad15/Screenshot1.png 801w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now that the file is added to the project we want to open the CodeBrowser which is represented as a dragon in the tool chest panel. Then open the project and import file in the CodeBrowser..&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/9e5e8b938af0c18d438058220c735926/29114/Screenshot2.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 55.21472392638037%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsSAAALEgHS3X78AAAB+klEQVQoz4WS628SQRTF+fc1NkbRtIakpfVR9ZOaVmIkwS802qKUNnXpArvsC5aFwrazLxZmj3eGQltt4s2enNndmd/MnXtzD9fyeLD2DI+ebOBxvoCn65vIr28h//wFeQEbhSI2i29Q3Nklfy3HW9u79P4WxZfvsPPqPbbJxTehXFMzoegOlG4PqjmAanlQNBsT30ecxIhiUrTwJJliPudSnGfgWQZ65FiEOxghh3tiPpvR4hQxgT583Mfe/hd8Ln3Fp70SwjCUczIJu5EIp+chp7R0dLo2LMeVsnsDaIZNJ0oQBAFKlSrK1Toq309QPqiDBf8C+RLYJ6Da6qBrWHCcPvruAN7wAqblyDSTJAELY4R02nA6A4sS+W0JvA0W0RPA+1JO03QFxPXkxWp+B/h3yhI4HI7AGJMSKYYkzxsRcHEaxgLElL4QY+EKSMibfZZAl4DlyjdUj47RUNqkDuqnTdQaCgICBmGEkzNV3rFmOGhpFhUlkotlla8lqi7CFkXRTB1Gf4D+mMEZ+XAnAc51C9Ufv3BYO5Z+cFjH0c8GavVTnCkqzqmQaltHq9NFWzNIJnQq5G/6l7vyXSQxu3OHvn+JiNqDz+e0u9BMOue3xaWyjK9STtMpNbbShGHasl1sahuHvEU7Di8m1NxXGE8u/6+xL90bjfEH6PQvgcAcf38AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot2&quot;
        title=&quot;Screenshot2&quot;
        src=&quot;/static/9e5e8b938af0c18d438058220c735926/a6d36/Screenshot2.png&quot;
        srcset=&quot;/static/9e5e8b938af0c18d438058220c735926/222b7/Screenshot2.png 163w,
/static/9e5e8b938af0c18d438058220c735926/ff46a/Screenshot2.png 325w,
/static/9e5e8b938af0c18d438058220c735926/a6d36/Screenshot2.png 650w,
/static/9e5e8b938af0c18d438058220c735926/e548f/Screenshot2.png 975w,
/static/9e5e8b938af0c18d438058220c735926/3c492/Screenshot2.png 1300w,
/static/9e5e8b938af0c18d438058220c735926/29114/Screenshot2.png 1920w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now that we have imported the file we want to analyze it&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 554px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/61abbd2375275293657ede964683d096/04abd/Screenshot3.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 34.355828220858896%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABnUlEQVQozz2PXW/ScBTG++nMMrNNXDbNjNF4p19k8SUMnSQmJm6hE+YyjReazEVdvNhKy0rfoIVCKWCMCpQ7rn+elsnFL+c85/zPOc9f6fVi9vZVtref8vjJMwqFEvmdCvl8mZ1CmZfFfQ6P3nNU+YBaqFDaK6MelCmpc9SDCs9fFOXtLkGrjXJ6+o2l5Zvk1u+wltti9camsLFgZe0Wd+8/5N6DR6yu32Z5ZYPrCzYznc5dW8px+O4YpRcP+HTync9fzvD8Lo4X4jQ6uM2OxDDDtJtYbgvba8ubeW/e/69DGkFE3B+i9PsDiq9LvHrzlrrto+kWes3BMF2qNZua6VE1rExrho1+6VzhcqHXMSSmOj2YLYx6fdneo90dEkY/haHkA1odQWqXXkRNCMKYdueqvmCYxXTOb0s/jFBicViXL51XTbloipumXA2wXV+uBhyfaHz8anAuvR+aLvVA6v4cx8+0IQ5Tt17DR5nNZoxGYy40DcPQaTT+EoYJyXTCeDwhin4xTab8Hv3BH3RJkoTJZLIg1a7rYll2lv8Dk57AzdH4rh4AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot3&quot;
        title=&quot;Screenshot3&quot;
        src=&quot;/static/61abbd2375275293657ede964683d096/04abd/Screenshot3.png&quot;
        srcset=&quot;/static/61abbd2375275293657ede964683d096/222b7/Screenshot3.png 163w,
/static/61abbd2375275293657ede964683d096/ff46a/Screenshot3.png 325w,
/static/61abbd2375275293657ede964683d096/04abd/Screenshot3.png 554w&quot;
        sizes=&quot;(max-width: 554px) 100vw, 554px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the next window we want to make sure we have “Decompile Parameter ID” checked&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/253ba213955d0eca98b3338968c53ffa/97655/Screenshot4.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 50.920245398773%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAACG0lEQVQoz21S227TQBD1P3IRbZIH0lYIUfHCV8AL/1Eh8QCookAlkthxEzu+r531NYmdG6GRWtJIVOgwuymIBx6OZmZ39uzMnFGah89w/2ED+/UD1BtHErXGoYQ4ax4d4+nxCxw+eY692gEe7T+W53u1JvlN6Yvcew/qePnqNZTzrxpOP55D7RrQDQd630bf8v/CtAMCg6YP0NF6sN0QQZjAZzE8ghtw+BQL63ghFHGZFCXG4ykyJ0DOOObZGJfVApeTKRZkXUY5aUE5Y5RlidGokHa1WmG5XGKz+YHZfAkvGEIZxjnSyTfMV1fgcYEkm2C2WGN9tcXN9hfW1z9huBx6bwCLPox4DhYlEhHPENF7wbGrmu8IyzkRrDcokwJ5yFGlI3yvlri93mJzcwvTCaFSywOyHlUrRiB8AcMK4PicWo6JNKaWoxgXfgx7WEDrWmhropIheDYFT2fwkgoGEVju7rHed9Cheau6iQuad8RTVNUcUV7JmSq2z/Ch3cL7dgcnn1SChjefuzg50/C2ZeFdyyRxAlmZwOBOII0Iuz0bIS+QkQZWIO6pZakSDZNR4PsRbMdHQL5Hinkek75PRJY3RI9mqZoBOoYvoQ0YzCCDQR0ZtBGMulUMi5Hs2a6CMJWKCiti9w4+xUGUSeuFmcyXb/7JZ8NcrpLSN11iTmX/Yp+kWn8sJZ+1eviimjAtj3aQyfP/QZAJ1X8DifeiiqtlAekAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot4&quot;
        title=&quot;Screenshot4&quot;
        src=&quot;/static/253ba213955d0eca98b3338968c53ffa/a6d36/Screenshot4.png&quot;
        srcset=&quot;/static/253ba213955d0eca98b3338968c53ffa/222b7/Screenshot4.png 163w,
/static/253ba213955d0eca98b3338968c53ffa/ff46a/Screenshot4.png 325w,
/static/253ba213955d0eca98b3338968c53ffa/a6d36/Screenshot4.png 650w,
/static/253ba213955d0eca98b3338968c53ffa/97655/Screenshot4.png 819w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To jump to the start of the program we can go to the symbol tree window on the left side and under the dropdown of the functions folder we want to click “entry” this is where the C program begins.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 566px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/970de24fb2bbffc380c07fdcc85d3792/6fe44/Screenshot5.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 93.86503067484662%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAAsSAAALEgHS3X78AAAB7ElEQVQ4y6WUW2/TQBBG/f9/AfBS8YQK7xQKpVWDCoW2UZKWXJ3GaXyJ73HaOiXOHsaOckF9IAkjffJqNT76dmd2tP39N7x89YK9vdfsv33H+4OPHHw45PDTEZ+/nHB8UuK0dMbXs3O+nV/w42eZi6sq5coNlVqDm4bOVfma0/PvHEueZg0q9PtVbnt3pOkjeWRZxmw2I1soW1f2TFNRHr/ahgCNMqYu0DsLzwtQiq1j8UtNt9DCwCe4G+L7Gab1G8dRPD6qIk2pzZXHdVeAUZgwdhI8FxoNaDbBdecJed6/HD8DjuKEyAqJIhgMFKapivXc4Q7AKIxJ7Lhw2OmoQrqOFIWly62AcTwqHAYh9C0lxVHYNv935ImfikuFL/cXyP1F8a5AG+1+/MBT/ASebFqrJti0fdaBtWYPLYnHTIIJSgqizKIUc5ja3OHiW2900MbJPWmYMnVkM1HL6rKFwyWwqedVjvCNAEfcZdMVcNMH8wyYjBJG0tiDASTjNYfscOSFw0Ac3naR56d2KspfwLxtEnFoGEqGg2I6nWubd5wrn04FMH1ImcUyGOTIvR602xAG7BT1Rgut2epidE2Zhx6ttku97sraZei6OMNt5HFZbaIdHp1yJdPXtodYtrOStZlMUf6v0TcplXX+AM13t+QTCj/7AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot5&quot;
        title=&quot;Screenshot5&quot;
        src=&quot;/static/970de24fb2bbffc380c07fdcc85d3792/6fe44/Screenshot5.png&quot;
        srcset=&quot;/static/970de24fb2bbffc380c07fdcc85d3792/222b7/Screenshot5.png 163w,
/static/970de24fb2bbffc380c07fdcc85d3792/ff46a/Screenshot5.png 325w,
/static/970de24fb2bbffc380c07fdcc85d3792/6fe44/Screenshot5.png 566w&quot;
        sizes=&quot;(max-width: 566px) 100vw, 566px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the decompile window we can see the entry point and that it calls another function which is our “main”. The decompiler renamed this to &lt;code class=&quot;language-text&quot;&gt;FUN_00400b0b&lt;/code&gt;. If we double click on it we can jump to the main of the C program.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/819ec24e64518e30b760b502e997758e/e9beb/Screenshot6.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 36.19631901840491%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABQUlEQVQoz3WQXStEURSG57ePGRHlI4kLF0QRkdwqBkmE/AGXY8455uN87s+zH2vOhcjYu6fetdp7rfWu1lznkrn2JZ1uj3bnioXFHstLPbrzV8wvXLO0fMPqyi1r63dsbN6zvXXPzs4Du3uP7B88cXj0zPHJC6dnr5xfvNEaRu9Y08cYKDUUCqhqvAvkqkZXXmJHpTy5rrG5pVaW/04rjhPGmSMZW5RKMTqhLCNpkn0/CrN+hr9xCEEmHI4YpTX9yJJlE8ZpzGcxorAKXxtBY10uVHivca5odOUcpaCEwlqM903RVpx8oqogiOUC0okn7pcMhonoPqrMhAlVnor9DD3VkkuNFUxTbKx1U7yx/DEYyGTSpRTLPsdbjxmCSwNWGphUdCkUP5CYesYWppajKBKB2AlizzfJ34uaTXPDb6bnC0sjEHybhRnkAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot6&quot;
        title=&quot;Screenshot6&quot;
        src=&quot;/static/819ec24e64518e30b760b502e997758e/a6d36/Screenshot6.png&quot;
        srcset=&quot;/static/819ec24e64518e30b760b502e997758e/222b7/Screenshot6.png 163w,
/static/819ec24e64518e30b760b502e997758e/ff46a/Screenshot6.png 325w,
/static/819ec24e64518e30b760b502e997758e/a6d36/Screenshot6.png 650w,
/static/819ec24e64518e30b760b502e997758e/e9beb/Screenshot6.png 730w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Once we have stepped into the main of the C program we can see on line 2 there is an int and undefined datatype as the parameters. From experience with C we can assume that this is &lt;code class=&quot;language-text&quot;&gt;int argc, char *argv&lt;/code&gt; and user input is passed to the binary. Also it is important to note the TID that we were given by the NCL competition is only argument that is ran when the binary is executed in the terminal. You can also see proof of that on line 17.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/45bfaed9f042cf7141163d01046c455e/487bb/Screenshot7.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 123.31288343558282%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAZCAYAAAAxFw7TAAAACXBIWXMAAAsSAAALEgHS3X78AAADbklEQVQ4y4VV2XLbRhDk/3+JI7piJXnIg63TknNUXvKulG0KB3Ev9t7F0W6CPsRIolTaqpGA6Z2Z7h6s1q9/x8mrVzhZr7Fev8ZPJ2u8eXOK019/w8+nv+Dt2zO8OzvHu/MLnF1e4fziGheX73F5dYOr61tc33zA+9s/cfPhL9z+8TdWeZqgFf+gEf+ibUfk2YSiitC9h2sdOhFQiYi+c7C1QXAR0zRhHEee6fDw/6uiKGCchbYePljEuHsITOOMeZgZzxh49n9PwIyjP6uqqpBVA+42CnWbE1AwZ5f1LfNhzGiej55VUZYEjLjf1qibDZTa8MHD5Mcg3549WWG+3RJwxOe0RNuliKGHsgI+hoOKsPzOzwIdABoOWlkLRzAOCtM88Ry++KNaPKjyCcAs38K7CrJLoKRGJyOc0yRCIIQWJirIKB/N87lCV3mew5gZxSdDuSgUSmBbF+g6iVrUEEJBZQa29RgjWeck5ulIhWmWshKg6yPiuJ+b60eYZoSVA6wY4cWEICdEXhz1XlLPA6YpqnJGstW4VwWkZ0WDhJk0zKiXeJjiw2kebzlNM/SiQV5mKPqM7XeLC17S23PSWQCVMqjrDYE/ou5ySsYflcYxcM4wxzBoWLuh/SrGkvGIXpq9JoNBR7b70EEEARftkxcczLCXHul2RlkPXBQFGlWj0orgjlY0i061HeB8gGUcgqOsHEKMBxUu1supQ6UN0rTF3d2Aj0mDnkBiCEvSSGK0GyDtTMBI8GHRaWRXPviFnfmgZVboHDhDhUaXaGy9CLxteq4ttsnWpdbodY9O9aglxc6tJIPiKDxsOLToAhjCxLbj99VlxQzD3RjURA1Sh5KxnhEM9aj3u29e7Dk/bjlJUrIs6ZIWG7b9+V4jKTvqkbPrNaTgohjsgQbxfUk8tOLXljM6xbPlbWkgyPIuuSkU2pxtcUu3pYLrWBUdsjuDYtZ4hOWELRu200oLSzL8FDjwwDHQdmTV8PhAMrxdjuXtju9ZXhxo1Z0J/jfDDHk+479PApucpKgKnSURTkC4knGO3nco9BaaRNiRwAPHQTn5wVMJwyFgRmHvLlGsUMtAt0Q0yYD+nh+phsmFgao9+orfG67LQb7UcpLQvyMFPYFypEv4/tdbHzkCx329Z3nRIeURdiDTix+jHyw/7fMv4bORqkW6DZoAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot7&quot;
        title=&quot;Screenshot7&quot;
        src=&quot;/static/45bfaed9f042cf7141163d01046c455e/a6d36/Screenshot7.png&quot;
        srcset=&quot;/static/45bfaed9f042cf7141163d01046c455e/222b7/Screenshot7.png 163w,
/static/45bfaed9f042cf7141163d01046c455e/ff46a/Screenshot7.png 325w,
/static/45bfaed9f042cf7141163d01046c455e/a6d36/Screenshot7.png 650w,
/static/45bfaed9f042cf7141163d01046c455e/487bb/Screenshot7.png 698w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So we can go ahead and rename these by right clicking and changing the variable name and type to its respective value. At this point we can begin to follow the decompiled code and understand what is going on. We can also see that the program requires the user to run a root or a user that has a UID of 0&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73394140033412510000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(` uid = geteuid();
 if (uid != 0) {
   fwrite(&amp;quot;You don\&apos;t have permission to run this program!\n&amp;quot;,1,0x2f,stderr);
                   /* WARNING: Subroutine does not return */
   exit(1);
 }`, `73394140033412510000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt; uid &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;geteuid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;uid &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token function&quot;&gt;fwrite&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;You don\&apos;t have permission to run this program!\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0x2f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
                   &lt;span class=&quot;token comment&quot;&gt;/* WARNING: Subroutine does not return */&lt;/span&gt;
   &lt;span class=&quot;token function&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I went ahead and renamed a few variables to help me follow the program.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 589px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/e355fe7012e752cf3a22f8b43d04b5f7/b1665/Screenshot8.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 143.55828220858896%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAdCAYAAACqhkzFAAAACXBIWXMAAAsSAAALEgHS3X78AAAES0lEQVRIx5VVaW/kRBCdP7taRJZjkUAgEAghEAiE+CerLGhZcYgvfOAPIC0KOTaZ8dnddh8+2t3249nZmGSTQNajmmn32NWv6r2q2ty7/xj37z3C3oN9PHjjMV57fR9vP/we7773BHu839vbx5tvPcbDd+a9H/D+B0/w4Uc/4uNPnuLTz37C51/8jC+/+gVff/Mrvv3uN2yyrIRQA9I0oJQtGtHyvketWrjSwQ8BIcQ720YIiYEvjSNo/IoTxgmYZgu8f8VrI6WEbYhQBCit6dwixo6ntaBPOp5eyTZ1rbArBvx5qHGyK+FcgaZJ4b1dHqDL9eE7IiyRlAOOtxVK8RxVdUin6frAXR2tDoUokcuIIzrMygRdpxi2Qe0U+qFfnV5G+V+HbMqyYA5HVGZA22mGWnObzI5xIefl6+WcrQe8eHaRTdcxb+4EphF0GuAaSsDPxFgMvkIMlFFfI0R/4wFXEOZ5DuM80mOFclfjIM9Q1AbCcr8VUMynbhUKLVFWHbQbmeMeve55ULyE+gIhHc5wVQVo69FRiyEGiMyhOoswlYcuPFw+QqUjZBah8wH21GNob3Ho+4i6Dui94xYdjoFaPFd+jCOGwJzyHjeQ8W8eV4cpynLE4d8Bz8QZnut8yZfsJIzX0LS6r2C94QHhf1knKWSZYhblc6RVSmJKhKG5VRa3sbwiXEgxHkJUaJuMbKcoqoxh+jsJ+RrLWZZzc2QO/4I1O+oxYS4bNN2sy0iROwyUS8vadlw7om9oPgyIY7yCenG42yV8sYUkKm0NRc4K6UqibiAqtq9eoRs6GFaPXc0uexcOL6NdQm7aDgdHEc8OgKPjBju5RWIVTnS1vBhYPW07H0DpaMDaDpX2qPUsfMloLFzrXuSwICm2hZICp1uHbcqXe4qWf0bMvTHwm+HxNzA1w1yS/MSJ6VjC9otuZ5ktCNMsw6yGPA+QdQ3BMpSN5AEGyVYiEQXSXKJSDpLwCiVpCtsiYyU56F6j6g2KrluAbHZJspSQVJHQ2xfJAJgqMH0I7QRvaJY4Ha2ZEJp5zRIIVzJ4HnJKlpvGoKoTkpLDqlMU26co5O9Iyz+IWsOQbUfCBpam7mr42K9OrnXsjM2g7yckiUdCpqU7gzJHDPUYu2zLdY3SSh7G0eCZPc6cyFkzhmlZX3M453C+KjLY9m5Fz8oDJ8ESblOM6ATDZAOJZDnQ5jXCDQ02TRMmPJLdDrlWqDsD1Qu40aBHB8ueWA81XHRcG0jKRA9MQzivc8UOb1jn7dAurFM2LLUCODy0OD5TyMlq5ch23cJYOuILld2xZwpI9sXSloykWyrFszx75nOIw9Kh5jG8lN7IXu898bQtBRxQVwPEKX9P2B/ngZ+x3IoeWvQwNF/xeYY8DTeEnCQpSQlEyeapJnA0s+zYB4kAFwN/PDeMuLR3y1ze7rZ0QjkYqn3qr9bm+ahf7eKzTiRcba7z9Q+Be7kNxEc/5QAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot8&quot;
        title=&quot;Screenshot8&quot;
        src=&quot;/static/e355fe7012e752cf3a22f8b43d04b5f7/b1665/Screenshot8.png&quot;
        srcset=&quot;/static/e355fe7012e752cf3a22f8b43d04b5f7/222b7/Screenshot8.png 163w,
/static/e355fe7012e752cf3a22f8b43d04b5f7/ff46a/Screenshot8.png 325w,
/static/e355fe7012e752cf3a22f8b43d04b5f7/b1665/Screenshot8.png 589w&quot;
        sizes=&quot;(max-width: 589px) 100vw, 589px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We can see that there is a another function previously called FUN_00400906 that we renamed to CalculateFlag that passes an argument of argv[1] which should be the TID value that we passed into the program. Now if we double click on the CalculateFlag function we can just to its decompiled code and right off the bat I noticed that there were variables that had hex values set.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 204px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/df3425f813114b7ae933c6b465eb193c/779ef/Screenshot9.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 101.22699386503066%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAACfElEQVQ4y5VUaW+iUBTt//9Vk5mkbZrWLqIgi1ZRdt4GWCvimfuetGNmUupAyPtAct7Z7r2q6w2EcFGWYzRNjLpeIlz+xMtqDC/yIEqBjGewSgvP+TOm2RSH9gD9HI9H/P1cbbcppJyDc4fAIigVIN48wI99RHmE3XaH6q2CL3zM2AxBGeCwHwDUrDRYUTxju03oi7EObwkwQMEKCCbAJIPLXdyn95ikExzb4zCgEF7PcAOpfGzCG7gkd54soIRCKUs49F8DWqk1LPntLSfJARibkocJVLVAEj/CTwKEeWgky600DD3uwc5tdG33NWBdr4mdTZKfUFUhARLQ6y840cyE0vAGXHITym18i4fo4XuGVbUklr7xUF9wAq/BFIPPfDiFg7mYY3/Yoz206LpuKOXESP7wUKklVYgAVWUAXarUU/4EN3c/0/0K7CyUUw9PgK/EcATBBQpZwGY2RukIWZX9492XDJU69bBpIuheCuniffcO1YcxKSdYizXafTvIrmeYEMOZYajBtZ9asqS6aMkOczDKRqbQ/wHoUm0mveQFnSsoWSOXuWF3l9xhxVeDE3ImOesl22aWdXX0Be+7PUlWmPEZfO6j2TXoDt0lDKPP0dOV0XOdZTcUikQhCryULwiK4CJ2ZwwXhpVm2DQpXTAhyQq84rQUPFiFhUQlABE86ndYcmqqoudZe6hDEcKmHlKxK2a2jAZcsMVlHp5vGy35o9g6Zd3DKYUyLsanpXAZYNLvQ7sfvQ19IYXSmqWgd6Bm6OTOpSmnZo7/pLyik5aEPI2eR1bocvulfxmgZsSYhTwfmUnRXsbxDyM5Exke80dcR9fGw27/fW1+A4uf+1lk1Wy+AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Screenshot9&quot;
        title=&quot;Screenshot9&quot;
        src=&quot;/static/df3425f813114b7ae933c6b465eb193c/779ef/Screenshot9.png&quot;
        srcset=&quot;/static/df3425f813114b7ae933c6b465eb193c/222b7/Screenshot9.png 163w,
/static/df3425f813114b7ae933c6b465eb193c/779ef/Screenshot9.png 204w&quot;
        sizes=&quot;(max-width: 204px) 100vw, 204px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If we convert those hex values to ascii we should get something that starts with &lt;code class=&quot;language-text&quot;&gt;SKY-&lt;/code&gt; which is a piece of a flag since all the NCL flags start with &lt;code class=&quot;language-text&quot;&gt;NCL-&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;SKY-&lt;/code&gt;. We cant assume that this is the flag because the program does something with the TID and those values.&lt;/p&gt;
&lt;p&gt;As we go through the program we notice is that the AUTH linux environment variable is retrieved and saved to a variable in the program and is later used.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;3308322316394995700&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`  __s = getenv(&amp;quot;AUTH&amp;quot;);
   if (__s != (char *)0x0) {
    sVar1 = strlen(__s);
    if (sVar1 == 0xd) {
      local_68 = 0;
      local_70 = 0;
      while( true ) {
        sVar1 = strlen(tid);
        if (sVar1 &lt;= (ulong)(long)local_70) break;
        local_68 = local_68 + tid[local_70];
        local_70 = local_70 + 1;
      }
      local_6c = 0;`, `3308322316394995700`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;  __s &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;AUTH&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__s &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0x0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    sVar1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sVar1 &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0xd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      local_68 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      local_70 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; true &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        sVar1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tid&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sVar1 &lt;span class=&quot;token operator&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ulong&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;local_70&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        local_68 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; local_68 &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; tid&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;local_70&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        local_70 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; local_70 &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      local_6c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I assume this AUTH environment variable is set on the NCL linux server and has a flag stored to check the user input the right flag. We can see that the program checks to make sure the user input flag is 13 (0xd) characters long and begins to take the TID value we passed in and adding the decimal value of each char to local_68 which is later used in the program.&lt;/p&gt;
&lt;p&gt;Unfortunately I don’t have the TID that was given to me, but the value of local_68 turned out to be &lt;code class=&quot;language-text&quot;&gt;2487&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then immediately after we can see that local_6c is set to 0 which which is the &lt;code class=&quot;language-text&quot;&gt;index&lt;/code&gt; of the program.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;15261906449999208000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`        if (index &lt; 4) {
          if ((int)flag_value[index] != local_58[index]) {
            uVar2 = 0;
            goto LAB_00400adf;
          }
        }`, `15261906449999208000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;flag_value&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            uVar2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;goto&lt;/span&gt; LAB_00400adf&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the code begins to come a little more clear. The code above shows that the AUTH environment variable which we assumed as the flag value is compared with the values we found at the beginning of the program as shown below. This values should be equivalent to &lt;code class=&quot;language-text&quot;&gt;SKY-&lt;/code&gt;.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;49938963144455120000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`  local_58[0] = 0x53;
  local_58[1] = 0x4b;
  local_58[2] = 0x59;
  local_58[3] = 0x2d;
  local_48 = 0x50;
  local_44 = 0x51;
  local_40 = 0x4e;
  local_3c = 0x4f;
  local_38 = 0xc;
  local_34 = 0x31;
  local_30 = 0x30;
  local_2c = 0x30;
  local_28 = 0x31;`, `49938963144455120000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;  local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x53&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x4b&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x59&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x2d&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_48 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_44 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x51&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_40 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x4e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_3c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x4f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_38 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0xc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_34 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x31&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_30 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_2c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  local_28 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0x31&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;‘0x50’, ‘0x51’, ‘0x4e’, ‘0x4f’, ‘0xc’, ‘0x31’, ‘0x30’, ‘0x30’, ‘0x31’&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now that we know the flag begins with &lt;code class=&quot;language-text&quot;&gt;SKY-&lt;/code&gt; we can begin to solve the rest. Now that we are looking for the 4 index value of the flag we can follow the code below.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;19198324139147060000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`        else {
          if (index == 8) {
            if (flag_value[8] != flag_value[3]) {
              uVar2 = 0;
              goto LAB_00400adf;
            }
          }
          else {
            if (((long)flag_value[index] ^ tid_value % 10) != (long)local_58[index]) {
              uVar2 = 0;
              goto LAB_00400adf;
            }
          }
        }
        index = index + 1;`, `19198324139147060000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;        &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;flag_value&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; flag_value&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              uVar2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
              &lt;span class=&quot;token keyword&quot;&gt;goto&lt;/span&gt; LAB_00400adf&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;flag_value&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt; tid_value &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;local_58&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              uVar2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
              &lt;span class=&quot;token keyword&quot;&gt;goto&lt;/span&gt; LAB_00400adf&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As we said earlier we can assume that local&lt;em&gt;48, local&lt;/em&gt;44, local&lt;em&gt;40, local&lt;/em&gt;3c, local&lt;em&gt;38, local&lt;/em&gt;34, local&lt;em&gt;30, local&lt;/em&gt;2c, and local&lt;em&gt;28 is the remaining values of the local&lt;/em&gt;58 array which is the obfuscated flag stored in the program. Since we are looking for the 4 index we will start at line 9 and it we can see that the flag value we input has a bitwise XOR to the value 2487 (tid&lt;em&gt;value) and is modulus by 10 and is compared to the local&lt;/em&gt;58 flag character stored in the program. So in order to reverse the value we can use a little bit of python.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;82610293776371000000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`chr(int(&amp;quot;0x50&amp;quot; ,16) ^ 2487 % 10)`, `82610293776371000000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;chr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;0x50&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2487&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output returns a ‘W’&lt;/p&gt;
&lt;p&gt;So we can do this for all of the hex values.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;44553681321762540000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`a = [&apos;0x50&apos;, &apos;0x51&apos;, &apos;0x4e&apos;, &apos;0x4f&apos;, &apos;0xc&apos;, &apos;0x31&apos;, &apos;0x30&apos;, &apos;0x30&apos;, &apos;0x31&apos;]
  for hex in a:
    print chr(int(hex ,16) ^ 2487 % 10),`, `44553681321762540000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;0x50&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x51&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x4e&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x4f&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0xc&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x31&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x30&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x30&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;0x31&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;hex&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;chr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;hex&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2487&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output gives us:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;W V I H 6 7 7 6&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now all we have to do is piece it together and we have the flag.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Just to note for the future. The TID will always be different so this flag wont always be the same.&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[4 Wonderful OS For Computer Science Students. Number 3 is a must.]]></title><description><![CDATA[⏭️ Skip to list  What is an operating system? For the sake of brevity, an OS or operating system is a piece of software that runs your…]]></description><link>https://www.devsurvival.com/4-wonderful-OS-for-computer-science-students/</link><guid isPermaLink="false">https://www.devsurvival.com/4-wonderful-OS-for-computer-science-students/</guid><pubDate>Sun, 19 Apr 2020 23:46:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;#list&quot;&gt;⏭️ Skip to list&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/5c5de30b48990163cde3380260163a6b/6a068/ubuntu.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 56.44171779141104%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAEDBP/EABcBAAMBAAAAAAAAAAAAAAAAAAABAgP/2gAMAwEAAhADEAAAAcqQb0Jiv//EABYQAQEBAAAAAAAAAAAAAAAAAAEAIP/aAAgBAQABBQJjP//EABYRAQEBAAAAAAAAAAAAAAAAAAABEv/aAAgBAwEBPwGVp//EABYRAQEBAAAAAAAAAAAAAAAAAAAREv/aAAgBAgEBPwGMv//EABUQAQEAAAAAAAAAAAAAAAAAACAh/9oACAEBAAY/Aov/xAAbEAACAQUAAAAAAAAAAAAAAAAAAREgITGR0f/aAAgBAQABPyF4fBdlLRNH/9oADAMBAAIAAwAAABB0L//EABcRAAMBAAAAAAAAAAAAAAAAAAABEXH/2gAIAQMBAT8Qco6YP//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/EJH/xAAaEAEBAQADAQAAAAAAAAAAAAABABEhMVGx/9oACAEBAAE/ED4Am9xgfmWPCV1tbW//2Q==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;ubuntu operating system&quot;
        title=&quot;ubuntu operating system&quot;
        src=&quot;/static/5c5de30b48990163cde3380260163a6b/6aca1/ubuntu.jpg&quot;
        srcset=&quot;/static/5c5de30b48990163cde3380260163a6b/d2f63/ubuntu.jpg 163w,
/static/5c5de30b48990163cde3380260163a6b/c989d/ubuntu.jpg 325w,
/static/5c5de30b48990163cde3380260163a6b/6aca1/ubuntu.jpg 650w,
/static/5c5de30b48990163cde3380260163a6b/6a068/ubuntu.jpg 960w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;What is an operating system?&lt;/h2&gt;
&lt;p&gt;For the sake of brevity, an OS or operating system is a piece of software that runs your hardware in a computer. It provides a level of abstraction and offers the convenient user experience that we all know and love.&lt;/p&gt;
&lt;p&gt;The invention of modern day operating system bridged the gaps between humans and computers. Computers existed before operating systems came about. However, using one at that time required a high degree of computer knowledge that most people did not have.&lt;/p&gt;
&lt;h2&gt;How does the choice of operating system affects computer science?&lt;/h2&gt;
&lt;p&gt;As a computer science student myself, I was forced to dig deep into what a computer is and how they work. Contrary to the belief that computer science is just about learning algorithms and coding. There are many layers in a computer&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/1561dbd20b06f875566cb03dd5165469/01dae/computer_layers.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 142.33128834355827%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAcCAYAAABh2p9gAAAACXBIWXMAAAsSAAALEgHS3X78AAAFiElEQVRIx5VVWVCVZRh+jjDdOONN0zgtFzVTM2blMtNMU7m0aJgiJWqYo6KJU+6VnhNHQyq3UPblAHoA2VxxwbHUFBVRHECUTcYdIQViUwE5h59zvrfn5/8puujCi2fe732/93m+dzkLMHL8CEwKmY9Pl8/GlGVB8PsmCP6rgzD9uyDMtBtnPR4YamDGD4aduoLxpQZ07qTFC/DGxNeBeVvs2N0lyHkkyH4oyO0UZDQLfj5NFAg2FQqy2gVxNcQ1QeINI+a8L9jdaXB07p5uQfD2MGBxnBV5fYJDqhcHNC8OixeZbV6s2edF2Akvvs318gEvlqZ6sZYx+1EvliQyp9XI1TmHlBsHvYKvHaHAomgr9rsFB/o0vqKQ85h4pJDerBBfq1iR4e9qUUi+o+C4rbCzQSG7QyGLyO1ULEgvRviQXRe09Tt7n2hYmaEQEitY6RTLsmSxrE4Ty9IksWwvFssqxpaniGVNjli+zxKsSBWs3UObJtjXoyHPQ8GEAUGXIM+tIalOYWu1IKqe86N1cLbx+vxaBRF1hk3oEEQ3CXb2cNZEwi3BQY2C7DKEgpYlMRQUQXqv5pNUqoal7JDhWT/Ki3tWyUu7lxMrDLt31T9n/W541joZ5nCIT1JJPxd5wm70lmclWocmZsuo30ZqH9+CmtoG8e+ABDyBfN5HeAmPeTZtQDdzHkL0XHJk9PER2tCkTEFQih3PBr5gm3QXEijQ/Pso6B4i/uIr468Q5T4yrsxXJlzl+bKvTKz2lfeLfWRCpa/4K1/pz+0zuJPvQZ4Let6OtxJg81cW/VKb2k3BLsh0VjWuEDI2DTIqEfLOsX/9MU7IhFLmUEjPJaefO10sMjoVdoyMtlinudiGx6yQYlMUxE8Hz35s009MeE0oI0fP1SsM8JLrhryZYGGFMayQyR92QfvoHtTkEs6pCDLnAmSujoumHYQvLxg5ei458gG5uga7sePVGFg/qYSEFkLLKoG62Ai5yqVUtkMqWiFV7f9FpYkKLqW4CZJNUTu5ftR4LYGCY4JgO1gBqWfZNxXU+QeQc/chZxogRc2QgnvG+Uw95GgN5PgNyO/X6TNe+CfkOkfSwKUcroK8PY+C67bBxi+X1HCGpR1Qmzn0jamQXzMgsXsh62MhEZmQuP2Q8CTIFi5mAxcVlgBxniBPY+W9LIYth8dS0B4LaxWXco3BahdUCdspewQpYUuljyGXuckKDryawy/nRss6Db+Md1W0tZrJ5XlDEgVDI1kh1fnjpJ1vgypke/n8WBw4B8k7S3sGsl9HAc9nzRhxlDln69h2q8HVKwyLo+CGVFhP3YEcyYVWsA2qNBzSGAlpj4a0mWiNgrQMQitj9RGs8ifOmDY/B5qu8Us6BQNmwFa0GdITCU1SoPpS2AoTm0h8zFk9jId0c3Zuxl3Jhu1i/Alj3h0QYcwVBe0iNQJnUXDjNNgUkzxOaC4KNlIofaGB3BBIxiJIDq0z2EBasBFLmMvq4yhMQS+5wkVGfEbBuLmw6q+6HdB6HVAuB6viBnXhVhJauOXmGMitrZDbRO0myF/0azf2c6Q3yeRS0DGfglGzYfPQkWxoHU6oB2yxiTNs2AK5S3KdCd0fQD3RSlE9t91pcBXbj59DweRgWFv4SnEw5zAW6tJwyKVnIFeG8BtBVAyyA9Dvipmj55IjxQug6RrOryi48F3YCl9hG+AMASXgi0+BHqKF3PMvQ0Leo2A4YNMYVBZoniFQ5RZ+qOnXmCglColy4qZpq4hiopG5blYrOpf+ZlBwF7DWZel/iX8q8JDgySdSiEziiGljiGwictA9H/ToHHbmclMjx4JQpAPrn7bN/wMfDIcVmMkqCk8D+SeBYzr+IE6ZduB80rSD4wP5OvcwUMR/+S/+BqwXpuksopY5AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;computer layers&quot;
        title=&quot;computer layers&quot;
        src=&quot;/static/1561dbd20b06f875566cb03dd5165469/a6d36/computer_layers.png&quot;
        srcset=&quot;/static/1561dbd20b06f875566cb03dd5165469/222b7/computer_layers.png 163w,
/static/1561dbd20b06f875566cb03dd5165469/ff46a/computer_layers.png 325w,
/static/1561dbd20b06f875566cb03dd5165469/a6d36/computer_layers.png 650w,
/static/1561dbd20b06f875566cb03dd5165469/01dae/computer_layers.png 721w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There is the hardware layer(hard drives, CPU, RAM, registers, cache). Then there is the operating system and application layer. Choosing an operating system will affect the entire composition of a computer.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;As a computer science student you are forced to go down these layers and interact with them. Choosing the right operating system for these tasks can make a difference in your learning experience and how successful you will be.&lt;/p&gt;
&lt;h2&gt;Not all operating systems are the same&lt;/h2&gt;
&lt;p&gt;Window is not the same as mac. Mac is not the same as Linux. Linux is not the same as Windows.&lt;/p&gt;
&lt;p&gt;Although they achieve similar goals, how they are implemented is a different story.&lt;/p&gt;
&lt;p&gt;Remember as a computer science student, you are not concerned with using the operating system, because anyone can do that. You are concerned with how it works!&lt;/p&gt;
&lt;div id=&quot;list&quot;&gt;&lt;/div&gt;
&lt;h2&gt;Top 4 OS for computer science students&lt;/h2&gt;
&lt;p&gt;Note: The order is not an indication of one being better than the other.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Window&lt;/strong&gt; - The most popular operating systems, and chances are, you are running it right now.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is good for basic computer tasks like file management and browsing the internet. You can also do programming on window, but some of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Toolchain&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;tool-chains&lt;/a&gt; is not the most forgiving to install or use.&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Mac OS&lt;/strong&gt; - Most developers you see at hackathons or conferences will likely sport a macbook running Mac OS. There are good reasons for that: the hardware is good, it’s reliable, no-headache when setting up new tools or working with existing popular technologies, stunning interface.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, the main benefit for a computer science student is the terminal. Even if you are using an &lt;a href=&quot;https://www.codecademy.com/articles/what-is-an-ide&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;IDE&lt;/a&gt; or integrated development environment, you will find yourself coming back to the terminal from time to time.&lt;/p&gt;
&lt;p&gt;The terminal provides some very powerful features such as file management, installing packages and modules, compiling your code, and executing your code.&lt;/p&gt;
&lt;p&gt;Since Mac OS is based on Unix, the development experience is pretty similar to linux. However, since Mac OS is proprietary, you are prevented from seeing the source code and doing certain things that violate the term of use. Even if it was for learning.&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://ubuntu.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;&lt;strong&gt;Ubuntu&lt;/strong&gt;&lt;/a&gt; - Open source, linux distribution. These two things are the main reason why every computer science students should use Linux.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are many distributions of linux that you can choose from. This flexibility allows you to hop between different linux operating systems while still maintaining the core functionality.&lt;/p&gt;
&lt;p&gt;The fact that it is open sourced means that you can look at the source code and try to learn how it works. you can even change it if you want to! This transparency provides the perfect learning environment for a computer science students.&lt;/p&gt;
&lt;p&gt;The expectation is for you to learn how a computer works, software and hardware. What better way to do that than by using a naked operating system.&lt;/p&gt;
&lt;p&gt;Similar to how you dissect a frog to learn how it functions, you need to dissect an operating system and all its underlying components to learn how a computer functions.&lt;/p&gt;
&lt;p&gt;In addition, you can install ubuntu on virtually any computer!&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;&lt;strong&gt;Chrome OS&lt;/strong&gt; - This one is relatively new to the market, but it is slowly growing into the developer’s community. You can use it to run python and Node, and support for linux features is slowing creeping its way in. Some of the main attractions of Chrome OS is its affordability and simplicity. &lt;a href=&quot;https://www.amazon.com/s?k=chrome+book&amp;#x26;ref=nb_sb_noss_2&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Amazon&lt;/a&gt; sells these chromebooks for less than $500.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Parting advice&lt;/h2&gt;
&lt;p&gt;Whatever you decide on, know the differences between these operating systems and when to use one over the other.&lt;/p&gt;
&lt;p&gt;There will be a point in your education or career where you are not given the choice in which operating system to use.&lt;/p&gt;
&lt;p&gt;For instance, I had to use linux(ubuntu) for my operating systems class or else risks failing the class because the tests used to validate the projects were written specifically for linux.&lt;/p&gt;
&lt;p&gt;So it is in your best interests to dap your feet in the water with what is available out there and don’t be afraid to try new things 😄.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Learn The Truth About Getting a Computer Science Degree In The Next 5 Minutes]]></title><description><![CDATA[credits to
unsplash-logoMatt Ragland What is Computer Science? According to Techopedia ”Computer science is the study of both computer…]]></description><link>https://www.devsurvival.com/learn-the-truth-about-getting-a-computer-science-degree-in-the-next-5-minutes/</link><guid isPermaLink="false">https://www.devsurvival.com/learn-the-truth-about-getting-a-computer-science-degree-in-the-next-5-minutes/</guid><pubDate>Sat, 18 Apr 2020 23:46:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/1a9bf73419b752f9dc6040f1169b0a5f/b9962/college.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 74.84662576687117%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAABAABBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAFAVEiudZL/AP/EABoQAQEAAgMAAAAAAAAAAAAAAAECAAMEERL/2gAIAQEAAQUC8uwOLV5sli6tk7ZFaf/EABgRAAIDAAAAAAAAAAAAAAAAAAECEBEh/9oACAEDAQE/AWNZH//EABcRAQADAAAAAAAAAAAAAAAAAAECEBH/2gAIAQIBAT8BiaV//8QAGxAAAwACAwAAAAAAAAAAAAAAAAERAiEiUXH/2gAIAQEABj8C2PkluDx6IiY5NeFbrP/EABsQAAICAwEAAAAAAAAAAAAAAAERACExQVFh/9oACAEBAAE/ISqJDXTMogozGNbJwnJfZ6rbbhm8ZJn/2gAMAwEAAgADAAAAEIcP/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAEh/9oACAEDAQE/EK2a/8QAFxEAAwEAAAAAAAAAAAAAAAAAAAERIf/aAAgBAgEBPxBVkYf/xAAcEAEAAwACAwAAAAAAAAAAAAABABEhQYExYXH/2gAIAQEAAT8QUiYvXYepvGZIfDnIkr7gwZX/AKUcg5I24m9B2+x4WlFrP//Z&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;College&quot;
        title=&quot;College&quot;
        src=&quot;/static/1a9bf73419b752f9dc6040f1169b0a5f/6aca1/college.jpg&quot;
        srcset=&quot;/static/1a9bf73419b752f9dc6040f1169b0a5f/d2f63/college.jpg 163w,
/static/1a9bf73419b752f9dc6040f1169b0a5f/c989d/college.jpg 325w,
/static/1a9bf73419b752f9dc6040f1169b0a5f/6aca1/college.jpg 650w,
/static/1a9bf73419b752f9dc6040f1169b0a5f/7c09c/college.jpg 975w,
/static/1a9bf73419b752f9dc6040f1169b0a5f/01ab0/college.jpg 1300w,
/static/1a9bf73419b752f9dc6040f1169b0a5f/b9962/college.jpg 1334w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;credits to
&lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@mattragland?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from Matt Ragland&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;Matt Ragland&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;What is Computer Science?&lt;/h3&gt;
&lt;p&gt;According to &lt;a href=&quot;https://www.techopedia.com/definition/592/computer-science&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Techopedia&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;”&lt;/strong&gt;Computer science is the study of both computer hardware and software design. It encompasses both the study of theoretical algorithms and the practical problems involved in implementing them through computer hardware and software.&lt;strong&gt;”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br/&gt;
&lt;p&gt;&lt;a href=&quot;https://www.dictionary.com/browse/computer-science&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Dictionary.com&lt;/a&gt; defines computer science as&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;”&lt;/strong&gt;the science that deals with the theory and methods of processing information in digital computers, the design of computer hardware and software, and the applications of computers.&lt;strong&gt;”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;br/&gt;
&lt;p&gt;These definitions can be a mouthful sometime and the meaning can sometimes get lost in the jargon, so let’s pick out some keywords.&lt;/p&gt;
&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Software&lt;/strong&gt; - There are many forms that is &lt;em&gt;thing&lt;/em&gt; exists in. It could be an app on your phone, your desktop programs like a pdf reader, or a website.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At the end of the day, they are just lines of text. What makes these lines of text different than a regular piece of text is that the computer views them as &lt;strong&gt;commands&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;When you type &lt;code class=&quot;language-text&quot;&gt;print &amp;quot;hello world&amp;quot;&lt;/code&gt;. To a normal human being, it is the equivalent of writing &lt;code class=&quot;language-text&quot;&gt;I love chicken nugget&lt;/code&gt;. However, to the computer, these words are quite different.&lt;/p&gt;
&lt;p&gt;The computer thinks: “ooh ooh, I just received a command to do something. Let’s see what it is…Yes I can definitely print ‘hello world’ for you. No problem …printing…printing…Here you go. I am done printing your message :)”&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Theory&lt;/strong&gt; - The logical reasoning and analysis of how a computer and software function using models and mathematics.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Computer&lt;/strong&gt; - a software can be run on any hardware that is able to store and process data. It could be your smart washing machine, but the majority of the software are designed to be run on a computer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hardware&lt;/strong&gt; - There is a misconception out there that software and data exists in a realm outside our physical world like &lt;em&gt;magic&lt;/em&gt; 🌈.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, as any computer scientists will tell you, that is far from the truth.&lt;/p&gt;
&lt;p&gt;Data must be stored on a physical hard drive. There are electrical components and moving parts that helps to read and write data to your hard drive. &lt;/p&gt;
&lt;p&gt;In order to run your command, you need a central processing unit or CPU. CPU is a hardware that exists in your computer. Its job is to process information and do whatever it is you tell it to.&lt;/p&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;&lt;strong&gt;Algorithm&lt;/strong&gt; - So we have a command that &lt;code class=&quot;language-text&quot;&gt;prints &amp;quot;Hello World&amp;quot;&lt;/code&gt;, but now we want it to take in some input like a &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt; and give us an output like &lt;code class=&quot;language-text&quot;&gt;print &amp;quot;Hieu&amp;quot;&lt;/code&gt;. This can be achieved using an algorithm. An algorithm is like a black box that you can pour some inputs into, and then get something back from it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Why Do People Get A Computer Science Degree?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Money&lt;/strong&gt; - Average salary for a software developer in the United States is &lt;a href=&quot;https://www.glassdoor.com/Salaries/us-software-developer-salary-SRCH_IL.0,2_IN1_KO3,21.htm&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;$76,525&lt;/a&gt;. This value can changed depending on where you live and the level of experience with the highest pay ranging from &lt;a href=&quot;https://www.zdnet.com/article/these-are-the-highest-paying-companies-for-software-engineers-across-the-us/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;100k - 350k&lt;/a&gt;. Despite the high pay, most of these people would keep do their job and love doing it for even a fraction of their current salary.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;They Love Doing It&lt;/strong&gt; - many programers consider their work as artistic. In fact, programming or coding requires a high degree of creativity and critical thinking. It is similar to the high that other artists experience. They just want to keep doing again and again.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;They Want To Change The World&lt;/strong&gt;- Many programmers dreams of one day developing something that will revolutionize the world. They draw their inspiration from the likes of Mark Zurkerberg who developed Facebook.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Do I need a Degree To Be A Software Developer?&lt;/h3&gt;
&lt;p&gt;Absolutely Not. &lt;/p&gt;
&lt;p&gt;In the age of the internet, there is really no limit to what you can learn online.&lt;/p&gt;
&lt;p&gt;For instance, I wanted to build a blog a couple of weeks ago, but I did not have the technical knowledge to do so. My computer science program wasn’t going to help. I was too busy doing calculus and solving algorithms problem. However, I wasn’t going to give up there. I researched online on how to learn web development and starting a blog. Within a couple months, my &lt;a href=&quot;/&quot;&gt;blog&lt;/a&gt; was up and running.&lt;/p&gt;
&lt;h3&gt;Self-taught to a Career&lt;/h3&gt;
&lt;p&gt;Once you are feeling confident, you can start looking for work. Since you don’t have a degree, the only thing that is going to back you up is &lt;strong&gt;experience&lt;/strong&gt;, &lt;strong&gt;experience&lt;/strong&gt;, and &lt;strong&gt;more experience&lt;/strong&gt;. There are many ways to accumulate experience:&lt;/p&gt;
&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;Build and publish a successful app.&lt;/li&gt;
&lt;li&gt;Join a &lt;a href=&quot;https://www.switchup.org/rankings/best-coding-bootcamps&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;coding bootcamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Network with other developers&lt;/li&gt;
&lt;li&gt;Freelancing&lt;/li&gt;
&lt;li&gt;Contribute to &lt;a href=&quot;https://www.freecodecamp.org/news/the-definitive-guide-to-contributing-to-open-source-900d5f9f2282/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;open source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Blogging - teaching what you have learned to someone else. If done correctly, this approach can mark you as an authoritative figure in your niche. Note: patience is required for this route as you have to start building your creditability and fan base.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Is It That Simple?&lt;/h3&gt;
&lt;p&gt;There are several reasons why you should still want a computer science degree.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Direct Access to Job Market&lt;/strong&gt; after graduation as many companies are looking to hire new graduates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Understanding The Fundamentals&lt;/strong&gt; - Many computer science skills, such as data structure and operating systems, are just not taught at the same level in a self-taught environment compared to a college class.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Networking&lt;/strong&gt; - You are surrounded by professors, experts, and other students who all shared the same interests, so being able to find a connection in your field is trivial.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internship&lt;/strong&gt; - Many universities will offer opportunities to complete internships for class credit. Doing an internship provides you with some real world perspectives and skills that are likely not taught in school. Plus, you get the 💰💰💰&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;College Experience&lt;/strong&gt; - Just do it so you can say you’ve done it philosophy.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[3 Things I've Learned From Doing Nails Professionally as a 16 Years Old]]></title><description><![CDATA[Credits to
unsplash-logoLazar Gugleta Wait… What?!?!? Yes, you heard that right. I started doing nails when I was 16. How does a computer…]]></description><link>https://www.devsurvival.com/3-things-i-have-learned-from-doing-nails-professionally-as-a-16-years-old/</link><guid isPermaLink="false">https://www.devsurvival.com/3-things-i-have-learned-from-doing-nails-professionally-as-a-16-years-old/</guid><pubDate>Fri, 17 Apr 2020 23:46:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/662729906c39311ed60ba98507b93dc8/9c9b2/nails.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 142.94478527607362%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAdABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAQCAwX/xAAWAQEBAQAAAAAAAAAAAAAAAAADAgH/2gAMAwEAAhADEAAAAbHKoZTQsIDmVopE8ADv/8QAHhAAAQMEAwAAAAAAAAAAAAAAAQACAwQQERIhIiP/2gAIAQEAAQUCiF9SGCbnDjaYYW8rU44VQOkI8v/EABgRAAMBAQAAAAAAAAAAAAAAAAABEQIh/9oACAEDAQE/AWqqVmH2ER//xAAZEQACAwEAAAAAAAAAAAAAAAAAAQIQIRL/2gAIAQIBAT8BWZU0dM//xAAbEAABBQEBAAAAAAAAAAAAAAAAAQIQETEhgf/aAAgBAQAGPwLNm04U85k01UqPBD//xAAbEAADAQEBAQEAAAAAAAAAAAAAARExIUGRsf/aAAgBAQABPyHr2vwYo/Cpayi2tJcUeMqbWsRY8ImQJkmVDk56ScfFP//aAAwDAQACAAMAAAAQkxEN/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQARUf/aAAgBAwEBPxBEFzLNQc1L/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQARIf/aAAgBAgEBPxBDJhchk3Bv/8QAHxABAQACAQQDAAAAAAAAAAAAAREAITFBUWGhscHR/9oACAEBAAE/EHIAb0d7ZEtApfHRwEAjgltY6a+sIR4Pl7P7kBkUrxlBCzE8YIqadez4cDk6OrOmzGHCg9OBD2OAVVWu0uf/2Q==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;nails&quot;
        title=&quot;nails&quot;
        src=&quot;/static/662729906c39311ed60ba98507b93dc8/6aca1/nails.jpg&quot;
        srcset=&quot;/static/662729906c39311ed60ba98507b93dc8/d2f63/nails.jpg 163w,
/static/662729906c39311ed60ba98507b93dc8/c989d/nails.jpg 325w,
/static/662729906c39311ed60ba98507b93dc8/6aca1/nails.jpg 650w,
/static/662729906c39311ed60ba98507b93dc8/7c09c/nails.jpg 975w,
/static/662729906c39311ed60ba98507b93dc8/01ab0/nails.jpg 1300w,
/static/662729906c39311ed60ba98507b93dc8/9c9b2/nails.jpg 2268w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Credits to
&lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@lazargugleta?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from Lazar Gugleta&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;Lazar Gugleta&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Wait… What?!?!?&lt;/h3&gt;
&lt;p&gt;Yes, you heard that right. I started doing nails when I was 16.&lt;/p&gt;
&lt;p&gt;How does a computer science students and developer begin his career by doing nails?&lt;/p&gt;
&lt;p&gt;I wonder that question myself sometimes. Well to understand this story you have to go back in history and understand where it all started.&lt;/p&gt;
&lt;h3&gt;History Lesson&lt;/h3&gt;
&lt;p&gt;&lt;small&gt;Feel free to skip this section, but I recommend briefing over it as it will set the stage for the rest of the post&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;During the vietnamese war, many families were dislocated due to the violence and war boundaries.&lt;/p&gt;
&lt;p&gt;The communist North vs the American backed South.&lt;/p&gt;
&lt;p&gt;My family was situated in the south at that time. My grandfather fought in the war and befriended many American soldiers. He would often share stories about how beautiful and developed Vietnam was before all the violence.&lt;/p&gt;
&lt;p&gt;We had cars! I did not believe it when they told me that vietnamese were driving cars in the 60s and 70s.&lt;/p&gt;
&lt;p&gt;The economy was growing and international trade was at its peak. My aunt even told us that she once had a french teacher. Can you imagine a vietnamese girl in the 60s or 70s taking french lessons. That idea seems farfetched now, but prior to the war, things were different.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;For those who follow history, then we all know that the north eventually invaded the south, and story short, Vietnam became a communist country. However, there was still a glimpse of freedom for those who were willing to risk everything.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;My family were some of the brave souls that abandoned the country they loved in search of freedom beyond the waters.&lt;/p&gt;
&lt;p&gt;They scattered onto wooden boats that were not meant for the treacherous conditions of the sea. They brought nothing with them besides the clothe they had on and the hope of freedom.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Most of my families arrived in America. Some where in Germany, Madagascar, and other neighboring countries that were willing to take in vietnamese refugees.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Once they got here, they needed to work and start over. Many went straight into factories.&lt;/p&gt;
&lt;p&gt;My aunt had other ideas. She wanted to try her hand at doing nails. She was old at the time and many nail salons rejected her application because of it.&lt;/p&gt;
&lt;p&gt;However, her persistence eventually earned her enough money to start her own business. Her business grew and she was able to open more shops.&lt;/p&gt;
&lt;p&gt;Despite, all of her successes, she never forgot where she came from and what matters most in here life: her family. She was able to petition for her other siblings to come to America,&lt;/p&gt;
&lt;p&gt;and guess what they did for work? Nails.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Soon it became standard for any person in the family to start out working in one of the family’s nail salon. Naturally, I was cultivated at an early age to start working in the nails salon.&lt;/p&gt;
&lt;h3&gt;My Initial Reaction&lt;/h3&gt;
&lt;p&gt;I despised it with every inch of my soul, but I manage to tolerate it and gained some very valuable life lessons along the way that I don’t think could have been obtained from doing anything else.&lt;/p&gt;
&lt;h3&gt;3 Things I’ve Learned From Doing Nails Professionally As a 16 Years Old&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;1. The value of money&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At a young age I learned that money or any other thing that holds monetary value must be earned with hard work. The shortcuts of acquiring wealth is either illegal or only work in the short term.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Time is a commodity&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I often worked at the nails salon right after school, which did not leave me with a lot of time to do other things. To compensate, I would always complete as much school work at school as I can.&lt;/p&gt;
&lt;p&gt;Instead of hanging out with friends or doing other things that typical teenagers do, I worked. I had earned a decent income which at the time, surpassed my imagination of what I could buy with it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Appreciate the little things&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You may have been wondering by now why I was working so hard in the first place?&lt;/p&gt;
&lt;p&gt;Why not just quit? The reality was that I couldn’t.&lt;/p&gt;
&lt;p&gt;I was going through some rough time as a teenager and my parents could not make the sacrifices needed to raise me.&lt;/p&gt;
&lt;p&gt;Instead of feeling pity for myself, I picked up a job in my family’s business and started working.&lt;/p&gt;
&lt;p&gt;Working gave me a new outlook on life. It taught me the preciousness of having a supportive family. I finally understood what my parents were saying when they told me: “We work hard so you can have a happy life.”&lt;/p&gt;
&lt;p&gt;During this time, happiness and joy was scarce in my life, so I appreciated every ounce of happiness that I could find. It could be a smile from a stranger or a complement from a school teacher. It all adds up.&lt;/p&gt;
&lt;h3&gt;What are your thoughts?&lt;/h3&gt;</content:encoded></item><item><title><![CDATA[Mac - Changing Font Size Without Lowering Display Resolution]]></title><description><![CDATA[Many other guides on this topic solve this problem by changing your display scaling. Although this methods works and is fairly simple, it…]]></description><link>https://www.devsurvival.com/mac-increase-font-size-without-lowering-resolution/</link><guid isPermaLink="false">https://www.devsurvival.com/mac-increase-font-size-without-lowering-resolution/</guid><pubDate>Thu, 16 Apr 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;Many other guides on this topic solve this problem by changing your display &lt;a href=&quot;/setting-native-resolution-on-mac/&quot;&gt;scaling&lt;/a&gt;. Although this methods works and is fairly simple, it does result in a minor degradation of visual quality or display resolution.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;This tutorial is a little bit different. I am going to show you how easy it is to change your system font without the side effects of lowering your resolution. Let’s get started.&lt;/p&gt;
&lt;h3&gt;Who is this guide for?&lt;/h3&gt;
&lt;p&gt;If you are a person who likes to take your gadgets and experiment with them, then this guide is for you. If you are just trying to quickly change the font size or the scaling of your mac’s appearance without downloading extra software, then I recommend using the provided &lt;a href=&quot;/setting-native-resolution-on-mac/&quot;&gt;display settings&lt;/a&gt; provided by Apple in your mac’s preferences.&lt;/p&gt;
&lt;h3&gt;Step 1&lt;/h3&gt;
&lt;p&gt;Download &lt;a href=&quot;https://www.bresink.com/osx/TinkerTool.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;TinkerTool&lt;/a&gt;. This tools allows you to tweak certain things in your mac that are usually not exposed to the common user. Don’t worry it is legal 😉.&lt;/p&gt;
&lt;h3&gt;Step 2&lt;/h3&gt;
&lt;p&gt;Open the Tinkertool dmg file and open the TinkerTool app. There will be a couple pop-ups, just click continue on those.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/0377c71e68c413870c54cf74e60c7572/0d0e4/tinkerToolDMG.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 61.34969325153374%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAABYlAAAWJQFJUiTwAAAB2ElEQVQoz41SS2/TQBj0f+G3ICHOAa6cqTgUTkhwR1yQUCUkoEWtOHEEcSgSp6RSOFBFOBaE2ImT+G3X9Wtt52EP/rbYagiNGGm89vrb2flmV5BlGSyfQ/r5A6qmI0pzpGmKLMv+yTzPN+aofrlcQlEUCJbt4EvnBLfv3MKjJ4/x+eQr/kZZls1YFMUGa+i6DsFxXbzY28PNG9ex++AhXr7e5z9px8lkgvF4jOl0ClVVOS3LQhAE8H2fk95r0dlsBsEwDLw5OECr1cK9nR3svz3kToimafJdiVRMYxRFvM0kSdbaJWiaBoEKHduG2O9DFEWolaPaITkajUZcmNyEYchpV/VkhOY8z+O5NoL0ICwWi2anOi/GGOLKyXw+xzbUGXNByomsx3GMLM3AEobVavWnkLIpmkVXsc6QC9JRd7td9Ho9yLLCJykXQpovMDAZUpZuFV0TpIza7TYkScJwKPOTTSqnhPdShGvPuvj4Teffq6Js2ruMDYedTgeDX8MqbLcK20RSZUc4VTzcPTyFqEUXC8v/EByPZPS/9+CaU8TnLmzLQJ5dtBgFPpIzBxmLudjlA7hS8NWnAZ4fh7h/ZGD3nYGnHxwci+SwhH8ewDujyxuuZbhN8DejlYQacR7d8QAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;TinkerTool dmg&quot;
        title=&quot;TinkerTool dmg&quot;
        src=&quot;/static/0377c71e68c413870c54cf74e60c7572/a6d36/tinkerToolDMG.png&quot;
        srcset=&quot;/static/0377c71e68c413870c54cf74e60c7572/222b7/tinkerToolDMG.png 163w,
/static/0377c71e68c413870c54cf74e60c7572/ff46a/tinkerToolDMG.png 325w,
/static/0377c71e68c413870c54cf74e60c7572/a6d36/tinkerToolDMG.png 650w,
/static/0377c71e68c413870c54cf74e60c7572/e548f/tinkerToolDMG.png 975w,
/static/0377c71e68c413870c54cf74e60c7572/0d0e4/tinkerToolDMG.png 1230w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Step 3&lt;/h3&gt;
&lt;p&gt;Navigate to the “font” panel. Once you are there, you can change any of the available font options according to your needs. There is no need to save your changes once you are done, just restart any application and you will see the update, and that is it. You can always go back and fine tune it to suit your preference.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/878c56451fee76d1b0afcf6bd8d65693/ae28e/tinkerToolPreview.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 59.50920245398773%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAABYlAAAWJQFJUiTwAAACD0lEQVQoz31Tu27UQBT1V6SmZ5e1x++xZ+z4ubsJxPFmYylRhFgeSUBKCgQFhIYSIiTED6QBWqDgA6gRRX7oMHfAYhEbiuM7M77n3NeMcXR8hLIuMJluYKttsbm3wHT/EarJJookwmw2w1bTopw0KPIMG+MKyc0OB3ceoLm1CyEyJIlUSCClhFHsLCBkijzPUSrR8e4e6p1DlNUU44yj2d5Gup6DeRJxFCFLJcJxi/nBPUwnLRw3hOs6Ci48z4Ph2RbiONbOQlnBQ8jIQyIjSB05xroSSROhMyBfGXFEYaDWHKGyYRhqOI4DI44F6rpGVVWIlKPrx7BsCeYIBbIJbDdByCNwFYxzDuKQMInYtq2FyDLGYNCCUiUxi3m43TG8fGLj+QnD2cl1jafHA0zqRPe5LAr4vg/LsmCaprbLMPofUsYIeIbzFy4uvzJ8/zzEj0/XcPllDd/er2G/y7G4e6iG1Gp/ymYVDPqQaOB78IIcr54N8fqMYXCDw7SYIv/CKjLxVgpSxCBwVf9KfHg7wMd3thZk1kiR2G/8XdqVgnRITY1pciLH6X0Xjx+qgdihIvSlWf9ktiw6Go00KDGDBpJlmZq0anZY4eJ8iIs3DEMzUgTzv+WRAPFb9SC6rkNZln+G0kehrPqzHleVSHsSbJoG8/kchboBRhAESNNUX9oeQgj9lPpzulqrxJbL7/ETwT+eZkHaB5IAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;tinkertool font panel&quot;
        title=&quot;tinkertool font panel&quot;
        src=&quot;/static/878c56451fee76d1b0afcf6bd8d65693/a6d36/tinkerToolPreview.png&quot;
        srcset=&quot;/static/878c56451fee76d1b0afcf6bd8d65693/222b7/tinkerToolPreview.png 163w,
/static/878c56451fee76d1b0afcf6bd8d65693/ff46a/tinkerToolPreview.png 325w,
/static/878c56451fee76d1b0afcf6bd8d65693/a6d36/tinkerToolPreview.png 650w,
/static/878c56451fee76d1b0afcf6bd8d65693/e548f/tinkerToolPreview.png 975w,
/static/878c56451fee76d1b0afcf6bd8d65693/3c492/tinkerToolPreview.png 1300w,
/static/878c56451fee76d1b0afcf6bd8d65693/ae28e/tinkerToolPreview.png 1598w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;How do I reset everything and pretend this never happened?&lt;/h3&gt;
&lt;p&gt;Simple. Navigate to the &lt;em&gt;reset&lt;/em&gt; panel and click “reset to pre-tinkertool state”.&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/aa622b4bbfe0d3c4c08bfc954f047cf0/ae28e/resetTinker.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 27.607361963190186%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAABYlAAAWJQFJUiTwAAABHElEQVQY022Py26DMBBF/T1VogQMNg8DLWACCRjUEpBolUUqVVUWzf+vbh2nRCy6OLp+zBzNENVWyHKJruvQDB84TF/YD5/IEoFdnqFtW8iiQlo0SJIY+3KHpOrQTWec3k/IpUIcx/ovMUkyXfySpmiVwkEXqNMF5XhFLQXqMkfTNAjCGFzs8KyFdZFC7N/wev7B5fuK6jCCcwbP8wwkDILHxdcfPnfhMwo/FPrNB2MMga4JfI7tdquxQK0NNqsnrNcruC6FZVkPCOfcNN3yjmdgzNXrKkzThOPxiGEYTZZlacQ2pbBt20huOUOW9iW3Jikl+r7XsgHjOJpzURR34UKylJIoiiCEQBiGZrU55wKqJ3Ecx0D/pvpvsplfvMbPGJQbWsgAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;reset tinkertool&quot;
        title=&quot;reset tinkertool&quot;
        src=&quot;/static/aa622b4bbfe0d3c4c08bfc954f047cf0/a6d36/resetTinker.png&quot;
        srcset=&quot;/static/aa622b4bbfe0d3c4c08bfc954f047cf0/222b7/resetTinker.png 163w,
/static/aa622b4bbfe0d3c4c08bfc954f047cf0/ff46a/resetTinker.png 325w,
/static/aa622b4bbfe0d3c4c08bfc954f047cf0/a6d36/resetTinker.png 650w,
/static/aa622b4bbfe0d3c4c08bfc954f047cf0/e548f/resetTinker.png 975w,
/static/aa622b4bbfe0d3c4c08bfc954f047cf0/3c492/resetTinker.png 1300w,
/static/aa622b4bbfe0d3c4c08bfc954f047cf0/ae28e/resetTinker.png 1598w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;blockquote&gt;
&lt;p&gt;“It’s still magic even if you know how it’s done.”
-Terry Pratchett,&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[The Power Of Bookmarking Websites]]></title><description><![CDATA[What is Bookmarking?  Bookmarking is the practice of saving a website to your browser for easy access at a later time. On Google Chrome…]]></description><link>https://www.devsurvival.com/the-power-of-bookmarking/</link><guid isPermaLink="false">https://www.devsurvival.com/the-power-of-bookmarking/</guid><pubDate>Sat, 11 Apr 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;What is Bookmarking?&lt;/h3&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 150.30674846625766%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAeABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIEAQP/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAABuYns7jBi5QcRA//EABwQAAICAgMAAAAAAAAAAAAAAAABAgMRMRIhMv/aAAgBAQABBQKZW+UWiwo2ywrhge5C8N9//8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAwEBPwEf/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPwEf/8QAFRABAQAAAAAAAAAAAAAAAAAAIBH/2gAIAQEABj8CdP8A/8QAGxAAAgIDAQAAAAAAAAAAAAAAAAERIRAxQaH/2gAIAQEAAT8hUrYpaLDUaIccjWWRE8YnKrif/9oADAMBAAIAAwAAABCcJoL/xAAVEQEBAAAAAAAAAAAAAAAAAAABIP/aAAgBAwEBPxAj/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPxAf/8QAHRAAAwEAAgMBAAAAAAAAAAAAAAERIUFRMWGRcf/aAAgBAQABPxCGvgTFCdd66dA8v4Ocjqo+iFLTNKFubi/Q+9N57Q9PaptP/9k=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;bookmarking&quot;
        title=&quot;bookmarking&quot;
        src=&quot;/static/d4788a0aaa9559b2e9bbfc117b99af39/6aca1/bookmarking.jpg&quot;
        srcset=&quot;/static/d4788a0aaa9559b2e9bbfc117b99af39/d2f63/bookmarking.jpg 163w,
/static/d4788a0aaa9559b2e9bbfc117b99af39/c989d/bookmarking.jpg 325w,
/static/d4788a0aaa9559b2e9bbfc117b99af39/6aca1/bookmarking.jpg 650w,
/static/d4788a0aaa9559b2e9bbfc117b99af39/b701e/bookmarking.jpg 934w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;div&gt; &lt;small style=&quot;margin-left: 15vw&quot;&gt;Credits to: &lt;/small&gt;
&lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@oriento?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from 五玄土 ORIENTO&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;五玄土 ORIENTO&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Bookmarking is the practice of saving a website to your browser for easy access at a later time. On Google Chrome, there is usually a star at the end of the URL bar that lets you bookmark the current page. Pretty straight forward, but it is one of the most under-appreciated feature.&lt;/p&gt;
&lt;h3&gt;Why you should start Bookmarking&lt;/h3&gt;
&lt;p&gt;Bookmarking allows you to quickly save a website, so you can look at it later like an interesting article that you want to read later. You can bookmark your most visited sites, such as Youtube or Twitter. People tend to visit these sites with high frequency throughout the day, and being able to directly go to them with a click of a button can be a time saver.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Please save yourself from a carpal tunnel by clicking that star to save the website. Otherwise, bookmark your frequently visit websites so you can avoid the common habit of doing a google search every time… Cmon, we have all been there. Me: trying to get to Youtube&lt;/p&gt;
&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;typing “yout” in the URL bar&lt;/li&gt;
&lt;li&gt;waiting for the google search algorithm to do its things&lt;/li&gt;
&lt;li&gt;its done finally! (Click the first Youtube result)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Bookmarking on Steroid&lt;/h3&gt;
&lt;p&gt;Are you convinced yet? Bookmarking in its simplest form is great, but what if you have hundreds of websites? Start grouping websites into directories! This is where the true power of bookmarking lies in. Organizing related websites into folders allows you to quickly and intuitively find a website you are looking for. For instance if I was looking for a website I bookmarked about a hackathon, I can intuitively go into my bookmark directories : code -&gt; hackathon -&gt; my_hackathon.com&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 52.14723926380368%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAABYlAAAWJQFJUiTwAAACPElEQVQoz1WS3UuTURzH/VequbfHbe7NvTzPdNPlFgsaRcSySG0oGItA8qKZL82LuloX3hUrIbo0CN2EVkT/QF00G429z70xCEw3LOrb+Z05pQe+/J6Xcz7nc87v6XsQfoiZ2Tl4vD7YxWFYbRKvojQCi1WC0+XG0tIKVlYjPOHFZcwvhBG6dx93QvMIzoYQuDENv/8KAldvoQ/sSuzssMl2DtLq9FCqBiAM6CDrV2LMPY5UKoVcLsfzNfUN28lP2Nx6h5ev3yC6HsPy46dYuLuIJ2sbXWAy+Z5N9MB74SJGnGPcTnI44Rh2wWaXIGj03NxiFaEbNLJFDTyDehNUbHE32100+gLP1z92gfF4gg82miyQK9RQqTXckqqCVbVMAbPZyr+bh2w8BuMQTOydUilg1O3FxqtNvH324RiYSPDBNrujuyoDcSgbrGVGk9cCCAZnMDUdxOTUbV6vT9zEBMsl/2WsPoogFothLRI5NSQgWWq0eg5Ts5yRq+ATRfxNfcF+u41ddpaZTAbZbBb5fJ6fKdVCIc/fp9Pp/7dMhj2gILCmyJWQ7C7sfv6OdqeNvb09tFot1Go11Ot1nmazeZJGo9EFbm3H0c/Orgc1MVvauuycHOKoF4UfHRz+3EeWGRGkWCzyVCoVlMvlY8sCSqXSKZDMqLt6g5n/MmpBi7MM6Bn34s+vI3Q6HT6BLAlCNmRKz2RHcKonWyYQdU/BGkEd7gHPe3xoH/3G4cEBt+oBCUYQeq5Wq9yQ7v8Btfn8NsBGrl8AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;bookmarking folders&quot;
        title=&quot;bookmarking folders&quot;
        src=&quot;/static/50a652fc8ba27e23d84ae3347265de34/a6d36/bookmarking_folder.png&quot;
        srcset=&quot;/static/50a652fc8ba27e23d84ae3347265de34/222b7/bookmarking_folder.png 163w,
/static/50a652fc8ba27e23d84ae3347265de34/ff46a/bookmarking_folder.png 325w,
/static/50a652fc8ba27e23d84ae3347265de34/a6d36/bookmarking_folder.png 650w,
/static/50a652fc8ba27e23d84ae3347265de34/e548f/bookmarking_folder.png 975w,
/static/50a652fc8ba27e23d84ae3347265de34/3c492/bookmarking_folder.png 1300w,
/static/50a652fc8ba27e23d84ae3347265de34/e3729/bookmarking_folder.png 1794w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;It might be cumbersome or even pointless to do it this way, but at least give it a try 🙏. I had some doubts when I first started, but the investment was totally worth it now 😄&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Blogging As A Learning Tool]]></title><description><![CDATA[What is Blogging?  Photo Credits To: unsplash-logoNeONBRAND This question has probably been answered a thousand times, but I will answer it…]]></description><link>https://www.devsurvival.com/blogging-as-a-learning-tool/</link><guid isPermaLink="false">https://www.devsurvival.com/blogging-as-a-learning-tool/</guid><pubDate>Thu, 09 Apr 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;What is Blogging?&lt;/h3&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 640px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/6f4ad5aef8c2974c1f8500d1acccb636/c08c5/blogging.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.87116564417178%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAIBAwT/xAAVAQEBAAAAAAAAAAAAAAAAAAABAP/aAAwDAQACEAMQAAABdDAUFAn/xAAaEAADAAMBAAAAAAAAAAAAAAABAgMREhMh/9oACAEBAAEFAlUuKQ8oNGptjq2SST//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAcEAACAgIDAAAAAAAAAAAAAAABEQACYXESMVH/2gAIAQEABj8CIuxhwCpW4uT1GLKZ9jPc/8QAGhABAAMBAQEAAAAAAAAAAAAAAQARMUEhcf/aAAgBAQABPyHmDfCZb9s1Hd3a4h9Tw12IBGhDpFWrP//aAAwDAQACAAMAAAAQV+//xAAXEQEBAQEAAAAAAAAAAAAAAAABABEh/9oACAEDAQE/EEx7Lf/EABcRAQEBAQAAAAAAAAAAAAAAAAEAESH/2gAIAQIBAT8QHTkX/8QAGhABAQEBAQEBAAAAAAAAAAAAAREAITFxQf/aAAgBAQABPxCrKQCBjjz9o7pOjXiHJNxZogRX7oPNwHj7pzvItcjdaiq7/9k=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Blogging&quot;
        title=&quot;Blogging&quot;
        src=&quot;/static/6f4ad5aef8c2974c1f8500d1acccb636/c08c5/blogging.jpg&quot;
        srcset=&quot;/static/6f4ad5aef8c2974c1f8500d1acccb636/d2f63/blogging.jpg 163w,
/static/6f4ad5aef8c2974c1f8500d1acccb636/c989d/blogging.jpg 325w,
/static/6f4ad5aef8c2974c1f8500d1acccb636/c08c5/blogging.jpg 640w&quot;
        sizes=&quot;(max-width: 640px) 100vw, 640px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;small&gt;Photo Credits To: &lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@neonbrand?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from NeONBRAND&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;NeONBRAND&lt;/span&gt;&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;This question has probably been answered a thousand times, but I will answer it from the perspective of a computer science student which might differ a little bit with the conventional views.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Besides being a great tool for sharing new ideas or maybe passing along some useful information. Blogging can also serve as a learning tool for the writer themselves. Just consider what is going on inside the blogger’s mind when they are writing. For instance, if you were writing a blog about how to build a website, you first have to know how to do it yourself. Once you know how to do it, your next challenge is to formulate how you are going to deliver it to the audience. Some questions you might ask:&lt;/p&gt;
&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;How should I break down the problem?&lt;/li&gt;
&lt;li&gt;What are some questions or challenges that my audience will have if I wrote it this way?&lt;/li&gt;
&lt;li&gt;Can I simplify it even further to enhance understanding?&lt;/li&gt;
&lt;li&gt;Will this information be overwhelming?&lt;/li&gt;
&lt;li&gt;If I was in their shoes, what would I wish the author could have done better?&lt;/li&gt;
&lt;li&gt;Can some people see the value in reading this post?&lt;/li&gt;
&lt;/ul&gt;
&lt;br/&gt;
&lt;p&gt;These are not all the questions going through the bloggers mind, but it paints a pretty good picture of the thinking process.&lt;/p&gt;
&lt;h3&gt;How Does Blogging Helps You Learn?&lt;/h3&gt;
&lt;p&gt;There is a common understanding that a true expert of anything can explain their topic to even the most unintelligent of us. This concept is called &lt;a href=&quot;https://effectiviology.com/protege-effect-learn-by-teaching/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;The Protégé Effect&lt;/a&gt;, the act of teaching someone else as a mean to learn. Sounds selfish, but it works. I have practiced this method multiple times when learning a new programming skill, and I must confess that I am a better programmer because of it.&lt;/p&gt;
&lt;br/&gt;
&lt;h3&gt;What’s Next?&lt;/h3&gt;
&lt;p&gt;The next time you confront a new learning challenge, write about it and try to teach it to someone else!&lt;/p&gt;
&lt;h4&gt;What If I am Wrong?&lt;/h4&gt;
&lt;p&gt;Before becoming a blogger, I always had some reservations about how other people would react. However, I learned that a blog is the best place to make a mistake 😄 When you are wrong about something people are quick to point out your mistakes, and you as the writer, should take those criticisms and feedbacks and improve from them!&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;&lt;strong&gt;Happy Blogging 🌟 😃 🌟!&lt;/strong&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How Many Hours Do You Code In a Day During a Crisis]]></title><description><![CDATA[At the time of writing this, I was under locked down due to the coronavirus. There was not a lot that I could do to pass the time. I could…]]></description><link>https://www.devsurvival.com/coding-during-crisis/</link><guid isPermaLink="false">https://www.devsurvival.com/coding-during-crisis/</guid><pubDate>Sun, 29 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 242px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/5b6d4e418f644633a3c0bc80a77517a4/46713/virus.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 85.88957055214723%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAARABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAQFAQL/xAAWAQEBAQAAAAAAAAAAAAAAAAAAAgH/2gAMAwEAAhADEAAAAc22SuczHpScHAf/xAAaEAACAwEBAAAAAAAAAAAAAAACAwABERJB/9oACAEBAAEFAlLrOFnOC1ZDnQhRtsink//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABcRAAMBAAAAAAAAAAAAAAAAAAERIEH/2gAIAQIBAT8BLyP/xAAbEAACAgMBAAAAAAAAAAAAAAABEQASAhAgMf/aAAgBAQAGPwK2UVVoB+Rkwnj/xAAcEAEAAgMAAwAAAAAAAAAAAAABABEhMUEQUWH/2gAIAQEAAT8hbkNOCAcH0RBFaYl9H2hSFrgwK0W6qd8v/9oADAMBAAIAAwAAABA70MH/xAAXEQEAAwAAAAAAAAAAAAAAAAABABAx/9oACAEDAQE/EANYX//EABcRAQEBAQAAAAAAAAAAAAAAAAERABD/2gAIAQIBAT8QdTEe/wD/xAAcEAEAAgMBAQEAAAAAAAAAAAABABEhMUFxUWH/2gAIAQEAAT8QXkNA6YxzQULY8hn3ByEKyRo1z25X6FoCv5X2C6N2Bqc+ENfYz//Z&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;coding during a pandemic&quot;
        title=&quot;coding during a pandemic&quot;
        src=&quot;/static/5b6d4e418f644633a3c0bc80a77517a4/46713/virus.jpg&quot;
        srcset=&quot;/static/5b6d4e418f644633a3c0bc80a77517a4/d2f63/virus.jpg 163w,
/static/5b6d4e418f644633a3c0bc80a77517a4/46713/virus.jpg 242w&quot;
        sizes=&quot;(max-width: 242px) 100vw, 242px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;At the time of writing this, I was under locked down due to the &lt;a href=&quot;https://www.cdc.gov/coronavirus/2019-ncov/index.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;coronavirus&lt;/a&gt;. There was not a lot that I could do to pass the time. I could waste time on youtube or browse the latest viral news. Instead, I decided to code and learn something new while I’m at it. Yeah yeah, “overachiever over hurr”. What? I like to code. Coding and &lt;strong&gt;A LOT&lt;/strong&gt; of free time is a perfect combination.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;For the last week or so, I have put in an average of 6-8 hrs a day ≈ a full day job without the pay.&lt;/p&gt;
&lt;h3&gt;So what about you? What crisis are you in right now? How has that affect your productivity?&lt;/h3&gt;</content:encoded></item><item><title><![CDATA[Top 10 Discord Servers For Developers]]></title><description><![CDATA[What The Heck is Discord ? Discord is a community based chatting app that allows you to directly connect with other people within your niche…]]></description><link>https://www.devsurvival.com/top-10-discord-servers-for-developers/</link><guid isPermaLink="false">https://www.devsurvival.com/top-10-discord-servers-for-developers/</guid><pubDate>Sun, 29 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;What The Heck is &lt;a href=&quot;https://discordapp.com/company&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Discord&lt;/a&gt; ?&lt;/h3&gt;
&lt;p&gt;Discord is a community based chatting app that allows you to directly connect with other people within your niche. Although Discord was initially built for gamers, it grew and people from all walks of life started using it to empower their connectivity.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;One of those communities is obviously the developer’s communities. I say &lt;strong&gt;communities&lt;/strong&gt; , plural, because there are multiple sub-communities. One might focus on web development while another might focus on game development.&lt;/p&gt;
&lt;br/&gt;
&lt;h3&gt;Here Are My Top 10 Discord Servers To Join As a Developer&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://discord.me/coding&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Programmer’s Hangout&lt;/a&gt; - Jack of all trade. There is a channel for everything you can think of. They have special channels dedicated to off-topic discussion, web development, computer science topic, animme, javascript, jobs, etc.. It is also very active with over 10,000 active users.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discord.me/devcord&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Devcord&lt;/a&gt; - Another popular community that focuses on general development topic, such as web development, desktop application, mobile devleopment. They also help channels for getting help with language or technology specific problems.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/code&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;The Coding Den&lt;/a&gt; - Another active community with over 5000 active users. Similar to the other servers, this one also provides technology/language specific channels. There is also a channel for showcasing your projects. However, be aware that they are very weary about spamming your project for the sake of promoting it, so make sure it is educational and adds value to the community.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discord.me/speakjs&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;SpeakJS&lt;/a&gt; - do you write a lot of Javascript? Well, there is a server fully dedicated to it! You will be surprised at how much more you can learn by interacting with other people. give it a try!&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discord.me/codesupport&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;CodeSupport&lt;/a&gt; - If you need some serious help with your programming, then there is no better place to look than here. There is just about one channel for every topics you can think of.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://disboard.org/server/425824580918181889&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Nodeiflux&lt;/a&gt; - Do you have an unbreakable bond with Javascript that you would use it for both frontend and backend development? That is where Node comes in. This one single technology that allows developers to run Javascript on the server gave rise to an entire community of developers.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordsl.com/server/4837/lazy-developers&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Lazy Developer&lt;/a&gt; - They say developers are one of the most lazy people. What better way to honor that than to create an entire community full of lazy devlopers. On a more serious note, this server can be a great place to learn new tips and tricks to increase your productivity and reduce your work.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://disboard.org/server/395520812347686912&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;TensorFlow&lt;/a&gt; - If you are familiar with machine learning, then you probably already know that Tensorflow tends to be the centered of manny conversations. It is the most popular machine learning library.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/ph&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Programmer Humor&lt;/a&gt; - Are you suffering from a developer’s burnout or just bored from typing all day? Come here to get your daily juice of laughter from intelligent people with a humor side.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/python&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Python&lt;/a&gt; - Python is quickly becoming one of the most trending languages do to its simplicity and role in data science and machine learning. Come here to showcase your python skill and pick up a some extra tips and tricks.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Update:&lt;/h3&gt;
&lt;p&gt;here are some additional servers recommended by the awesome community at &lt;a href=&quot;https://dev.to/htnguy/top-10-discord-servers-for-developers-559o&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;devto:&lt;/a&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.reactiflux.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Reactiflux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vue.land/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Vue Land&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/typescript&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Typescript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/mPZNm7A&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Laravel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://discordapp.com/invite/Bed5FRa&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Qovery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Did I Miss One?&lt;/h3&gt;
&lt;p&gt;There are a lot of servers, so narrowing it down to a handful is quite a difficult task, so if I missed a very reputable one, please forgive me 😥 and post it in the comment below.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How To Get In Contact]]></title><description><![CDATA[Let’s Connect You can get in touch with me using the contact form or follow me on social media:]]></description><link>https://www.devsurvival.com/contact-info/</link><guid isPermaLink="false">https://www.devsurvival.com/contact-info/</guid><pubDate>Sat, 28 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;Let’s Connect&lt;/h3&gt;
&lt;p&gt;You can get in touch with me using the &lt;a href=&quot;/contact/&quot;&gt;contact form&lt;/a&gt; or follow me on social media:&lt;/p&gt;
&lt;br/&gt;
&lt;div style=&quot;display:flex;flex-wrap:wrap&quot;&quot;&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://twitter.com/HieuNgu11332621&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 512 512&quot; color=&quot;#1DA1F2&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(29, 161, 242);&quot;&gt;&lt;path d=&quot;M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &amp;nbsp;&lt;/a&gt;
&lt;p&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://www.linkedin.com/in/hieu-nguyen-2572b9170/&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; color=&quot;#2867B2&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(40, 103, 178);&quot;&gt;&lt;path d=&quot;M100.28 448H7.4V148.9h92.88zM53.79 108.1C24.09 108.1 0 83.5 0 53.8a53.79 53.79 0 0 1 107.58 0c0 29.7-24.1 54.3-53.79 54.3zM447.9 448h-92.68V302.4c0-34.7-.7-79.2-48.29-79.2-48.29 0-55.69 37.7-55.69 76.7V448h-92.78V148.9h89.08v40.8h1.3c12.4-23.5 42.69-48.3 87.88-48.3 94 0 111.28 61.9 111.28 142.3V448z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://medium.com/@hieu.nguyen4e&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; color=&quot;#292929&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(41, 41, 41);&quot;&gt;&lt;path d=&quot;M0 32v448h448V32H0zm372.2 106.1l-24 23c-2.1 1.6-3.1 4.2-2.7 6.7v169.3c-.4 2.6.6 5.2 2.7 6.7l23.5 23v5.1h-118V367l24.3-23.6c2.4-2.4 2.4-3.1 2.4-6.7V199.8l-67.6 171.6h-9.1L125 199.8v115c-.7 4.8 1 9.7 4.4 13.2l31.6 38.3v5.1H71.2v-5.1l31.6-38.3c3.4-3.5 4.9-8.4 4.1-13.2v-133c.4-3.7-1-7.3-3.8-9.8L75 138.1V133h87.3l67.4 148L289 133.1h83.2v5z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://dev.to/htnguy&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; color=&quot;#08090A&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(8, 9, 10);&quot;&gt;&lt;path d=&quot;M120.12 208.29c-3.88-2.9-7.77-4.35-11.65-4.35H91.03v104.47h17.45c3.88 0 7.77-1.45 11.65-4.35 3.88-2.9 5.82-7.25 5.82-13.06v-69.65c-.01-5.8-1.96-10.16-5.83-13.06zM404.1 32H43.9C19.7 32 .06 51.59 0 75.8v360.4C.06 460.41 19.7 480 43.9 480h360.2c24.21 0 43.84-19.59 43.9-43.8V75.8c-.06-24.21-19.7-43.8-43.9-43.8zM154.2 291.19c0 18.81-11.61 47.31-48.36 47.25h-46.4V172.98h47.38c35.44 0 47.36 28.46 47.37 47.28l.01 70.93zm100.68-88.66H201.6v38.42h32.57v29.57H201.6v38.41h53.29v29.57h-62.18c-11.16.29-20.44-8.53-20.72-19.69V193.7c-.27-11.15 8.56-20.41 19.71-20.69h63.19l-.01 29.52zm103.64 115.29c-13.2 30.75-36.85 24.63-47.44 0l-38.53-144.8h32.57l29.71 113.72 29.57-113.72h32.58l-38.46 144.8z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://www.reddit.com/user/hieuTnguyen&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 512 512&quot; color=&quot;#EC5428&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(236, 84, 40);&quot;&gt;&lt;path d=&quot;M201.5 305.5c-13.8 0-24.9-11.1-24.9-24.6 0-13.8 11.1-24.9 24.9-24.9 13.6 0 24.6 11.1 24.6 24.9 0 13.6-11.1 24.6-24.6 24.6zM504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-132.3-41.2c-9.4 0-17.7 3.9-23.8 10-22.4-15.5-52.6-25.5-86.1-26.6l17.4-78.3 55.4 12.5c0 13.6 11.1 24.6 24.6 24.6 13.8 0 24.9-11.3 24.9-24.9s-11.1-24.9-24.9-24.9c-9.7 0-18 5.8-22.1 13.8l-61.2-13.6c-3-.8-6.1 1.4-6.9 4.4l-19.1 86.4c-33.2 1.4-63.1 11.3-85.5 26.8-6.1-6.4-14.7-10.2-24.1-10.2-34.9 0-46.3 46.9-14.4 62.8-1.1 5-1.7 10.2-1.7 15.5 0 52.6 59.2 95.2 132 95.2 73.1 0 132.3-42.6 132.3-95.2 0-5.3-.6-10.8-1.9-15.8 31.3-16 19.8-62.5-14.9-62.5zM302.8 331c-18.2 18.2-76.1 17.9-93.6 0-2.2-2.2-6.1-2.2-8.3 0-2.5 2.5-2.5 6.4 0 8.6 22.8 22.8 87.3 22.8 110.2 0 2.5-2.2 2.5-6.1 0-8.6-2.2-2.2-6.1-2.2-8.3 0zm7.7-75c-13.6 0-24.6 11.1-24.6 24.9 0 13.6 11.1 24.6 24.6 24.6 13.8 0 24.9-11.1 24.9-24.6 0-13.8-11-24.9-24.9-24.9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://github.com/htnguy&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 496 512&quot; color=&quot;#25292E&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;color: rgb(37, 41, 46);&quot;&gt;&lt;path d=&quot;M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z&quot;&gt;&lt;/path&gt;&lt;/svg&gt; &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.pinterest.com/devsurvival/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 496 512&quot; size=&quot;25&quot; height=&quot;25&quot; width=&quot;25&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; color=&quot;#D42D30&quot; style=&quot;color: rgb(212, 45, 48);&quot;&gt;&lt;path d=&quot;M496 256c0 137-111 248-248 248-25.6 0-50.2-3.9-73.4-11.1 10.1-16.5 25.2-43.5 30.8-65 3-11.6 15.4-59 15.4-59 8.1 15.4 31.7 28.5 56.8 28.5 74.8 0 128.7-68.8 128.7-154.3 0-81.9-66.9-143.2-152.9-143.2-107 0-163.9 71.8-163.9 150.1 0 36.4 19.4 81.7 50.3 96.1 4.7 2.2 7.2 1.2 8.3-3.3.8-3.4 5-20.3 6.9-28.1.6-2.5.3-4.7-1.7-7.1-10.1-12.5-18.3-35.3-18.3-56.6 0-54.7 41.4-107.6 112-107.6 60.9 0 103.6 41.5 103.6 100.9 0 67.1-33.9 113.6-78 113.6-24.3 0-42.6-20.1-36.7-44.8 7-29.5 20.5-61.3 20.5-82.6 0-19-10.2-34.9-31.4-34.9-24.9 0-44.9 25.7-44.9 60.2 0 22 7.4 36.8 7.4 36.8s-24.5 103.8-29 123.2c-5 21.4-3 51.6-.9 71.2C65.4 450.9 0 361.1 0 256 0 119 111 8 248 8s248 111 248 248z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Setting or Scaling Native Resolution On Mac]]></title><description><![CDATA[Defaults and Settings If you own a mac or have previous experiences with one then you probably know that Apple offers a list of options for…]]></description><link>https://www.devsurvival.com/setting-native-resolution-on-mac/</link><guid isPermaLink="false">https://www.devsurvival.com/setting-native-resolution-on-mac/</guid><pubDate>Sat, 28 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d4b78054aa0bc5f3cbfc60ee38a4677c/6a068/macbook.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.87116564417178%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAUCAwT/xAAVAQEBAAAAAAAAAAAAAAAAAAABAP/aAAwDAQACEAMQAAABkpaVC2NAX//EABoQAAMBAAMAAAAAAAAAAAAAAAECEQMABCP/2gAIAQEAAQUCbVoaOdceBWsuIYqIv//EABYRAQEBAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPwE1n//EABYRAAMAAAAAAAAAAAAAAAAAAAIQIf/aAAgBAgEBPwGCv//EABsQAAIBBQAAAAAAAAAAAAAAAAABAhAhMUFx/9oACAEBAAY/AmrGSHB0SWj/xAAZEAEAAwEBAAAAAAAAAAAAAAABABEhQTH/2gAIAQEAAT8hZQHItHrGenPv6I1La7CyQKJ//9oADAMBAAIAAwAAABBnL//EABURAQEAAAAAAAAAAAAAAAAAABAx/9oACAEDAQE/EID/xAAWEQADAAAAAAAAAAAAAAAAAAAAASH/2gAIAQIBAT8QboQ//8QAHhABAAIBBAMAAAAAAAAAAAAAAQARITFBUWGBocH/2gAIAQEAAT8QT5EVi33DLKmAUdnTEu1IXzn7KDrLquSNoNhzcDylDgCf/9k=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;mac&quot;
        title=&quot;mac&quot;
        src=&quot;/static/d4b78054aa0bc5f3cbfc60ee38a4677c/6aca1/macbook.jpg&quot;
        srcset=&quot;/static/d4b78054aa0bc5f3cbfc60ee38a4677c/d2f63/macbook.jpg 163w,
/static/d4b78054aa0bc5f3cbfc60ee38a4677c/c989d/macbook.jpg 325w,
/static/d4b78054aa0bc5f3cbfc60ee38a4677c/6aca1/macbook.jpg 650w,
/static/d4b78054aa0bc5f3cbfc60ee38a4677c/6a068/macbook.jpg 960w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;h2&gt;Defaults and Settings&lt;/h2&gt;
&lt;p&gt;If you own a mac or have previous experiences with one then you probably know that Apple offers a list of options for &lt;a href=&quot;https://support.apple.com/guide/mac-help/change-your-displays-resolution-mchl86d72b76/mac&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;configuration&lt;/a&gt; the resolution of your display. You can choose “default for display” or select from a list of scaled options: Ranging from “Larger Text” to “More Space”. If you hover over an option, you will see the resolution that it scales to.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/bce18eab17344cee86227a06e3134ad0/9685e/displayoptions.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 68.09815950920245%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAABYlAAAWJQFJUiTwAAACZElEQVQ4y3VUy27UQBDcv0CIOwKFsH6M7Rnba4/Hj/X6uUmQrEggkaBEyiVC3ODArxfds4vIRuFQco89U1PdXe3V3CYYxhnLslhM8wwlJVIlYDKJQucoigLGGCRJAqUUQWK8vsG3779wffeIT18f8OXhB4brW6yE78IXAYIgJAQQQsDxBNbFZzj1PfKqR10ZVHWNpmkQxzEcx6F9AaJI2nMcB2FoeVYRqQmEB+GtIXzfxlEUIRgeEe5/Yjsu2E8D9vOEq6tLVFVlvzNCIokYx9jzXKxkKOAlLd7HFzj3FN6tY5ypkW4WUOIDsixFusmg8i1M1dr0y7LCZrM5EB7JWa3n+ViF/hrxeI94+W1T8QJKqb6DnzSQMoLJNXbVBuX2AgPVtyk1sjxBbiqkukS24QtTSEvoYRXLAG/ehnh13sF1HZy7IV6fVThzQip+hDbPsYwaU5VhGgqMTYl+brHtRtTDjLapUDe1VWkJWbpKMgRKo2k7UtJByIxUFIipozl3uGrsWmuDXGvqvEHTEVm/R83Nqjmbo0IOkiRGEiv7ki2TUCfj41oTASMmq/BaSmXrxUKyLENOGXB8QvivsKfgb8aUKI1GpEdIPSHWHRIzIMp3MO0leXi0nX6R8KDgOUgpOSFqb9DNC+ZpJOvUNlVGWZZI0/SU8C9ObRCd+E1GIUZSM1OnZ/LkbrdD27b2yVP0okK+6X9QKdtF27oxnp7jCw/Gtl0+bOA5naYJfd+j67on6DF0LZL+liwl4aw/Wr+6rvsiVrrZ26LXNKdcE56EwzSUNhWOOTXuujU+qXgOJuL9/C/4AzrF4UPDHS/mAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;mac display options&quot;
        title=&quot;mac display options&quot;
        src=&quot;/static/bce18eab17344cee86227a06e3134ad0/a6d36/displayoptions.png&quot;
        srcset=&quot;/static/bce18eab17344cee86227a06e3134ad0/222b7/displayoptions.png 163w,
/static/bce18eab17344cee86227a06e3134ad0/ff46a/displayoptions.png 325w,
/static/bce18eab17344cee86227a06e3134ad0/a6d36/displayoptions.png 650w,
/static/bce18eab17344cee86227a06e3134ad0/e548f/displayoptions.png 975w,
/static/bce18eab17344cee86227a06e3134ad0/3c492/displayoptions.png 1300w,
/static/bce18eab17344cee86227a06e3134ad0/9685e/displayoptions.png 1336w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;I own a &lt;a href=&quot;https://www.apple.com/macbook-pro-16/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;macbook pro 16”&lt;/a&gt; (you can call me spoiled or lucky :P), and the native resolution for this model is 3072 x 1920. One day, I went to scale the resolution to the native resolution, but could not find an option to do so! It seemed really odd to me that Apple does not offer the option to adjust the resolution to match the native display resolution. Even if there are only a select few who will find it useful, they should still make it available.&lt;/p&gt;
&lt;h2&gt;Display Menu Jumps In To Save The Day&lt;/h2&gt;
&lt;p&gt;Display Menu is an app that lets you configure your macbook display with any resolution. With this tool, I was able to quickly set my screen resolution to the native resolution! But it was…ahh not all great.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;The native resolution turns out to be too small for my eyes, and I have almost 20/20 vision. However, everything on the screen was crispier and there was more screen real estate.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/97f64c738b9c7028ee5678fa28d8d443/f581c/newdisplay.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 62.576687116564415%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABb0lEQVQ4y53TO08CQRAHcL4DtMBRUZPgdwFqBBVBPqSdrY0Ntdy+jr338+/MIacxWHCTTPaSzfwyO7vXmUwmGI/HGA4HlEM4joPRyPleR+j3+5hO77Db7fG8fcF2u8fyfk35gNXqEcvlGqv1EzabHdarDTqMcNG15L1ut4v5fI5LeJ6Hw+EApTSM1qiqqtnj7w4XDgaDq8ld9no9zGazuqAsS6RZhiSK4MUpVBijKosa4syzHJ0GYPhPMsgd/gYv8eZXeLUVCu7wAuYMXoH+B8+FDHyEJd6D8gzifOybQY4wDKGkhFYKmlYpXMRxfBu4WCwa0FoLSVCaJpQ0T8qiKNp1yEc2nsXx6MKVClJ7EMYijJOfW74FLAg8+QGE1BD0bLTx6BkZZHTzrcCcQEUdfgpFoIGg+R1dgSiK24F8odb6EPpUd3l0XUi6nKIo24EcfhDWkKa/RNEMJXWaJGl7MAgCuELU8zPGEGroyFEDfgHzhJ+aDMg8MwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;macbook pro 16&amp;quot; native resolution&quot;
        title=&quot;macbook pro 16&amp;quot; native resolution&quot;
        src=&quot;/static/97f64c738b9c7028ee5678fa28d8d443/a6d36/newdisplay.png&quot;
        srcset=&quot;/static/97f64c738b9c7028ee5678fa28d8d443/222b7/newdisplay.png 163w,
/static/97f64c738b9c7028ee5678fa28d8d443/ff46a/newdisplay.png 325w,
/static/97f64c738b9c7028ee5678fa28d8d443/a6d36/newdisplay.png 650w,
/static/97f64c738b9c7028ee5678fa28d8d443/e548f/newdisplay.png 975w,
/static/97f64c738b9c7028ee5678fa28d8d443/3c492/newdisplay.png 1300w,
/static/97f64c738b9c7028ee5678fa28d8d443/f581c/newdisplay.png 3072w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;h2&gt;Download and Usage&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Download the app from the &lt;a href=&quot;https://apps.apple.com/us/app/display-menu/id549083868?mt=12&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;mac store&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Launch Display Menu&lt;/li&gt;
&lt;li&gt;The icon should added to the top right corner of the screen.&lt;/li&gt;
&lt;li&gt;Click the icon and adjust your resolution.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you have any comments or questions, please submit below.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Best Way To Learn React]]></title><description><![CDATA[Forget what I just said. There is no such thing as the best way for learning ANYTHING. This post is reserved for newcomers to React who are…]]></description><link>https://www.devsurvival.com/best-way-to-learn-react/</link><guid isPermaLink="false">https://www.devsurvival.com/best-way-to-learn-react/</guid><pubDate>Fri, 27 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/638be90904f9f9248d3c69cb2992c562/21b4d/react.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 70.5521472392638%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAABoElEQVQ4y42Tv0rDUBTGk7QgVOmgizgLjlqhi0t1FUHBQdHBZFS6dqjaFMGir6CDLlpEHHSsrr5Ch+RRchd/Nzk3va0pGvg4/79zcu+5jmN9QawyGSnHj5ORP1IeMc+y87gvNVM/nWw1WAOLxvYjtQRBLbf/JCPBTILcA7cU9cA2jXawr9FvgjjZzZonXiEpCbq7TJGUhPCS36rI1G/EXyU+B8mF6GUzKfqI0BgUueZsaHIO9iFugneKPiBuIrWvLRNqMnfyqHIykRWSTsEzGFDcBxsaxPr4Pmn0BM7QZ+1a6yIS+xw7JDZAVQjXKfgONLgQ5ABUQQN/aA1kTWetCHqP7jVZFaZRqyQP8Q9THR+6J+S9ou0wk7lCOI/eAg8QfUFwj16nSR37LsgIH0ELe0H+0HUKFzoeBSAK8fvIbnohXAzoghPIrqw812zK2C8H+e2qsnRto1ek6AWYtZkhV9Ymy9Xn5//6ZRwpzGJH6gB0sn1UxxQc0kRfWAiOhKiUPgZ7B6c9vSxRbSFXrNgy9qad8693PHlj8sS84nMfz/0BFyCKnKIAc38AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;reactjs&quot;
        title=&quot;reactjs&quot;
        src=&quot;/static/638be90904f9f9248d3c69cb2992c562/a6d36/react.png&quot;
        srcset=&quot;/static/638be90904f9f9248d3c69cb2992c562/222b7/react.png 163w,
/static/638be90904f9f9248d3c69cb2992c562/ff46a/react.png 325w,
/static/638be90904f9f9248d3c69cb2992c562/a6d36/react.png 650w,
/static/638be90904f9f9248d3c69cb2992c562/e548f/react.png 975w,
/static/638be90904f9f9248d3c69cb2992c562/21b4d/react.png 1280w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Forget what I just said. There is no such thing as the best way for learning ANYTHING. This post is reserved for newcomers to React who are trying to navigate the complicated world of web development and especially trending technologies like React. I will also prescribe some note worthy courses and tutorials to start learning React some of which I have actually used and succeeded.&lt;/p&gt;
&lt;h2&gt;What is React?&lt;/h2&gt;
&lt;p&gt;React is a framework developed by Facebook and was &lt;a href=&quot;https://opensource.com/resources/what-open-source&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;open sourced&lt;/a&gt; in 2013. React quickly gain popularity and was adopted by some of the top companies like &lt;a href=&quot;https://www.airbnb.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Airbnb&lt;/a&gt;, &lt;a href=&quot;https://www.uber.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Uber&lt;/a&gt;, &lt;a href=&quot;https://www.facebook.com/pg/facebook/about/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Facebook&lt;/a&gt;, and &lt;a href=&quot;https://www.netflix.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Netflix&lt;/a&gt;. However, you don’t have to be a big company to use React. React is able to handle any number of projects from small &lt;a href=&quot;https://en.wikipedia.org/wiki/Single-page_application&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;single page app&lt;/a&gt; to apps that can handle &lt;a href=&quot;https://www.smashingmagazine.com/2016/09/how-to-scale-react-applications/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;thousands of users&lt;/a&gt; at once.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;If you do &lt;a href=&quot;https://en.wikipedia.org/wiki/Web_development&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;web development&lt;/a&gt;, more specifically &lt;a href=&quot;https://www.interaction-design.org/literature/topics/ui-design&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;ui design&lt;/a&gt;, then React will become standard knowledge for many web development positions.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Ohh right. Almost forgot to answer the original question. &lt;a href=&quot;https://reactjs.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;React&lt;/a&gt; in technical term is a component based &lt;a href=&quot;https://searchapparchitecture.techtarget.com/definition/client-side-framework&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;client side framework&lt;/a&gt;. A client side framework is a library that handles the user facing interface of an application. Some of the main jobs of a client side library is to display content to the page (sounds obvious Lol), handles user inputs, provide consistency in the development process( you are using one framework, therefore, there is less of a chance of contradicting &lt;a href=&quot;https://www.nginx.com/blog/principles-of-modern-application-development/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;design philosophy&lt;/a&gt;), and the most important job is to manage the &lt;a href=&quot;https://kentcdodds.com/blog/application-state-management-with-react/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;state of the application&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;React VS &lt;a href=&quot;https://angular.io/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Anguar&lt;/a&gt; VS plain HTML, JS, and CSS?&lt;/h2&gt;
&lt;p&gt;Without going into too much &lt;a href=&quot;https://www.freecodecamp.org/news/angular-vs-react-what-to-choose-for-your-app-2/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;details&lt;/a&gt;, React and Anguar are similar in that they provide the same service to the developers. They provide a set of well defined tools and functionality to ease the UI design process. React is based on &lt;a href=&quot;https://reactjs.org/docs/react-component.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;components&lt;/a&gt; while Angular is based on &lt;a href=&quot;https://angular.io/guide/architecture#modules&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;modules and services&lt;/a&gt;.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;However, some people have argued that React has a steeper &lt;a href=&quot;https://medium.com/@ericclemmons/angular-is-easy-react-is-hard-6f55e360482c&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;learning curve&lt;/a&gt; than Angular. Over the recent years, the learning curve for react has reduced significantly due to the increase of online tutorials and courses.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Angular is managed by &lt;a href=&quot;https://en.wikipedia.org/wiki/Angular_(web_framework)&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Google&lt;/a&gt; , hence, features are slower to release, but not by a lot. Angular is also open source. For comparison Angular has around 60k stars of &lt;a href=&quot;https://github.com/angular/angular&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;github&lt;/a&gt; while React has a whopping &lt;a href=&quot;https://github.com/facebook/react&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;146k stars&lt;/a&gt;. What does more stars translate to? It means more people are using React and &lt;a href=&quot;https://reactjs.org/docs/how-to-contribute.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;contributing&lt;/a&gt; to React. From a developers perspective (I might be a little biased here), React has fewer bugs than Angular, and more features that the developer community is requesting.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Plain HTML, CSS and, JS? Before React and Angular, every single website used any combinations of these three to achieve the same complexity of a modern web app. People used &lt;a href=&quot;https://jquery.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;JQuery&lt;/a&gt; to easily integrate animations and special web interactions.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Don’t be fool. HTML,CSS, and JS are still the backbone of web development. However, how they are used is being revolutionized by React.&lt;/p&gt;
&lt;h2&gt;You Want Some React?&lt;/h2&gt;
&lt;p&gt;There are a lot of good tutorials and resources and some not so great ones. Here are some of the top picks for learning React.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://reactjs.org/tutorial/tutorial.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;React’s Official Website&lt;/a&gt; - there is no better place to learn something than from the originator. Short and easy to follow.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.udemy.com/course/the-advanced-web-developer-bootcamp/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Udemy’s Advanced Web Development BootCamp&lt;/a&gt; - A full stack developer course covering the &lt;a href=&quot;https://www.geeksforgeeks.org/mern-stack/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;MERN&lt;/a&gt; stack - ReactJS, &lt;a href=&quot;https://expressjs.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;ExpressJS&lt;/a&gt;,&lt;a href=&quot;https://nodejs.org/en/about/&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;NodeJS&lt;/a&gt;, and &lt;a href=&quot;https://www.mongodb.com/what-is-mongodb&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;MongoDB&lt;/a&gt;. By the end of this bootcamp, you will be able to build an entire react application with a backend server. (I took this course and built a &lt;a href=&quot;https://www.pixomy.net/home&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;full react application&lt;/a&gt; in less than 2 months)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.udemy.com/course/react-the-complete-guide-incl-redux/?LSNPUBID=jU79Zysihs4&amp;#x26;ranEAID=jU79Zysihs4&amp;#x26;ranMID=39197&amp;#x26;ranSiteID=jU79Zysihs4-hJgTxHRzRjJwjAGursAbmw&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Another Udemy Couse - React - The Complete Guide (incl Hooks, React Router, Redux)&lt;/a&gt; - I have read some great reviews about this course. It is purely focused on React without the extra stuff.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=QFaFIcGhPoM&amp;#x26;list=PLC3y8-rFHvwgg3vaYJgHGnModB54rxOk3&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;Youtube React Tutorial For Beginners&lt;/a&gt; - I like this one because it is completely free and it is a video format course, which makes it way more interactive and helpful for the visual learners.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Final Note&lt;/h2&gt;
&lt;p&gt;If you still find it hard to decide, it’s completely normal. Heck, I was stuck on searching for the best course for days before settling on one. Whatever the case may be, just start somewhere and start building your developer’s toolbox.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Writing For Devsurvival]]></title><description><![CDATA[Why write on devsurvival? Hi. Thanks for coming to devsurvival. This is a new blog where you can submit  writing about technology and more…]]></description><link>https://www.devsurvival.com/guest-blog/</link><guid isPermaLink="false">https://www.devsurvival.com/guest-blog/</guid><pubDate>Fri, 27 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d086496055e058f437bfa7ae4d4ea47f/4b190/guess_blog.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 74.84662576687117%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAwAEBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHQ3PWFlo//xAAZEAEBAQEBAQAAAAAAAAAAAAABAgMSAAT/2gAIAQEAAQUCKrwhHOtK/P1WmWkwsz//xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAgBAwEBPwFH/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAHxAAAgIBBAMAAAAAAAAAAAAAAREAAiEDEhNBcYGR/9oACAEBAAY/AuvkFiPKjpZCHdXLyZxabHqIlz//xAAcEAADAQACAwAAAAAAAAAAAAAAAREhMUFxgbH/2gAIAQEAAT8h16kYrnTcbylG40eKHr3GfRAexcTAiXF3D//aAAwDAQACAAMAAAAQLD//xAAWEQEBAQAAAAAAAAAAAAAAAAABABH/2gAIAQMBAT8QB2Z//8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQIBAT8QUn//xAAdEAEAAgIDAQEAAAAAAAAAAAABACERMUFRgWGh/9oACAEBAAE/EGa9Apw/Y55gQxn8AEJ89rY79mLrc5KnPBFKhHg7tPs0oTQV5P/Z&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;devsurvival guest blog&quot;
        title=&quot;devsurvival guest blog&quot;
        src=&quot;/static/d086496055e058f437bfa7ae4d4ea47f/6aca1/guess_blog.jpg&quot;
        srcset=&quot;/static/d086496055e058f437bfa7ae4d4ea47f/d2f63/guess_blog.jpg 163w,
/static/d086496055e058f437bfa7ae4d4ea47f/c989d/guess_blog.jpg 325w,
/static/d086496055e058f437bfa7ae4d4ea47f/6aca1/guess_blog.jpg 650w,
/static/d086496055e058f437bfa7ae4d4ea47f/4b190/guess_blog.jpg 800w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Why write on devsurvival?&lt;/h3&gt;
&lt;p&gt;Hi. Thanks for coming to devsurvival. This is a new blog where you can submit  writing about technology and more. The community is kinda small right now, but with your help, it can grow! &lt;/p&gt;
&lt;h3&gt;Some Little Rules&lt;/h3&gt;
&lt;p&gt;Please make sure your blog follows the criteria below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Contains a title and cover image.&lt;/li&gt;
&lt;li&gt;Unlike other blogging platform, devsurvival does not concern with your grammar and spelling skills 😉 as long as the readers can understand what you are trying to say. &lt;/li&gt;
&lt;li&gt;Code block must be correctly formatted.&lt;/li&gt;
&lt;li&gt;Content must be useful or fun to read by at least one other person besides yourself.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Submitting Blog&lt;/h3&gt;
&lt;p&gt;Submit your blog using this &lt;a href=&quot;/submit-guest-blog/&quot;&gt;form&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Request An Emoji Tag]]></title><description><![CDATA[Did not find an emoji tag? The emoji tags is an easy way to add emojis to your comments by using # tags ( e.g entering #smile will produce…]]></description><link>https://www.devsurvival.com/request-emoji/</link><guid isPermaLink="false">https://www.devsurvival.com/request-emoji/</guid><pubDate>Fri, 27 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;Did not find an emoji tag?&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;/devsurvival-user-guide/&quot;&gt;emoji tags&lt;/a&gt; is an easy way to add emojis to your comments by using # tags ( e.g entering #smile will produce 😊) Cool right?
Submit your emoji tag request &lt;a href=&quot;/emoji-list/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Devsurvival User Guide]]></title><description><![CDATA[Devsurvival Starter Guide  Welcome to devsurvival ! This quick user guide will get you up to speed with the website in no time Leaving a…]]></description><link>https://www.devsurvival.com/devsurvival-user-guide/</link><guid isPermaLink="false">https://www.devsurvival.com/devsurvival-user-guide/</guid><pubDate>Thu, 26 Mar 2020 23:46:37 GMT</pubDate><content:encoded>&lt;h2&gt;Devsurvival Starter Guide&lt;/h2&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/97e5756e3652007258577a7f76a29ade/e9256/guide.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 85.2760736196319%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAARABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAIDAf/EABYBAQEBAAAAAAAAAAAAAAAAAAEDAP/aAAwDAQACEAMQAAAB1y2xK24xEE6UE//EABkQAAIDAQAAAAAAAAAAAAAAAAABEBESAv/aAAgBAQABBQIXemWxaunCj//EABgRAAIDAAAAAAAAAAAAAAAAAAABAxAT/9oACAEDAQE/AXGZjr//xAAWEQEBAQAAAAAAAAAAAAAAAAASABD/2gAIAQIBAT8BUt//xAAaEAACAgMAAAAAAAAAAAAAAAAAEBFxAQIx/9oACAEBAAY/AiIe1nVm1//EABoQAAIDAQEAAAAAAAAAAAAAAAABEUFhECD/2gAIAQEAAT8hSJlHhW+Zlwhg8T//2gAMAwEAAgADAAAAEBPvwP/EABcRAAMBAAAAAAAAAAAAAAAAAAAQEUH/2gAIAQMBAT8QjhDf/8QAFhEBAQEAAAAAAAAAAAAAAAAAARBh/9oACAECAQE/EDck/8QAHRAAAgICAwEAAAAAAAAAAAAAAAERITGRQVFxsf/aAAgBAQABPxCjD0RN2tOi/Bt9EqpEhmoFONIlzqODL2+IZ//Z&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;devsurvival user guide&quot;
        title=&quot;devsurvival user guide&quot;
        src=&quot;/static/97e5756e3652007258577a7f76a29ade/6aca1/guide.jpg&quot;
        srcset=&quot;/static/97e5756e3652007258577a7f76a29ade/d2f63/guide.jpg 163w,
/static/97e5756e3652007258577a7f76a29ade/c989d/guide.jpg 325w,
/static/97e5756e3652007258577a7f76a29ade/6aca1/guide.jpg 650w,
/static/97e5756e3652007258577a7f76a29ade/7c09c/guide.jpg 975w,
/static/97e5756e3652007258577a7f76a29ade/e9256/guide.jpg 1158w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;Welcome to &lt;a href=&quot;/&quot;&gt;devsurvival&lt;/a&gt; ! This quick user guide will get you up to speed with the website in no time&lt;/p&gt;
&lt;h3&gt;Leaving a comment&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Click on one of the available &lt;a href=&quot;/&quot;&gt;posts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Click on discussion&lt;/li&gt;
&lt;li&gt;Enter your name , email, and comment and hit &lt;strong&gt;comment&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Please don’t spam the discussions.&lt;/li&gt;
&lt;li&gt;Be thoughtful and make constructive comments. It is &lt;strong&gt;ok&lt;/strong&gt; to say “I like the post” or “Cool”.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;You want some emojis?&lt;/h3&gt;
&lt;p&gt;I got you. Type one of the following tags into the comment section.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tags&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;Emoji&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;#smile&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;😀&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#laugh&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;😂&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#pray&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;🙏&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#thumbsup&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;👍&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#fire&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;🔥&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#thinking&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;🤔&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#crying&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;😭&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;📓 &lt;a href=&quot;/emoji-list/&quot;&gt;complete list of emojis&lt;/a&gt; (you can also request new ones to be added)&lt;/p&gt;
&lt;h3&gt;Edit Suggestion&lt;/h3&gt;
&lt;p&gt;At devsurvival, you can make edit suggestions to a post. Follow the instructions below to make an edit suggestion:&lt;/p&gt;
&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;Select a &lt;a href=&quot;./&quot;&gt;post&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Edit Icon&lt;/strong&gt; on the tool bar located on the left side&lt;/li&gt;
&lt;li&gt;Enter your name, email, and a suggestion to the author.&lt;/li&gt;
&lt;li&gt;hit submit&lt;/li&gt;
&lt;li&gt;you are all done! You will be notify of the author’s response by email&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Submitting Guest Blog&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/guest-blog/&quot;&gt;click here&lt;/a&gt; for instructions on submitting guest blog.&lt;/p&gt;
&lt;h3&gt;Quick Access Tools&lt;/h3&gt;
&lt;p&gt;located on the left side bar is a set of icons under &lt;strong&gt;Tools&lt;/strong&gt; to help you navigate devsurvival.com.&lt;/p&gt;
&lt;h3&gt;Last Few Words&lt;/h3&gt;
&lt;p&gt;Have fun and hopefully you learn something while you were here with us. Educating or at least an attempt to do so is the reason why I created this blog.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[About Devsurvival]]></title><description><![CDATA[Enjoy this amazing picture of Vietnam, where it all started. photo credits to:
unsplash-logoAmmie Ngo Humble Roots Devsurvival was born from…]]></description><link>https://www.devsurvival.com/about-me/</link><guid isPermaLink="false">https://www.devsurvival.com/about-me/</guid><pubDate>Tue, 24 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/4151eee33c117e1794cf106cc4d920d7/857b3/vietnam.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.87116564417178%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAEEBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAGlZdrDM0H/xAAcEAACAQUBAAAAAAAAAAAAAAABAgQAERMUISL/2gAIAQEAAQUC2eGSwdpHpWLDKaY3b//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAECAQE/AVf/xAAdEAACAgEFAAAAAAAAAAAAAAAAAQIRAxMzQWGh/9oACAEBAAY/ArWORWkbfpGPCH0M/8QAGxAAAgIDAQAAAAAAAAAAAAAAAAERMSFBUYH/2gAIAQEAAT8h2DjwVEaOOx0lr0VhZocjRYexLyz/2gAMAwEAAgADAAAAEPff/8QAFhEAAwAAAAAAAAAAAAAAAAAAAAER/9oACAEDAQE/EG4Q/8QAFhEAAwAAAAAAAAAAAAAAAAAAARAh/9oACAECAQE/EBU//8QAGxABAAMBAAMAAAAAAAAAAAAAAQARITFxgZH/2gAIAQEAAT8Q4gmxhaFEssXfzINQtU9L9RRKX3V73zLVKoa9i9BRQcn/2Q==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;vietnam is beautiful&quot;
        title=&quot;vietnam is beautiful&quot;
        src=&quot;/static/4151eee33c117e1794cf106cc4d920d7/6aca1/vietnam.jpg&quot;
        srcset=&quot;/static/4151eee33c117e1794cf106cc4d920d7/d2f63/vietnam.jpg 163w,
/static/4151eee33c117e1794cf106cc4d920d7/c989d/vietnam.jpg 325w,
/static/4151eee33c117e1794cf106cc4d920d7/6aca1/vietnam.jpg 650w,
/static/4151eee33c117e1794cf106cc4d920d7/7c09c/vietnam.jpg 975w,
/static/4151eee33c117e1794cf106cc4d920d7/01ab0/vietnam.jpg 1300w,
/static/4151eee33c117e1794cf106cc4d920d7/857b3/vietnam.jpg 6000w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;small&gt;&lt;em&gt;Enjoy this amazing picture of Vietnam, where it all started.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;photo credits to:
&lt;a style=&quot;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&quot; href=&quot;https://unsplash.com/@ammiengo?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; title=&quot;Download free do whatever you want high-resolution photos from Ammie Ngo&quot;&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white&quot; viewBox=&quot;0 0 32 32&quot;&gt;&lt;title&gt;unsplash-logo&lt;/title&gt;&lt;path d=&quot;M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&quot;display:inline-block;padding:2px 3px&quot;&gt;Ammie Ngo&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Humble Roots&lt;/h3&gt;
&lt;p&gt;Devsurvival was born from a curiosity or perhaps an obsession with the internet. It started out as a small side project for experimenting with new web technologies, and now it has grown into a close-knit community of developers.&lt;/p&gt;
&lt;h3&gt;The Purpose&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;To share some of my experiences as a developer and to help others survive the dev world&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;What You Will Find&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Tutorials and guides&lt;/li&gt;
&lt;li&gt;Stories and discussions about development topics&lt;/li&gt;
&lt;li&gt;Free courses covering topics like web development&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Team&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://hieutnguyen.com/&quot; rel=&quot;noopener noreferrer&quot;&gt; me&lt;/a&gt; 👨‍💻&lt;/li&gt;
&lt;li&gt;my macbook 💻&lt;/li&gt;
&lt;li&gt;the internet 🌐&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Build A Todo App with React, MongoDB, ExpressJS, and NodeJS Part 1 (Backend)]]></title><description><![CDATA[Estimated Completion Time: 15-30 minutes Background The classic todo app has been written so many times that most people have lost count…]]></description><link>https://www.devsurvival.com/todo-app-react-backend/</link><guid isPermaLink="false">https://www.devsurvival.com/todo-app-react-backend/</guid><pubDate>Mon, 23 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;Estimated Completion Time: 15-30 minutes&lt;/p&gt;
&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;The classic todo app has been written so many times that most people have lost count. However, in this tutorial, I will try to cover some React and Node JS skills that can be used to create this app.&lt;/p&gt;
&lt;p&gt;A little background. I have about 2 years of react experience and have built several react applications. However, don’t be fool, I am far from being an expert in this area. There are still a lot of advanced things that I am still learning everyday.&lt;/p&gt;
&lt;p&gt;How did I meet our friends React and Node? Story short, I was a computer science student in college and was bored from all the classes I had to take; I needed something to revive the joy of being a programmer, so I did a little research and came upon the MERN Stack - MongoDB, ExpressJS, ReactJS, and NodeJS. I went through a couple online tutorials and here I am.&lt;/p&gt;
&lt;h2&gt;Project Setup&lt;/h2&gt;
&lt;h4&gt;Install Node&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Mac:&lt;/strong&gt;
Install Homebrew. Homebrew is a package manager for mac. It helps you install programs and packages using the terminal.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;72675350557768210000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`/bin/bash -c &amp;quot;\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)&amp;quot;`, `72675350557768210000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;/bin/bash -c &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Install Node&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;54601696830200580000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew install node`, `54601696830200580000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; node&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;check if Node was installed successfully.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;10354122173827030000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`node -v`, `10354122173827030000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;node -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Open a terminal&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;52465424289822610000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sudo apt install nodejs`, `52465424289822610000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; nodejs&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;check if node installed successfully&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;76182026624185090000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`node -v`, `76182026624185090000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;node -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;install NPM, a package manager for Node&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;48078813975711720000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sudo apt install npm`, `48078813975711720000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;check if NPM installed successfully&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;43257466956396270000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm -v`, `43257466956396270000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Window:&lt;/strong&gt;
Download the &lt;a target = &quot;_blank&quot; href =&quot;https://nodejs.org/en/download/&quot; rel=&quot;noopener noreferrer&quot; &gt;installer&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Installing MongoDB&lt;/h4&gt;
&lt;p&gt;MongoDB is the database that we will use to store our todo’s&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mac:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;using Homebrew&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;40275316550807140000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew tap mongodb/brew
brew install mongodb-community@4.2`, `40275316550807140000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew tap mongodb/brew
brew &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; mongodb-community@4.2&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;at the time of writing this, version &lt;code class=&quot;language-text&quot;&gt;4.2&lt;/code&gt; was the latest. The latest version might be different for you. here is a link that might help you find the &lt;a target = &quot;_blank&quot; href =&quot;https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/&quot; rel=&quot;noopener noreferrer&quot;&gt;latest version&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Run the mongodb instance using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;12632012526387526000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew services start mongodb-community`, `12632012526387526000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew services start mongodb-community&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Due to the variations in installing MongoDB depending on the distribution, here is the link to the original &lt;a target = &quot;_blank&quot; href =&quot;https://docs.mongodb.com/manual/administration/install-on-linux/&quot; rel=&quot;noopener noreferrer&quot;&gt;installation guide&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Setting up project structure&lt;/h4&gt;
&lt;p&gt;create the application folder&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;98352953399517920000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir todo-app
cd todo-app`, `98352953399517920000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; todo-app
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; todo-app&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;create the backend folder&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;6435761519141003000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir todo-backend`, `6435761519141003000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; todo-backend&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;create the front end react app&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;92435668254142020000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npx create-react-app todo-frontend`, `92435668254142020000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;npx create-react-app todo-frontend&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;now you should have a folder structure like so&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;todo-app
    - todo-backend
    - todo-frontend
        - node_modules
        - public
        - src
        - package.json
        - .gitignore
        - README.md&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Building backend&lt;/h2&gt;
&lt;p&gt;navigate to the &lt;code class=&quot;language-text&quot;&gt;todo-backend&lt;/code&gt; folder&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;31069629304893764000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`cd todo-backend`, `31069629304893764000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; todo-backend&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;run&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;8966954414001016000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm init -y`, `8966954414001016000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; init -y&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;install packages that we will need to build the express server&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;44692708807885290000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm install express body-parser mongoose --save`, `44692708807885290000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; express body-parser mongoose --save&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ExpressJS&lt;/strong&gt; - is the server framework with Node JS under the hood.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;body-parser&lt;/strong&gt; - allows express to parse the request payload into the &lt;code class=&quot;language-text&quot;&gt;req.body&lt;/code&gt; object. More about this later.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;mongoose&lt;/strong&gt; - high level API for interacting with our MongoDB database.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;create the &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; which will store our server initialization logic.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;36284839921172353000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch index.js`, `36284839921172353000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you have VS Code installed, you can open the project in VS Code using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;28868542568792056000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`code .`, `28868542568792056000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;code &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;otherwise, just open it in your favorite code editor&lt;/p&gt;
&lt;p&gt;copy this code into the index.js file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;14135923571669019000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const express = require(&amp;quot;express&amp;quot;) // our express server
const app = express() // generate an app object
const bodyParser = require(&amp;quot;body-parser&amp;quot;) // requiring the body-parser
const PORT = process.env.PORT || 3000 // port that the server is running on =&gt; localhost:3000
app.use(bodyParser.json()) // telling the app that we are going to use json to handle incoming payload

app.listen(PORT, () =&gt; {
  // listening on port 3000
  console.log(\`listening on port \${PORT}\`) // print this when the server starts
})`, `14135923571669019000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; express &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;express&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// our express server&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// generate an app object&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; bodyParser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;body-parser&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// requiring the body-parser&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// port that the server is running on =&gt; localhost:3000&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;bodyParser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// telling the app that we are going to use json to handle incoming payload&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// listening on port 3000&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;listening on port &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// print this when the server starts&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Run the server&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;6686385869875444000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`node index.js`, `6686385869875444000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;node index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You should see the message print out to the terminal.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nodemon(highly recommend but not required)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This handy tools allows you to edit your server files and see the change propagate in real time without starting the server each time with &lt;code class=&quot;language-text&quot;&gt;node index.js&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;install by running&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;53737063519229000000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`npm install -g nodemon`, `53737063519229000000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g nodemon&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Run the server again using&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;32945947144680575000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`nodemon index.js`, `32945947144680575000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;nodemon index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you choose to not use this tool, make sure to restart the server each time you make a change to the &lt;code class=&quot;language-text&quot;&gt;todo-backend&lt;/code&gt; files&lt;/p&gt;
&lt;h4&gt;Connecting to MongoDB&lt;/h4&gt;
&lt;p&gt;create the models folder in the root of the &lt;code class=&quot;language-text&quot;&gt;todo-backend&lt;/code&gt; folder&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;56466183387109070000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`mkdir models`, `56466183387109070000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; models&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Connecting to the database is really simple. Create an &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file in the &lt;code class=&quot;language-text&quot;&gt;models&lt;/code&gt; directory&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;31725585987448435000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch models/index.js`, `31725585987448435000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; models/index.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;copy the follow code into the &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;64260647837828964000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const mongoose = require(&amp;quot;mongoose&amp;quot;)
mongoose.connect(&amp;quot;mongodb://localhost/todo-app&amp;quot;, {
  // connecting to the mongodb database name: &amp;quot;todo-app&amp;quot; locally
  keepAlive: true, // keeping the connection alive
  useNewUrlParser: true,
  useUnifiedTopology: true,
})
mongoose.set(&amp;quot;debug&amp;quot;, true) // enabling debugging information to be printed to the console for debugging purposes
mongoose.Promise = Promise // setting mongoose&apos;s Promise to use Node&apos;s Promise`, `64260647837828964000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; mongoose &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mongoose&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
mongoose&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mongodb://localhost/todo-app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// connecting to the mongodb database name: &quot;todo-app&quot; locally&lt;/span&gt;
  keepAlive&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// keeping the connection alive&lt;/span&gt;
  useNewUrlParser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  useUnifiedTopology&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
mongoose&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;debug&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// enabling debugging information to be printed to the console for debugging purposes&lt;/span&gt;
mongoose&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Promise &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Promise &lt;span class=&quot;token comment&quot;&gt;// setting mongoose&apos;s Promise to use Node&apos;s Promise&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Create the Todo Model&lt;/h4&gt;
&lt;p&gt;A model is just a blue print for an object that we want to store in our database. It describes the structure and fields that pertains to a specific kinds of data.&lt;/p&gt;
&lt;p&gt;Create the &lt;code class=&quot;language-text&quot;&gt;todo.js&lt;/code&gt; file that will store our model&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;70429251986912610000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch models/todo.js`, `70429251986912610000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; models/todo.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;copy the code below into the &lt;code class=&quot;language-text&quot;&gt;todo.js&lt;/code&gt; file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;3204786339032806000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const mongoose = require(&amp;quot;mongoose&amp;quot;) // requiring the mongoose package

const todoSchema = new mongoose.Schema({
  // creating a schema for todo
  task: {
    // field1: task
    type: String, // task is a string
    unique: true, // it has to be unique
    required: true, // it is required
  },
  completed: {
    // field2: completed
    type: Boolean, // it is a boolean
    default: false, // the default is false
  },
})

const todoModel = mongoose.model(&amp;quot;Todo&amp;quot;, todoSchema) // creating the model from the schema

module.exports = todoModel // exporting the model`, `3204786339032806000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; mongoose &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mongoose&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// requiring the mongoose package&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todoSchema &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;mongoose&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Schema&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// creating a schema for todo&lt;/span&gt;
  task&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// field1: task&lt;/span&gt;
    type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// task is a string&lt;/span&gt;
    unique&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// it has to be unique&lt;/span&gt;
    required&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// it is required&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  completed&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// field2: completed&lt;/span&gt;
    type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Boolean&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// it is a boolean&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// the default is false&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todoModel &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; mongoose&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Todo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todoSchema&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// creating the model from the schema&lt;/span&gt;

module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; todoModel &lt;span class=&quot;token comment&quot;&gt;// exporting the model&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now that we have our model, let’s use it. In the &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file of the &lt;code class=&quot;language-text&quot;&gt;models&lt;/code&gt; dictory , add the following line of code to the bottom.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;19153334068808680000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`module.exports.Todo = require(&amp;quot;./todo&amp;quot;) // requiring the todo model that we just created in mongodb`, `19153334068808680000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./todo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// requiring the todo model that we just created in mongodb&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, add the following statement to the top of the index.js file where we stored server initialization logic. Note: we did not do &lt;code class=&quot;language-text&quot;&gt;require(&amp;quot;./models/index.js&amp;quot;)&lt;/code&gt; because in Node Js whenever we require a directory, it will search for the file named &lt;code class=&quot;language-text&quot;&gt;index&lt;/code&gt; first.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;20142364083527540000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const db = require(&amp;quot;./models/&amp;quot;)`, `20142364083527540000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; db &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./models/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Run the server to make sure that nothing is broken. Chances are, you ran into this error: &lt;code class=&quot;language-text&quot;&gt;MongoNetworkError: failed to connect to server [localhost:27017]&lt;/code&gt; in the terminal which is because we have not started the mongodb server locally. Run the following command to start the mongodb service on mac.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50864142166497200000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`brew services start mongodb-community`, `50864142166497200000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;brew services start mongodb-community&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restart the node server and we should see that everything is fine&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;62680967599902360000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`listening on port 3000
Mongoose: todos.ensureIndex({ task: 1 }, { unique: true, background: true })
(node:10201) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.`, `62680967599902360000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;listening on port &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;
Mongoose: todos.ensureIndex&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; task: &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;, &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; unique: true, background: &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;node:10201&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Establishing API Endpoints&lt;/h4&gt;
&lt;p&gt;API endpoints are just URL’s that can be used to make request to a service or a system.&lt;/p&gt;
&lt;h5&gt;How should we structure our API Endpoints?&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;establish what kinds of functionality we want to expose. In our case, we need to be able to add a new todo, delete a todo, update a todo, and retrieve all the todos&lt;/li&gt;
&lt;li&gt;formulate the routes. For instance an ice-cream distribution API can expose &lt;code class=&quot;language-text&quot;&gt;icecream.com/flavors&lt;/code&gt; making a &lt;code class=&quot;language-text&quot;&gt;GET&lt;/code&gt; request to this API endpoint will retrieve all the flavors.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Our todo API will have the following endpoints&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;77114837912778800000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`GET  /todos //getting all todos
POST  /todos //adding a new todo
PUT  /todos/:id //updating a todo with the matching id
DELETE  /todos/:id //deleting a todo with matching id`, `77114837912778800000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token constant&quot;&gt;GET&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;todos &lt;span class=&quot;token comment&quot;&gt;//getting all todos&lt;/span&gt;
&lt;span class=&quot;token constant&quot;&gt;POST&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;todos &lt;span class=&quot;token comment&quot;&gt;//adding a new todo&lt;/span&gt;
&lt;span class=&quot;token constant&quot;&gt;PUT&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;todos&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;id &lt;span class=&quot;token comment&quot;&gt;//updating a todo with the matching id&lt;/span&gt;
&lt;span class=&quot;token constant&quot;&gt;DELETE&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;todos&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;id &lt;span class=&quot;token comment&quot;&gt;//deleting a todo with matching id&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Lets Create Some Routes&lt;/h4&gt;
&lt;p&gt;Routes in Node and Express are just API endpoints that we are exposing.&lt;/p&gt;
&lt;p&gt;Update the &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file at the root containing the server initialization logic to look like the section below. This might be quite a bit of code, and you will probably feel overwhelmed. Do not be discouraged. I will clarify each part. Those of you who are familiar with &lt;a href=&quot;https://expressjs.com/en/guide/routing.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; &gt; ExpressJS&lt;/a&gt; will find this section familiar, so feel free to skim over the section below.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;3028277160412518000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const express = require(&amp;quot;express&amp;quot;)
const app = express()
const bodyParser = require(&amp;quot;body-parser&amp;quot;)
const PORT = process.env.PORT || 3000
const db = require(&amp;quot;./models/&amp;quot;)

app.use(bodyParser.json())

function success(res, payload) {
  return res.status(200).json(payload)
}

app.get(&amp;quot;/todos&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todos = await db.Todo.find({})
    return success(res, todos)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to get todos&amp;quot; })
  }
})

app.post(&amp;quot;/todos&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todo = await db.Todo.create(req.body)
    return success(res, todo)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to create todo&amp;quot; })
  }
})

app.put(&amp;quot;/todos/:id&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todo = await db.Todo.findByIdAndUpdate(req.params.id, req.body, {
      new: true,
    })
    return success(res, todo)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to update todo&amp;quot; })
  }
})
app.delete(&amp;quot;/todos/:id&amp;quot;, async (req, res, next) =&gt; {
  try {
    await db.Todo.findByIdAndRemove(req.params.id)
    return success(res, &amp;quot;todo deleted!&amp;quot;)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to delete todo&amp;quot; })
  }
})

app.use((err, req, res, next) =&gt; {
  return res.status(err.status || 400).json({
    status: err.status || 400,
    message: err.message || &amp;quot;there was an error processing request&amp;quot;,
  })
})

app.listen(PORT, () =&gt; {
  console.log(\`listening on port \${PORT}\`)
})`, `3028277160412518000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; express &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;express&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; bodyParser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;body-parser&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; db &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./models/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;bodyParser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todos &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todos&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to get todos&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to create todo&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos/:id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findByIdAndUpdate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;params&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to update todo&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos/:id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findByIdAndRemove&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;params&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;todo deleted!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to delete todo&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;err&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;there was an error processing request&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;listening on port &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;success&lt;/code&gt; function accepts the &lt;code class=&quot;language-text&quot;&gt;res&lt;/code&gt; object and the &lt;code class=&quot;language-text&quot;&gt;payload&lt;/code&gt; and send a &lt;code class=&quot;language-text&quot;&gt;200&lt;/code&gt; status code with the &lt;code class=&quot;language-text&quot;&gt;payload&lt;/code&gt; in the response&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;33037458001741290000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`function success(res, payload) {
  return res.status(200).json(payload)
}`, `33037458001741290000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;GET /todos/&lt;/strong&gt; - getting all the todos. &lt;code class=&quot;language-text&quot;&gt;app.get()&lt;/code&gt; tells express that the route &lt;code class=&quot;language-text&quot;&gt;&amp;quot;/todos&amp;quot;&lt;/code&gt; is a get route. The second paramater &lt;code class=&quot;language-text&quot;&gt;async (req,res,next)=&amp;gt;{ //some code }&lt;/code&gt; is the function that gets called when the server receives this request.&lt;/p&gt;
&lt;p&gt;Inside the function, we are getting the all todos using &lt;code class=&quot;language-text&quot;&gt;await db.Todo.find({})&lt;/code&gt;. If it was successful we return &lt;code class=&quot;language-text&quot;&gt;success(res, todos)&lt;/code&gt; with all the todos. Otherwise, we received an error and send a &lt;code class=&quot;language-text&quot;&gt;400&lt;/code&gt; status code with a message.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;96072918385883680000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.get(&amp;quot;/todos&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todos = await db.Todo.find({})
    return success(res, todos)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to get todos&amp;quot; })
  }
})`, `96072918385883680000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todos &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todos&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to get todos&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;POST /todos/&lt;/strong&gt; - creating a new todo
we called &lt;code class=&quot;language-text&quot;&gt;await db.Todo.create(req.body)&lt;/code&gt; to create a new todo. Here &lt;code class=&quot;language-text&quot;&gt;req.body&lt;/code&gt; contains the request payload that will contain the task to be created.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;22516862754426790000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.post(&amp;quot;/todos&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todo = await db.Todo.create(req.body)
    return success(res, todo)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to create todos&amp;quot; })
  }
})`, `22516862754426790000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to create todos&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;PUT /todos/:id&lt;/strong&gt; - updating a todo with the given id
we update the todo by calling &lt;code class=&quot;language-text&quot;&gt;await db.Todo.findByIdAndUpdate(req.params.id, req.body, {new:true})&lt;/code&gt;. here &lt;code class=&quot;language-text&quot;&gt;req.params&lt;/code&gt; contains all the route parameters that we specified; Here we have one: &lt;code class=&quot;language-text&quot;&gt;&amp;quot;/todos/:id&amp;quot;&lt;/code&gt; called &lt;code class=&quot;language-text&quot;&gt;id&lt;/code&gt;. &lt;code class=&quot;language-text&quot;&gt;req.body&lt;/code&gt; contains the new information that we want to update the task with. The last parameter &lt;code class=&quot;language-text&quot;&gt;{new:true}&lt;/code&gt; tells mongoose that we want the updated task to be returned.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73033398209422360000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.put(&amp;quot;/todos/:id&amp;quot;, async (req, res, next) =&gt; {
  try {
    const todo = await db.Todo.findByIdAndUpdate(req.params.id, req.body, {
      new: true,
    })
    return success(res, todo)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to update todo&amp;quot; })
  }
})`, `73033398209422360000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos/:id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findByIdAndUpdate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;params&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to update todo&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;DELETE /todos/:id&lt;/strong&gt; - deleting a todo with the given id
we call &lt;code class=&quot;language-text&quot;&gt;await db.Todo.findByIdAndRemove(req.params.id)&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9563539617211392000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.delete(&amp;quot;/todos/:id&amp;quot;, async (req, res, next) =&gt; {
  try {
    await db.Todo.findByIdAndRemove(req.params.id)
    return success(res, &amp;quot;todo deleted!&amp;quot;)
  } catch (err) {
    next({ status: 400, message: &amp;quot;failed to delete todo&amp;quot; })
  }
})`, `9563539617211392000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/todos/:id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findByIdAndRemove&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;params&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;todo deleted!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failed to delete todo&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is our error handler. Whenever we call &lt;code class=&quot;language-text&quot;&gt;next({status: 400, message: &amp;quot;failed to do something&amp;quot;})&lt;/code&gt;, we are passing the error object to the error handler.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;1062342745287958500&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`app.use((err, req, res, next) =&gt; {
  return res.status(err.status || 400).json({
    status: err.status || 400,
    message: err.message || &amp;quot;there was an error processing request&amp;quot;,
  })
})`, `1062342745287958500`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;err&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;there was an error processing request&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Testing Our API&lt;/h3&gt;
&lt;p&gt;Now that our API is built, how do we test it? There is a useful tool called Postman that allows us to make http requests through a user interface. &lt;a target = &quot;_blank&quot; href =&quot;https://www.postman.com/&quot; rel=&quot;noopener noreferrer&quot; &gt;Download it&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a quick video of me testing it.
&lt;img src=&quot;/791cf9feb632ec5d96a3acbabdc9e9ad/api-testing.gif&quot; alt=&quot;Todo app API testing&quot;&gt;&lt;/p&gt;
&lt;h2&gt;What’s Next&lt;/h2&gt;
&lt;p&gt;The next step is to create the react front end and connect it with the API backend. Here is the next segment of this tutorial &lt;a target=&quot;_blank&quot; href=&quot;/todo-app-react-frontend/&quot; rel=&quot;noopener noreferrer&quot;&gt;Build A Todo App with React and Node Part 2 (Frontend)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This tutorial’s source code can be found on &lt;a href=&quot;https://github.com/htnguy/todo-app-tutorial.git&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;github&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Build A Todo App with React, MongoDB, ExpressJS, and NodeJS Part 2 (Frontend)]]></title><description><![CDATA[Welcome back. Congratulation on completing part 1 of the tutorial on how to create a todo app with React and NodeJS. In part 2, we will…]]></description><link>https://www.devsurvival.com/todo-app-react-frontend/</link><guid isPermaLink="false">https://www.devsurvival.com/todo-app-react-frontend/</guid><pubDate>Mon, 23 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;Welcome back. Congratulation on completing &lt;a target=&quot;_blank&quot; href=&quot;/todo-app-react-backend/&quot; ref=&quot;noopener noreferrer&quot;&gt;part 1&lt;/a&gt; of the tutorial on how to create a todo app with React and NodeJS.&lt;/p&gt;
&lt;p&gt;In part 2, we will create the react frontend and connect it to our API backend to &lt;code class=&quot;language-text&quot;&gt;GET, POST, UPDATE, and DELETE&lt;/code&gt; our todos.&lt;/p&gt;
&lt;h3&gt;Additional Packages&lt;/h3&gt;
&lt;p&gt;Before we can start coding, we have to install some additional packages to make this work.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Axios&lt;/strong&gt; - allows us to send http request from out react frontend to our todo API run &lt;code class=&quot;language-text&quot;&gt;npm install axios&lt;/code&gt; in the &lt;code class=&quot;language-text&quot;&gt;todo-frontend&lt;/code&gt; directory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cors&lt;/strong&gt; - allows cross domain http request. In other words, without enabling cors on the backend, even Axios will not able to send our request to the API. run &lt;code class=&quot;language-text&quot;&gt;npm install cors&lt;/code&gt; in the &lt;code class=&quot;language-text&quot;&gt;todo-backend&lt;/code&gt; directory, and then add the snippet below to the top of your &lt;code class=&quot;language-text&quot;&gt;index.js&lt;/code&gt; file in the root of &lt;code class=&quot;language-text&quot;&gt;todo-backend&lt;/code&gt; directory&lt;/li&gt;
&lt;/ol&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;4751768721530336000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const cors = require(&amp;quot;cors&amp;quot;)
app.use(cors())`, `4751768721530336000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; cors &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cors&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cors&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Almost There :)&lt;/h3&gt;
&lt;p&gt;Since the frontend for this application is pretty straight forward, we are going to make changes to two files: &lt;code class=&quot;language-text&quot;&gt;App.js&lt;/code&gt; and the &lt;code class=&quot;language-text&quot;&gt;APIHelper.js&lt;/code&gt; (we will have to create)&lt;/p&gt;
&lt;p&gt;Let’s create the &lt;code class=&quot;language-text&quot;&gt;APIHelper.js&lt;/code&gt; file in the &lt;code class=&quot;language-text&quot;&gt;src&lt;/code&gt; directory of the &lt;code class=&quot;language-text&quot;&gt;todo-frontend&lt;/code&gt; .&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;77610491183946960000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`touch APIHelper.js`, `77610491183946960000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;shell&quot;&gt;&lt;pre class=&quot;language-shell&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;touch&lt;/span&gt; APIHelper.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Copy the following code into the &lt;code class=&quot;language-text&quot;&gt;APIHelper.js&lt;/code&gt; file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;39499013426268730000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`import axios from &amp;quot;axios&amp;quot;

const API_URL = &amp;quot;http://localhost:3000/todos/&amp;quot;

async function createTodo(task) {
  const { data: newTodo } = await axios.post(API_URL, {
    task,
  })
  return newTodo
}

async function deleteTodo(id) {
  const message = await axios.delete(\`\${API_URL}\${id}\`)
  return message
}

async function updateTodo(id, payload) {
  const { data: newTodo } = await axios.put(\`\${API_URL}\${id}\`, payload)
  return newTodo
}

async function getAllTodos() {
  const { data: todos } = await axios.get(API_URL)
  return todos
}

export default { createTodo, deleteTodo, updateTodo, getAllTodos }`, `39499013426268730000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; axios &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;axios&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;API_URL&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;http://localhost:3000/todos/&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; newTodo &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;API_URL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    task&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; newTodo
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; message &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;API_URL&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;id&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; message
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; newTodo &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;API_URL&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;id&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; newTodo
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAllTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; todos &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; axios&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;API_URL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; todos
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; createTodo&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; deleteTodo&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; updateTodo&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; getAllTodos &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Let Me Explain&lt;/h4&gt;
&lt;p&gt;We have four functions that mimic our API &lt;code class=&quot;language-text&quot;&gt;createTodo, deleteTodo, updateTodo, getAllTodos&lt;/code&gt; .&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;createTodo(task)&lt;/code&gt;&lt;/strong&gt; - accepts a task and sends a post via &lt;code class=&quot;language-text&quot;&gt;axios.post&lt;/code&gt; to our &lt;code class=&quot;language-text&quot;&gt;API_URL&lt;/code&gt; and returns the newTodo. Note: axios stores the response of our requests in a field called &lt;code class=&quot;language-text&quot;&gt;data&lt;/code&gt;,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;deleteTodo(id)&lt;/code&gt;&lt;/strong&gt; - accepts an id and sends a delete request to our API.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;updateTodo&lt;/code&gt;&lt;/strong&gt; - accepts an id and a payload object contain fields that we want to update =&gt; &lt;code class=&quot;language-text&quot;&gt;payload= {completed: true}&lt;/code&gt; .It sends a &lt;code class=&quot;language-text&quot;&gt;PUT&lt;/code&gt; request to update the todo.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;getAllTodos&lt;/code&gt;&lt;/strong&gt; - fetching all the todos from our API via &lt;code class=&quot;language-text&quot;&gt;axios.get&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And we make all these functions accessible in other files using an export function &lt;code class=&quot;language-text&quot;&gt;export default { createTodo, deleteTodo, updateTodo, getAllTodos };&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;App.js&lt;/h4&gt;
&lt;p&gt;Copy the following code into your &lt;code class=&quot;language-text&quot;&gt;App.js&lt;/code&gt; file&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;72173443035294870000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`import React, { useState, useEffect } from &amp;quot;react&amp;quot;
import &amp;quot;./App.css&amp;quot;
import APIHelper from &amp;quot;./APIHelper.js&amp;quot;

function App() {
  const [todos, setTodos] = useState([])
  const [todo, setTodo] = useState(&amp;quot;&amp;quot;)

  useEffect(() =&gt; {
    const fetchTodoAndSetTodos = async () =&gt; {
      const todos = await APIHelper.getAllTodos()
      setTodos(todos)
    }
    fetchTodoAndSetTodos()
  }, [])

  const createTodo = async e =&gt; {
    e.preventDefault()
    if (!todo) {
      alert(&amp;quot;please enter something&amp;quot;)
      return
    }
    if (todos.some(({ task }) =&gt; task === todo)) {
      alert(\`Task: \${todo} already exists\`)
      return
    }
    const newTodo = await APIHelper.createTodo(todo)
    setTodos([...todos, newTodo])
  }

  const deleteTodo = async (e, id) =&gt; {
    try {
      e.stopPropagation()
      await APIHelper.deleteTodo(id)
      setTodos(todos.filter(({ _id: i }) =&gt; id !== i))
    } catch (err) {}
  }

  const updateTodo = async (e, id) =&gt; {
    e.stopPropagation()
    const payload = {
      completed: !todos.find(todo =&gt; todo._id === id).completed,
    }
    const updatedTodo = await APIHelper.updateTodo(id, payload)
    setTodos(todos.map(todo =&gt; (todo._id === id ? updatedTodo : todo)))
  }

  return (
    &lt;div className=&amp;quot;App&amp;quot;&gt;
      &lt;div&gt;
        &lt;input
          id=&amp;quot;todo-input&amp;quot;
          type=&amp;quot;text&amp;quot;
          value={todo}
          onChange={({ target }) =&gt; setTodo(target.value)}
        /&gt;
        &lt;button type=&amp;quot;button&amp;quot; onClick={createTodo}&gt;
          Add
        &lt;/button&gt;
      &lt;/div&gt;

      &lt;ul&gt;
        {todos.map(({ _id, task, completed }, i) =&gt; (
          &lt;li
            key={i}
            onClick={e =&gt; updateTodo(e, _id)}
            className={completed ? &amp;quot;completed&amp;quot; : &amp;quot;&amp;quot;}
          &gt;
            {task} &lt;span onClick={e =&gt; deleteTodo(e, _id)}&gt;X&lt;/span&gt;
          &lt;/li&gt;
        ))}
      &lt;/ul&gt;
    &lt;/div&gt;
  )
}

export default App`, `72173443035294870000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useState&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useEffect &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./App.css&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; APIHelper &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./APIHelper.js&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setTodos&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setTodo&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;fetchTodoAndSetTodos&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todos &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAllTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;fetchTodoAndSetTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;createTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;please enter something&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; task &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; task &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Task: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;todo&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; already exists&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newTodo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newTodo&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;deleteTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; _id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; i &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; id &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;updateTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; payload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      completed&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;todo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_id &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;completed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; updatedTodo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;todo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_id &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; id &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; updatedTodo &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;todo-input&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; target &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;createTodo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
          Add
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;

      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; task&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; completed &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
            &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
            &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
            &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;completed &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;completed&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;task&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; App&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Let Me Explain&lt;/h4&gt;
&lt;p&gt;We start by creating two states: &lt;code class=&quot;language-text&quot;&gt;todo&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt;. States are like information about your components. &lt;code class=&quot;language-text&quot;&gt;todo&lt;/code&gt; will store the user input when creating a new todo and &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt; will store all of our todos.&lt;/p&gt;
&lt;p&gt;Let’s see what the component looks like on paper.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;48939644669826785000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`return (
  &lt;div className=&amp;quot;App&amp;quot;&gt;
    &lt;div&gt;
      &lt;input
        id=&amp;quot;todo-input&amp;quot;
        type=&amp;quot;text&amp;quot;
        value={todo}
        onChange={({ target }) =&gt; setTodo(target.value)}
      /&gt;
      &lt;button type=&amp;quot;button&amp;quot; onClick={createTodo}&gt;
        Add
      &lt;/button&gt;
    &lt;/div&gt;

    &lt;ul&gt;
      {todos.map(({ _id, task, completed }, i) =&gt; (
        &lt;li
          key={i}
          onClick={e =&gt; updateTodo(e, _id)}
          className={completed ? &amp;quot;completed&amp;quot; : &amp;quot;&amp;quot;}
        &gt;
          {task} &lt;span onClick={e =&gt; deleteTodo(e, _id)}&gt;X&lt;/span&gt;
        &lt;/li&gt;
      ))}
    &lt;/ul&gt;
  &lt;/div&gt;
)`, `48939644669826785000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;todo-input&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; target &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;createTodo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        Add
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; task&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; completed &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;completed &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;completed&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;task&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To keep things simple we have a text input, a button for submitting the input, and a list.&lt;/p&gt;
&lt;p&gt;The text input has an &lt;code class=&quot;language-text&quot;&gt;onChange&lt;/code&gt; event handler for handling user inputs. When the user clicks the &lt;code class=&quot;language-text&quot;&gt;Add&lt;/code&gt; button, the &lt;code class=&quot;language-text&quot;&gt;onClick&lt;/code&gt; event handler is triggered- createTodo() is invoked.&lt;/p&gt;
&lt;h4&gt;Creating Todo&lt;/h4&gt;
&lt;p&gt;lets look at what the &lt;code class=&quot;language-text&quot;&gt;createTodo&lt;/code&gt; function does&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;35984211242420482000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const createTodo = async e =&gt; {
  e.preventDefault()
  if (!todo) {
    // check if the todo is empty
    alert(&amp;quot;please enter something&amp;quot;)
    return
  }
  if (todos.some(({ task }) =&gt; task === todo)) {
    // check if the todo already exists
    alert(\`Task: \${todo} already exists\`)
    return
  }
  const newTodo = await APIHelper.createTodo(todo) // create the todo
  setTodos([...todos, newTodo]) // adding the newTodo to the list
}`, `35984211242420482000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;createTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// check if the todo is empty&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;please enter something&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; task &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; task &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// check if the todo already exists&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Task: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;todo&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; already exists&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newTodo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// create the todo&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newTodo&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// adding the newTodo to the list&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Overall, it validates the input, create the todo using the &lt;code class=&quot;language-text&quot;&gt;APIHelper.js&lt;/code&gt; we created, and then add it to the list of &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Displaying the Todos&lt;/h3&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;94877877186206910000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;ul&gt;
  {todos.map(({ _id, task, completed }, i) =&gt; (
    &lt;li
      key={i}
      onClick={e =&gt; updateTodo(e, _id)}
      className={completed ? &amp;quot;completed&amp;quot; : &amp;quot;&amp;quot;}
    &gt;
      {task} &lt;span onClick={e =&gt; deleteTodo(e, _id)}&gt;X&lt;/span&gt;
    &lt;/li&gt;
  ))}
&lt;/ul&gt;`, `94877877186206910000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; task&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; completed &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;completed &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;completed&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;task&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We are mapping over the list of &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt; and creating a new list item with &lt;code class=&quot;language-text&quot;&gt;li&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;How do we load the todos when the page loads? React offers a useful function call &lt;code class=&quot;language-text&quot;&gt;useEffect&lt;/code&gt; which is called after the component is rendered&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;73431133944995340000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`useEffect(() =&gt; {
  const fetchTodoAndSetTodos = async () =&gt; {
    const todos = await APIHelper.getAllTodos()
    setTodos(todos)
  }
  fetchTodoAndSetTodos()
}, [])`, `73431133944995340000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;fetchTodoAndSetTodos&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; todos &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAllTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;fetchTodoAndSetTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;we create an &lt;code class=&quot;language-text&quot;&gt;async function&lt;/code&gt; called &lt;code class=&quot;language-text&quot;&gt;fetchTodoAndSetTodos&lt;/code&gt; which call the &lt;code class=&quot;language-text&quot;&gt;APIHelper&lt;/code&gt;’s &lt;code class=&quot;language-text&quot;&gt;getAllTodos&lt;/code&gt; function to fetch all the todos. It then sets the &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt; state of the component to include these todos.&lt;/p&gt;
&lt;h4&gt;Marking Todo As Completed&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;48764024191211060000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`;(
  &lt;li
    key={i}
    onClick={e =&gt; updateTodo(e, _id)}
    className={completed ? &amp;quot;completed&amp;quot; : &amp;quot;&amp;quot;}
  &gt;
    {task} &lt;span onClick={e =&gt; deleteTodo(e, _id)}&gt;X&lt;/span&gt;
  &lt;/li&gt;
)\`\``, `48764024191211060000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;completed &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;completed&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;task&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When the task is completed we add the class &lt;code class=&quot;language-text&quot;&gt;completed&lt;/code&gt;. you can declare this css class in a separate file. &lt;code class=&quot;language-text&quot;&gt;create-react-app&lt;/code&gt; provides an &lt;code class=&quot;language-text&quot;&gt;App.css&lt;/code&gt; file for this purpose.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;39041487714500780000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`.completed {
  text-decoration: line-through;
  color: gray;
}`, `39041487714500780000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.completed&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;text-decoration&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; line-through&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; gray&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice each todo item (&lt;code class=&quot;language-text&quot;&gt;&amp;lt;li onClick={updateTodo}&amp;gt;{task}&amp;lt;/li&amp;gt;&lt;/code&gt;) has an &lt;code class=&quot;language-text&quot;&gt;onClick&lt;/code&gt; event handler. When we click an &lt;code class=&quot;language-text&quot;&gt;li&lt;/code&gt; we trigger the &lt;code class=&quot;language-text&quot;&gt;updateTodo&lt;/code&gt; function.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;65177503180145390000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const updateTodo = async (e, id) =&gt; {
  e.stopPropagation()
  const payload = {
    completed: !todos.find(todo =&gt; todo._id === id).completed,
  }
  const updatedTodo = await APIHelper.updateTodo(id, payload)
  setTodos(todos.map(todo =&gt; (todo._id === id ? updatedTodo : todo)))
}`, `65177503180145390000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;updateTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; payload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    completed&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;todo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_id &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;completed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; updatedTodo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;todo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_id &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; id &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; updatedTodo &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; todo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;e&lt;/code&gt; is the event object on which we invoked &lt;code class=&quot;language-text&quot;&gt;e.stopPropagation()&lt;/code&gt; to prevent the click event from propagating to the parent element. Next, we find the todo in the list of &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt; and flip its completed status(&lt;code class=&quot;language-text&quot;&gt;completed = true =&amp;gt; !completed == false&lt;/code&gt;) . We add this new &lt;code class=&quot;language-text&quot;&gt;completed&lt;/code&gt; status to the &lt;code class=&quot;language-text&quot;&gt;payload&lt;/code&gt; object. we then call &lt;code class=&quot;language-text&quot;&gt;APIHelper.updateTodo&lt;/code&gt; and pass in the &lt;code class=&quot;language-text&quot;&gt;id&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;payload&lt;/code&gt; of the todo.&lt;/p&gt;
&lt;p&gt;The next bit of code is a little confusing. we call &lt;code class=&quot;language-text&quot;&gt;todos.map&lt;/code&gt; which maps over the array and return a new array. With each iteration we are check if the id matches. If it matches, then we return the &lt;code class=&quot;language-text&quot;&gt;updatedTodo&lt;/code&gt; which is effectively updating the todo. Otherwise, we return the original todo and leave it unchanged.&lt;/p&gt;
&lt;h4&gt;Deleting a Todo&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;82121034746921900000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`&lt;li
  key={i}
  onClick={e =&gt; updateTodo(e, _id)}
  className={completed ? &amp;quot;completed&amp;quot; : &amp;quot;&amp;quot;}
&gt;
  {task} &lt;span onClick={e =&gt; deleteTodo(e, _id)}&gt;X&lt;/span&gt;
&lt;/li&gt;`, `82121034746921900000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;completed &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;completed&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;task&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice how we have a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;span onClick={DeleteTodo(e, _id)}&amp;gt;X&amp;lt;/span&amp;gt;&lt;/code&gt; next to the task. When this span is clicked, it triggers the &lt;code class=&quot;language-text&quot;&gt;deleteTodo&lt;/code&gt; function that will delete the todo.&lt;/p&gt;
&lt;p&gt;Here is the function for deleting the todo.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;15290081754595586000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`const deleteTodo = async (e, id) =&gt; {
  try {
    e.stopPropagation()
    await APIHelper.deleteTodo(id)
    setTodos(todos.filter(({ _id: i }) =&gt; id !== i))
  } catch (err) {}
}`, `15290081754595586000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;deleteTodo&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; APIHelper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deleteTodo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setTodos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;todos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; _id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; i &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; id &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;we call &lt;code class=&quot;language-text&quot;&gt;APIHelper.deleteTodo&lt;/code&gt; and pass in the id of the todo we want to delete. If you refresh the page, the todo will be deleted. What if you were lazy and did feel like refreshing or you didn’t know better? Well, we have to remove it manually from the &lt;code class=&quot;language-text&quot;&gt;todos&lt;/code&gt; state. We remove it by calling &lt;code class=&quot;language-text&quot;&gt;todos.filter&lt;/code&gt; which will filter out the todo with the id we just deleted.&lt;/p&gt;
&lt;h3&gt;Show Time&lt;/h3&gt;
&lt;p&gt;Here is a quick demo:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/6fc9ef89612cae0d7c982aa70a8223df/todo-app-showtime.gif&quot; alt=&quot;Todo app show time&quot;&gt;&lt;/p&gt;
&lt;p&gt;This tutorial’s source code can be found on &lt;a href=&quot;https://github.com/htnguy/todo-app-tutorial.git&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;github&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Pointers in C and C++]]></title><description><![CDATA[Ahh the good old pointers. The first topic in most computer science program that most students struggle with. I admit. Not everyone uses…]]></description><link>https://www.devsurvival.com/pointers-with-c/</link><guid isPermaLink="false">https://www.devsurvival.com/pointers-with-c/</guid><pubDate>Sat, 21 Mar 2020 23:46:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 211px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/c920fffefc76be6aab60b4ed9692be58/4050c/pointers.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 113.49693251533743%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAIAAACEf/j0AAAACXBIWXMAAAsSAAALEgHS3X78AAACgUlEQVQ4y41UyW4TQRTsv+fEjQtCCCniQKRwIOAAsUM89myesR3vS7zLduKYhMT77uK9nobYQyLReofeqqve1gI0+tf4eIDLPM83G/zPWK+wWgnc3iASwnyOuIlamQ+22717yyVmE8ymyiZj3swmcfhO4NULVEu8Hj7g9Ut0mnv4+QzBAC5cxG24ljKaW1Hk0wKtKmJhvldIoZT1yxs8wNafc0fgro+EwdNyFu2GX/ZwwFTeK40qWnW2Zg2dFsYjCY7Lt4mWdjkYa+bxqAgck0+bYbgmKkUUM6hXcHaC9292wJc5v8Me2DF54hgY3D+e3v1Es7oDLqahnfKrpTzKBRRzWCxIm2KO6bj/pZz3bLuV4KQ8no4Z2aihXkW3g3CQnVzMFTNpJrclteLfbGSeY5p8cq2ket5eFtGoMDj4BYsZO+mBd5wSXADaVyRMuFE4GpwIbIqNjpMjdFt8JZNA/oLj9E+2hKo1ens5lzbzXyKmxZJLcDR6tOGQkiL2lHiT6w6SFhIWel1eUtmGQ3AsxExlrg0jgoQj9kkkWP/BrdLrIHouk6Sza75BATIiwovbjkR5e7XiUFkyhcY5KgVcdbiq2k102wxZLelUKDaVPRlwO8Jn1BJmlJc3V9xDFLB8CuUcPh2ykO2GTgV3GeVzV7ZrKLAVfSIiVOrUlTRncPgbPrzlwmg10KyzfT9mCX/BXEzSlC4dk9EfMKm67SOT5HosZJFLKyHTiWpGHzM1s8dsG+LZj4Zu6Jq/T8YDnH7mgqfN04BA0kbKhRZikWZEGTUD7SSdR7CXET3IAfOGfiYYeXSgXPLZk8PS+D/o96gcBMOo9J4cvp9QbW6IE6EANexv0gAT0gLt8bIAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Pointers&quot;
        title=&quot;Pointers&quot;
        src=&quot;/static/c920fffefc76be6aab60b4ed9692be58/4050c/pointers.png&quot;
        srcset=&quot;/static/c920fffefc76be6aab60b4ed9692be58/222b7/pointers.png 163w,
/static/c920fffefc76be6aab60b4ed9692be58/4050c/pointers.png 211w&quot;
        sizes=&quot;(max-width: 211px) 100vw, 211px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Ahh the good old pointers. The first topic in most computer science program that most students struggle with. I admit. Not everyone uses pointers in their day to day programming life. In fact, I have never had to use pointers during my internship at several companies. However, after taking operating systems and several critical computer science courses, I realized that they all share one common enemy or ally depending on your perspective: &lt;strong&gt;Pointer&lt;/strong&gt;. Its annoying persistence to show up in my education career has forced me to reconsider its significance and relevance in the developer world.&lt;/p&gt;
&lt;p&gt;Although most developers will never have to use it, it is good to know that it exists and the role it serves in your everyday computing life. Heres why. Every application you write will consume memory. That is an undeniable fact that you just have to accept. Anything that touches memory will inherently involve using pointers. Some may argue that even the most complex python program does not include a single pointer. In reality, the python language has taken care of that work for you, so you don’t have to. spoiled bastard 😙&lt;/p&gt;
&lt;h3&gt;What is a pointer?&lt;/h3&gt;
&lt;p&gt;A pointer is just a generic name given to a variable that holds the memory address of something. The analogy here is that a pointer is the street sign that &lt;strong&gt;points&lt;/strong&gt; *no pun intended, you to the location where you want to go.&lt;/p&gt;
&lt;h4&gt;Declaring a Pointer&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;28043070803798774000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int *int_pointer;
char *char_pointer;
float *float_pointer;
struct Person *person_pointer;`, `28043070803798774000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;int_pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;char_pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;float_pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;person_pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The general format of a pointer is the &lt;code class=&quot;language-text&quot;&gt;[Data Type] *[Variable Name]&lt;/code&gt;. the &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt; indicates that the variable of that specific data type is a pointer.&lt;/p&gt;
&lt;h4&gt;Initializing a Pointer&lt;/h4&gt;
&lt;p&gt;Pointers store memory addresses, but how do we get the memory address of something? C has a special built in operator &lt;code class=&quot;language-text&quot;&gt;&amp;amp;&lt;/code&gt; that returns the address of any value.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;57437464593708380000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int value =2;
int *location_of_value = &amp;value;`, `57437464593708380000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;location_of_value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;here the variable &lt;code class=&quot;language-text&quot;&gt;value&lt;/code&gt; contains 2, and we retrieved the location of this “2” in memory using &lt;code class=&quot;language-text&quot;&gt;&amp;amp;value&lt;/code&gt; and assigned it to the pointer &lt;code class=&quot;language-text&quot;&gt;*location_of_value&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;Retrieve The Value From The Pointer&lt;/h4&gt;
&lt;p&gt;Given a pointer, to retrieve the value from the pointer, we have to dereference it using &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt;. In other words, once we see the street sign, how do we travel to get to the location?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;92819886666760240000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int value =2;
int *location_of_value = &amp;value;
int retrieved_value=*location_of_value; // retrieved_value == 2`, `92819886666760240000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;location_of_value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; retrieved_value&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;location_of_value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// retrieved_value == 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are retrieving the value from the location using &lt;code class=&quot;language-text&quot;&gt;*location_of_value&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Special Cases of pointers&lt;/h3&gt;
&lt;h4&gt;Arrays&lt;/h4&gt;
&lt;p&gt;Arrays of any data type is a special case of pointer usage where the variable associated with the array is the pointer to the first element of the array. Sound confusing? So was I.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9057417843001603000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int arr[3]= {1,2,3};
printf(&amp;quot;%p\n&amp;quot;, arr);`, `9057417843001603000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%p\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;the &lt;code class=&quot;language-text&quot;&gt;%p&lt;/code&gt; in the printf statement is used to print the address of pointers. Here when we print the address of the pointer and pass &lt;code class=&quot;language-text&quot;&gt;arr&lt;/code&gt;, we expect &lt;code class=&quot;language-text&quot;&gt;arr&lt;/code&gt; to contain an address. what is stored at this address?&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;91661605565620630000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int arr[3]= {1,2,3};
printf(&amp;quot;%d\n&amp;quot;, *arr);// prints 1`, `91661605565620630000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;// prints 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;when we deference this address stored in &lt;code class=&quot;language-text&quot;&gt;arr&lt;/code&gt; we get the value 1, which is the first element in the array. To get the next value in the array, we just tell the pointer to move to the next address.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;5200323486059899000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int arr[3]= {1,2,3};
printf(&amp;quot;%p\n&amp;quot;, arr);// prints 1
arr++;
printf(&amp;quot;%d\n&amp;quot;, *arr); // prints 2`, `5200323486059899000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%p\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;// prints 1&lt;/span&gt;
arr&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When we increment the pointer we are telling it to move over by &lt;code class=&quot;language-text&quot;&gt;sizeof(int)&lt;/code&gt; bytes which is the memory address of the next element in the array.&lt;/p&gt;
&lt;h4&gt;Strings&lt;/h4&gt;
&lt;p&gt;There is actually no such things as a string in C. A string is just an array of char.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;95416829523199180000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(` char str[10]= &amp;quot;Hi There\0&amp;quot;;
 printf(&amp;quot;%c&amp;quot;, *str); // prints &amp;quot;H&amp;quot;`, `95416829523199180000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt; &lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hi There\0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints &quot;H&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here &lt;code class=&quot;language-text&quot;&gt;str&lt;/code&gt; points to the memory address of the first character in the sequence of char. To print the entire string&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;59107246113508794000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`char str[10] = &amp;quot;Hi There \0&amp;quot;;
while(str){
    printf(&amp;quot;%c&amp;quot;, *str);
    str++;
}
// prints &amp;quot;Hi There&amp;quot;`, `59107246113508794000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hi There \0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    str&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// prints &quot;Hi There&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Classes and Structs&lt;/h4&gt;
&lt;p&gt;structs and classes are a little different in their dereferencing step&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;89579883594205540000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`typedef struct person{
    char* first_name;
    int age;

}person;
.
.
.
char name[10] = &amp;quot;Bob&amp;quot;;
person p1 = {name, 21};
person *p1_location = &amp;p1;
printf(&amp;quot;First name:%s age:%d \n&amp;quot;, p1_location-&gt;first_name, (*p1_location).age);`, `89579883594205540000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; first_name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; age&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
person p1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
person &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;p1_location &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;p1&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;First name:%s age:%d \n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; p1_location&lt;span class=&quot;token operator&quot;&gt;-&gt;&lt;/span&gt;first_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;p1_location&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To access the member fields of the person struct given a &lt;code class=&quot;language-text&quot;&gt;struct person *&lt;/code&gt;, there are two ways.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;p1_location-&amp;gt;firstname&lt;/code&gt;
-Dereference and access in one operator&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;(*p1_location).firstname&lt;/code&gt;
-Dereference first and then access&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Memory Allocation and pointers&lt;/h4&gt;
&lt;p&gt;Pointers are also used when allocating block of memories&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;53155813775558910000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`char *str_ptr = malloc(sizeof(char) * 10)
strcpy(str_ptr, &amp;quot;hello\0&amp;quot;);
printf(&amp;quot;%s\n&amp;quot;, str_ptr) // prints &amp;quot;hello&amp;quot;`, `53155813775558910000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;str_ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;malloc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;strcpy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str_ptr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello\0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;%s\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; str_ptr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// prints &quot;hello&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we are asking &lt;code class=&quot;language-text&quot;&gt;malloc&lt;/code&gt; to give us a block of memory that can store 10 characters and return to us the starting memory address of the first location.&lt;/p&gt;
&lt;h3&gt;Final Note&lt;/h3&gt;
&lt;p&gt;This list of examples is not an exhaustive list of ways that pointers are applied, but it is a good starting point for those who are new to memory addresses and pointers. Peace Out :)&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Synchronization and Critical Section Problem]]></title><description><![CDATA[What is Synchronization? Synchronization in the context of multi-programming or multi-threaded programming is the process that coordinates…]]></description><link>https://www.devsurvival.com/synchronization-and-critical-section/</link><guid isPermaLink="false">https://www.devsurvival.com/synchronization-and-critical-section/</guid><pubDate>Sat, 21 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/175fc14baeaf83230f166f169b43e704/0f98f/synchronization-icon.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 100%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAMCBQT/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHoePeDsJC0guD/xAAcEAABBAMBAAAAAAAAAAAAAAACAQMEEwAQEjL/2gAIAQEAAQUCkyKsvcDALoZXQnIfR4GPBChJUOv/xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/AR//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/AR//xAAgEAACAgEDBQAAAAAAAAAAAAABEQACEhAhURMxQVJx/9oACAEBAAY/ApXMWrl7biOZANHJczp1oye78R8lxWDm7P06f//EAB8QAQACAgEFAQAAAAAAAAAAAAEAESFRYRAxcYGRof/aAAgBAQABPyEBQ1tC3wRa7tp7MSmpT2TTKOjHgVT8r9gl1NOIeWDKiYg6leAmf42Tp//aAAwDAQACAAMAAAAQQAc8/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAwEBPxAf/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPxAf/8QAHxABAAEFAAMBAQAAAAAAAAAAAREAITFBUWFxgRCR/9oACAEBAAE/EEDkBcBcA2ncuDTNSsEugcsCT4xxojXMrbgwn9oT0RYMIgndzsS7RPgEOSnRHaUaBsgWBPsJ+1c4Eg6ejp80RGAMgU+lh+/n/9k=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Synchronization&quot;
        title=&quot;Synchronization&quot;
        src=&quot;/static/175fc14baeaf83230f166f169b43e704/6aca1/synchronization-icon.jpg&quot;
        srcset=&quot;/static/175fc14baeaf83230f166f169b43e704/d2f63/synchronization-icon.jpg 163w,
/static/175fc14baeaf83230f166f169b43e704/c989d/synchronization-icon.jpg 325w,
/static/175fc14baeaf83230f166f169b43e704/6aca1/synchronization-icon.jpg 650w,
/static/175fc14baeaf83230f166f169b43e704/7c09c/synchronization-icon.jpg 975w,
/static/175fc14baeaf83230f166f169b43e704/01ab0/synchronization-icon.jpg 1300w,
/static/175fc14baeaf83230f166f169b43e704/0f98f/synchronization-icon.jpg 1920w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;What is Synchronization?&lt;/h3&gt;
&lt;p&gt;Synchronization in the context of multi-programming or multi-threaded programming is the process that coordinates access and manipulation of share data. If you have read some of my &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/multi-threaded-programming/&quot;&gt;previous&lt;/a&gt; blogs, you would have noticed that we occasionally run into an issue where two threads are trying to access the same share data at the same time. To deal with this common issue we have to learn how to synchronize access of these share datas.&lt;/p&gt;
&lt;h3&gt;Critical Section Problem&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;critical&lt;/strong&gt; section is anywhere in code were one thread is accessing share data that could potentially be accessed by another thread. Synchronization will attempt to prevent two threads from accessing the critical section/shared data at the same time.&lt;/p&gt;
&lt;h4&gt;Implementing Synchronization&lt;/h4&gt;
&lt;p&gt;There are many ways to implement synchronization but they all follow this general pseudo code:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;// Some code
.
.
.
acquire_access
    // critical section
    // access and update shared data
release_access
.
.
.
// some code&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;acquiring access will cause the thread to wait if access is being used by another thread or it will successfully acquire the access if no other thread is using it. Once the thread finished, it releases the access so another thread can use it.&lt;/p&gt;
&lt;p&gt;The most simple implementation of this uses what is called &lt;code class=&quot;language-text&quot;&gt;Semaphore&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;76718984483550220000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sem_t mutex;
sem_init(&amp;mutex, 0, 1);
int critical_section = 0;

//thread 1

sem_wait(&amp;mutex);
critical_section ++;
sem_post(&amp;mutex);

//thread 2

sem_wait(&amp;mutex);
critical_section ++;
sem_post(&amp;mutex);`, `76718984483550220000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;sem_t mutex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sem_init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; critical_section &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//thread 1&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;sem_wait&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
critical_section &lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sem_post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//thread 2&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;sem_wait&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
critical_section &lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sem_post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Closer Look&lt;/h4&gt;
&lt;p&gt;we start by declaring a mutex variable. we initialize it with &lt;code class=&quot;language-text&quot;&gt;sem_init(&amp;amp;mutex, 0, 1)&lt;/code&gt; .The first parameter is the semaphore that we are trying to initialize, the &lt;code class=&quot;language-text&quot;&gt;0&lt;/code&gt; allows the semaphore to be shared between the threads, and the &lt;code class=&quot;language-text&quot;&gt;1&lt;/code&gt; is the value with which we want to initialize the &lt;code class=&quot;language-text&quot;&gt;sem_t mutex&lt;/code&gt; with. &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;http://man7.org/linux/man-pages/man3/sem_init.3.html&quot;&gt;learn more &lt;/a&gt;. Always initialize a semaphore to a positive number, I will explain why a little bit later.&lt;/p&gt;
&lt;p&gt;the snippet for &lt;code class=&quot;language-text&quot;&gt;thread 1&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;thread 2&lt;/code&gt; is very similar. We invoke &lt;code class=&quot;language-text&quot;&gt;sem_wait(&amp;amp;mutex)&lt;/code&gt; which is equivalent to acquire access. here is the pseudo code of how this function work&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;28353594906314904000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sem_wait(semaphore){
    if semaphore greater than 0
        semaphore -1
        return;
    else
        wait/sleep
}`, `28353594906314904000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sem_wait&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;semaphore&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; semaphore greater than &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
        semaphore &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
        wait&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;sleep
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Based on the code above, the semaphore has to be initialized to a positive number for even the first thread to access the critical section. When the first thread access the critical section, &lt;code class=&quot;language-text&quot;&gt;mutex = 1&lt;/code&gt; , calling &lt;code class=&quot;language-text&quot;&gt;sem_wait&lt;/code&gt; will decrement the mutex and &lt;code class=&quot;language-text&quot;&gt;mutex = 0&lt;/code&gt; and return. First thread is allow to enter critical section.&lt;/p&gt;
&lt;p&gt;While first thread is accessing critical section, another thread attempts to go into the critical section, it calls &lt;code class=&quot;language-text&quot;&gt;sem_wait(&amp;amp;mutex)&lt;/code&gt;, but &lt;code class=&quot;language-text&quot;&gt;mutex= 0&lt;/code&gt; so it is put to sleep or forced to wait.&lt;/p&gt;
&lt;p&gt;The first one finished using the critical section and call &lt;code class=&quot;language-text&quot;&gt;sem_post(&amp;amp;mutex)&lt;/code&gt; which is equivalent to release access. here is the pseudo code for &lt;code class=&quot;language-text&quot;&gt;sem_post&lt;/code&gt;.&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;50764965449130340000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`sem_post(semaphore){
    semaphore + 1
    wake up the first thread in line to access the critical section
}`, `50764965449130340000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sem_post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;semaphore&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    semaphore &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
    wake up the first thread in line to access the critical section
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After the first thread calls &lt;code class=&quot;language-text&quot;&gt;sem_post(&amp;amp;mutext)&lt;/code&gt;, the second thread wakes up and enter the critical section and the process repeats.&lt;/p&gt;
&lt;h3&gt;Final Note&lt;/h3&gt;
&lt;p&gt;If you want to get into multi-threaded programming, understanding of this concept is crucial.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Multi-threaded Programming in C]]></title><description><![CDATA[What is Multi-threaded Programming?  Multi threaded programming is a design approach that splits work into smaller units of work and…]]></description><link>https://www.devsurvival.com/multi-threaded-programming/</link><guid isPermaLink="false">https://www.devsurvival.com/multi-threaded-programming/</guid><pubDate>Sat, 21 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;h3&gt;What is Multi-threaded Programming?&lt;/h3&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 650px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/924e91783330c598e566e27d226701b5/48ca3/Multithreaded_process.svg.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 94.47852760736197%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAAsSAAALEgHS3X78AAADkklEQVQ4y3WUWUhUYRTH72jFUFmamjNqabYgZJtUilC0WC89VM/mQ0T0EEYZvRQYQpkPQQ8FbrglOjlWLqjZmEvNuExj7ubC0IYtRmir2Ny59/Q/d+YOV6sPDt+Z7/vO7/t/554zguAdO3bsEfz9Fym+Xr80GJYcHh69zmCIWh0aGhEeFbUpMiTEGBkbG+/PZ1atChPKy/uEf47TpzNUV+edV8A2wDbCDsKSYQmwWN4kIj/hf+PEiYvKHBeXoMNBwXu7MSvLdK68vNd8//6otarqpa2srMd8/XpFWkBAUJgXKkCxKmA9bJEPGh+/V90QMjPvptfVvf46MkI0MUE0Pu4x9oeHiWprX81cvVp8boGurbDFiqfmzQsr7OsjGhwkstlmRbtdFB0Oye1wyO6Ojlmxq+u3yNAXL4igNk8DjPMBe3pISfKNG5UZzc2fyWTqd927NyjhmWS1/pARLPf2kmyxTMnYI7N5WHrwYMzFZ6H0CscuXx64zQfksX//8c2NjZPi6ChRc/OUVFJip4EBkqGMVGMwLucL+Lc0NETU0PDOtW/fsRjOodEYpfcBb99uusUwKHE9e/adSkvtaiABQlow9uXnzyVed42NEd25Y7kGxJqzZ7OWqDy/ysqhXt7EQTerQO58MC2Q85ub20qtrdOcBjeLMJkG7FxeQUGhBlRdrIBCXfnw4fg0PwEfQEKgrAUtBObktFBb2wwDlWfX17+dBHCnTqeLBvCIkJh4OLC6euIHb0KhNk9/KeT1nJwn1N7+zQd89Oj9BwCTYEZAk5ROwxd1ct0hQOLn1NQ4FTULFQJC+HiEEuKLJY5B7Bh3EMrvABQqQKGoqNPMOQRE5HIoKHgqa4FapViXPb4kcsEXFtpK+aOgg3ZiNijAtLTso93dLsITxKamjzIOyf39XDbSPIWcDs4x1vlCLnQ6f/7mISDWpqSkezpE7d/8/KdNb94QoYDnoJgAJE+wrM5eZco853QS5eW1NXAs1G3B5CmbM2cy/byLRnTIa+5ZqHVxu3EBqzCPL7m5VhlWUdHvRN7CvO273Qfkgb5UoBERMZHFxV02dAlxTrmnWSkb+7zGPlLSjn+acE0vR+v1yzye1fpTmbOzq3z/cZcv557C31WnxfLpa0vLFzfb48efZsrKHB3YO6meQ5GrMbmwRMXbteuAYLP9mvd8dQQHGzjZCSkpF3YHBoas0e6lpl7Snj2mfuE/GusDHxixgEMAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Multi-threaded Programming&quot;
        title=&quot;Multi-threaded Programming&quot;
        src=&quot;/static/924e91783330c598e566e27d226701b5/a6d36/Multithreaded_process.svg.png&quot;
        srcset=&quot;/static/924e91783330c598e566e27d226701b5/222b7/Multithreaded_process.svg.png 163w,
/static/924e91783330c598e566e27d226701b5/ff46a/Multithreaded_process.svg.png 325w,
/static/924e91783330c598e566e27d226701b5/a6d36/Multithreaded_process.svg.png 650w,
/static/924e91783330c598e566e27d226701b5/e548f/Multithreaded_process.svg.png 975w,
/static/924e91783330c598e566e27d226701b5/48ca3/Multithreaded_process.svg.png 1084w&quot;
        sizes=&quot;(max-width: 650px) 100vw, 650px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Multi threaded programming is a design approach that splits work into smaller units of work and distribute them among a collection of workers or threads that can solve the individual job concurrently. Imagine that you and your friends are trying to make a pizza. It would not make sense for everyone to make the dough and then make the sauce and then cook it. Instead, one person can make the dough while someone else can make the sauce and preheat the oven.&lt;/p&gt;
&lt;h3&gt;Thread vs Process&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Process&lt;/strong&gt; - When you are running any program, you are in fact running a process. For instance, you downloaded an application on your computer. It is sitting idling on your computer(like a lot of things we download and never use), it is not a process. When you open the application and it is actively running woahla! It becomes a process. Note: you can have more than one process of a program.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Thread&lt;/strong&gt; - A process will always have one thread commonly called the main or parent thread. However, a process can have more than one thread. A thread that is created in the main thread is called the child thread.&lt;/p&gt;
&lt;p&gt;So what happens when you create a thread? Thread creation will usually accepts a routine or function that will get invoked when the thread execution begins. When the child thread is executing the function/routine, the parent thread will continues execution unless a wait is invoked.&lt;/p&gt;
&lt;h3&gt;Memory Space&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;“Memory… is the diary that we all carry about with us.” ~ Oscar Wilde&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;All programs consume memory or space (RAM)&lt;/li&gt;
&lt;li&gt;A Process has its own memory space&lt;/li&gt;
&lt;li&gt;One process can not access another process’s memory space - else it would cause corruption or the common segmentation fault (sound familiar? )&lt;/li&gt;
&lt;li&gt;The memory space of a process can grow and shrink based on the need of the program.&lt;/li&gt;
&lt;li&gt;a section is a segment of a process’s address/memory space&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Data&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;Global Variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code/Text&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;Source Code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Heap&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;Dynamic Memory Allocation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stack&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;Local variables, function invocation and parameters&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Multi-thread vs Multi-process&lt;/h3&gt;
&lt;p&gt;Maybe you have heard of multi-core or multi-processing. Multi-processing and multi-threading despite their similarities are different things. When you are following multi-processing, you are creating multiple processes of the same program. On the other hand, when you create a thread, you are creating multiple child threads within one process that can run different routine or functions at the same time. There are pros and cons of using each&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Multi-Process&lt;/th&gt;
&lt;th align=&quot;center&quot;&gt;Multi-thread&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;color: green&quot;&gt;each process has its own address space&lt;/span&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;color:green&quot;&gt; threads shares the same data, heap, and code section, but have their own stack and register&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;color: red&quot;&gt;Overhead for creating Process&lt;/span&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;Thread creation is fast&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;color: green&quot;&gt;Greater CPU utilization due to context switching(CPU switching from one process to another)&lt;/span&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;color:green&quot;&gt; Greater CPU Utilization due to switching between the threads&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;color: red&quot;&gt;Failure to synchronize threads can result in corrupt data&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Let’s Learn by Example&lt;/h3&gt;
&lt;p&gt;I will try to solidify some of these concepts through a programming example. The program is very simple and all it does is take two sets of numbers and compute their sum: A: [1,2,3] B: [4,2,6] =&gt; A+B = 1+2+3+4+2+6 = 18. Note: the order of addition does not matter&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;55347028684003700000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;pthread.h&gt;
#include &lt;semaphore.h&gt;
#include &lt;unistd.h&gt;


int sum = 0; // Global int to store the sum of the two arrays
sem_t mutex; // Synchronization Bit

void *add(void *arg){
    int *ptr = (int *) arg;
    while(*ptr != -1){
        sem_wait(&amp;mutex);
        sum += *ptr;
        printf(&amp;quot;value: %d sum %d\n&amp;quot;, *ptr,sum );
        sem_post(&amp;mutex);
        ptr++;
    }
    return NULL;
}

int main(int argc, char *args[]){
    int A[4] = {1,2,3, -1}; // -1 marks the end of array
    int B[4] = {4,2,6, -1};

    pthread_t t_a, t_b;
    sem_init(&amp;mutex, 0, 1);
    pthread_create(&amp;t_a , NULL, add, A);
    pthread_create(&amp;t_b, NULL, add, B);

    pthread_join(t_a, NULL);
    pthread_join(t_b, NULL);
    printf(&amp;quot;Total: %d\n&amp;quot;, sum);

    return 0;
}`, `55347028684003700000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token macro property&quot;&gt;#&lt;span class=&quot;token directive keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&amp;lt;stdio.h&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token macro property&quot;&gt;#&lt;span class=&quot;token directive keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&amp;lt;stdlib.h&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token macro property&quot;&gt;#&lt;span class=&quot;token directive keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&amp;lt;pthread.h&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token macro property&quot;&gt;#&lt;span class=&quot;token directive keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&amp;lt;semaphore.h&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token macro property&quot;&gt;#&lt;span class=&quot;token directive keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&amp;lt;unistd.h&gt;&lt;/span&gt;&lt;/span&gt;


&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; sum &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Global int to store the sum of the two arrays&lt;/span&gt;
sem_t mutex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Synchronization Bit&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; arg&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;sem_wait&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        sum &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;value: %d sum %d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;sum &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;sem_post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        ptr&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; argc&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; A&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// -1 marks the end of array&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; B&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    pthread_t t_a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; t_b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;sem_init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;t_a &lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; add&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; A&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;t_b&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; add&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; B&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_b&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Total: %d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sum&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Output&lt;/h4&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;9234691463256350000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`value: 1 sum 1
value: 4 sum 5
value: 2 sum 9
value: 6 sum 15
value: 2 sum 7
value: 3 sum 18
Total: 18`, `9234691463256350000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;value: &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
value: &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;
value: &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;
value: &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;15&lt;/span&gt;
value: &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;
value: &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;
Total: &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Closer Look&lt;/h3&gt;
&lt;p&gt;Look at the main function&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;85067645207298080000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int main(int argc, char *args[]){
    int A[4] = {1,2,3, -1}; // -1 marks the end of array
    int B[4] = {4,2,6, -1};

    pthread_t t_a, t_b;
    sem_init(&amp;mutex, 0, 1);
    pthread_create(&amp;t_a , NULL, add, A);
    pthread_create(&amp;t_b, NULL, add, B);

    pthread_join(t_a, NULL);
    pthread_join(t_b, NULL);
    printf(&amp;quot;Total: %d\n&amp;quot;, sum);

    return 0;
}`, `85067645207298080000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; argc&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; A&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// -1 marks the end of array&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; B&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    pthread_t t_a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; t_b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;sem_init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;t_a &lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; add&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; A&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;t_b&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; add&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; B&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_b&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Total: %d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sum&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We initialized two array A and B. Note the -1 indicates the end of array. and we declared two &lt;code class=&quot;language-text&quot;&gt;struct pthread_t&lt;/code&gt;: &lt;code class=&quot;language-text&quot;&gt;t_a&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;t_b&lt;/code&gt;. Then we called &lt;code class=&quot;language-text&quot;&gt;sem_init(&amp;amp;mutext)&lt;/code&gt;which will initialize the mutex struct, for now you don’t have to worry about &lt;code class=&quot;language-text&quot;&gt;sem_t mutex&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;sem_init(&amp;amp;mutex, 0, 1), sem_wait(&amp;amp;mutex), and sem_post(&amp;amp;mutex)&lt;/code&gt;. In short they are the key parts of &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/synchronization-and-critical-section/&quot;&gt;synchronization &lt;/a&gt;and protecting the &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/synchronization-and-critical-section/&quot;&gt;critical section problem&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We then call &lt;code class=&quot;language-text&quot;&gt;pthread_create(&amp;amp;t_a, NULL, add, A)&lt;/code&gt; which creates a new thread. the information pertaining to this thread is store in &lt;code class=&quot;language-text&quot;&gt;t_a&lt;/code&gt; and this thread will run the &lt;code class=&quot;language-text&quot;&gt;void *add(void *arg)&lt;/code&gt; function with array &lt;code class=&quot;language-text&quot;&gt;int A[4] = {1,2,3,-1}&lt;/code&gt;. Same thing for thread &lt;code class=&quot;language-text&quot;&gt;p_thread t_b and int B[4] = {4,2,6,-1}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;At this point all three threads are running concurrently. Wait. Why three? Remember, a process always has at least one thread: the parent thread. What if the parent thread finishes while the child threads are running? Welp, kids are no better than their parents, so sadly, the child threads will terminate when the parent terminates.&lt;/p&gt;
&lt;p&gt;To prevent this from happening, we use &lt;code class=&quot;language-text&quot;&gt;pthread_join( t_a, NULL)&lt;/code&gt; which will cause the parent thread to wait for the child thread &lt;code class=&quot;language-text&quot;&gt;t_a&lt;/code&gt; to terminate before continuing&lt;/p&gt;
&lt;h4&gt;So what does the child threads do?&lt;/h4&gt;
&lt;p&gt;The two child threads will each run this function &lt;code class=&quot;language-text&quot;&gt;void *add(void*args)&lt;/code&gt; to compute the sum. Note: the sum is a global variable. Where does global variables live in the memory space? In the &lt;strong&gt;data section&lt;/strong&gt;. Which sections are shared by threads? &lt;strong&gt;data&lt;/strong&gt;, heap, and code/text. My point is: both &lt;code class=&quot;language-text&quot;&gt;pthread_t t_a&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;pthread_t t_b&lt;/code&gt; can access the &lt;code class=&quot;language-text&quot;&gt;int sum = 0&lt;/code&gt;&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;55728081073544520000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`int sum = 0; // Global int to store the sum of the two arrays
sem_t mutex; // Synchronization Bit

void *add(void *arg){
    int *ptr = (int *) arg;
    while(*ptr != -1){
        sem_wait(&amp;mutex);
        sum += *ptr;
        printf(&amp;quot;value: %d sum %d\n&amp;quot;, *ptr,sum );
        sem_post(&amp;mutex);
        ptr++;
    }
    return NULL;
}`, `55728081073544520000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; sum &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Global int to store the sum of the two arrays&lt;/span&gt;
sem_t mutex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Synchronization Bit&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; arg&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;sem_wait&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        sum &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;value: %d sum %d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;sum &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;sem_post&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;mutex&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        ptr&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;First we have to convert the parameter &lt;code class=&quot;language-text&quot;&gt;void *arg&lt;/code&gt; into a &lt;code class=&quot;language-text&quot;&gt;int *ptr&lt;/code&gt; because we passed in the int array when creating the thread and the variable name of the array : &lt;code class=&quot;language-text&quot;&gt;int A[4]= {1,2,3,-1}&lt;/code&gt; in other words, A stores the pointer to the first element of the array. If you want to learn more about pointers &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/pointers-with-c/&quot;&gt;click here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;we loop over the array. Ignore the &lt;code class=&quot;language-text&quot;&gt;sem_wait(&amp;amp;mutex)&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;sem_post(&amp;amp;mutex)&lt;/code&gt; these functions are again part of the &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/synchronization-and-critical-section/&quot;&gt;synchronization&lt;/a&gt; and &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/synchronization-and-critical-section/&quot;&gt;critical section problem&lt;/a&gt;. . For now, just pretend that they were not there.&lt;/p&gt;
&lt;p&gt;we &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;/pointers-with-c/&quot;&gt;dereference&lt;/a&gt; &lt;code class=&quot;language-text&quot;&gt;*ptr&lt;/code&gt; and increment and the value of &lt;code class=&quot;language-text&quot;&gt;sum&lt;/code&gt; and move to the next element using &lt;code class=&quot;language-text&quot;&gt;ptr++&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Once both child threads finish looping through their array and terminates, the parent thread will continues execution and print the total&lt;/p&gt;
&lt;div
              class=&quot;gatsby-code-button-container&quot;
              data-toaster-id=&quot;99236879035643050000&quot;
              data-toaster-class=&quot;gatsby-code-button-toaster&quot;
              data-toaster-text-class=&quot;gatsby-code-button-toaster-text&quot;
              data-toaster-text=&quot;Copied to Clipboard&quot;
              data-toaster-duration=&quot;3500&quot;
              onClick=&quot;copyToClipboard(`    pthread_join(t_a, NULL);
    pthread_join(t_b, NULL);
    printf(&amp;quot;Total: %d\n&amp;quot;, sum);

    return 0;`, `99236879035643050000`)&quot;
            &gt;
              &lt;div
                class=&quot;gatsby-code-button&quot;
                data-tooltip=&quot;copy to clipboard&quot;
              &gt;
                &lt;svg stroke=&quot;currentColor&quot; fill=&quot;currentColor&quot; stroke-width=&quot;0&quot; viewBox=&quot;0 0 448 512&quot; height=&quot;1em&quot; width=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;
              &lt;/div&gt;
            &lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;pthread_join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;t_b&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Total: %d\n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sum&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I highly recommend copying the entire code section above and running it using &lt;code class=&quot;language-text&quot;&gt;gcc -o OUTPUT_FILE_NAME src.c -pthread&lt;/code&gt;. Here, src.c is the C source code file you copied into. &lt;code class=&quot;language-text&quot;&gt;OUTPUT_FILE_NAME&lt;/code&gt; is an arbitrary name of your executable and -pthreads will link the pthread library. Run the program using &lt;code class=&quot;language-text&quot;&gt;./OUTPUT_FILE_NAME&lt;/code&gt;. Mess around with it and have fun.&lt;/p&gt;</content:encoded></item></channel></rss>