<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nick Hollins on Medium]]></title>
        <description><![CDATA[Stories by Nick Hollins on Medium]]></description>
        <link>https://medium.com/@nickahollins?source=rss-39c3aa25e3ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qhki8mTjK9zBrWzx8mzBsQ.jpeg</url>
            <title>Stories by Nick Hollins on Medium</title>
            <link>https://medium.com/@nickahollins?source=rss-39c3aa25e3ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:49:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nickahollins/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is MVC Architecture using Node/Express(For Beginners)]]></title>
            <link>https://nickahollins.medium.com/what-is-mvc-architecture-using-node-express-for-beginners-a1456eb88f34?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1456eb88f34</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 23:38:09 GMT</pubDate>
            <atom:updated>2022-08-23T23:38:59.806Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding MVC is a very important thing to know if you want to be able to organize your apps in a very clean way.</p><h3>So what is this MVC thing and why is it talked about so often?👀</h3><p>In the simplest way put, MVC (<strong>M</strong>odel <strong>V</strong>iew <strong>C</strong>ontroller) is a way of thinking when creating or structuring our applications. It’s talked about often because it is one of the standard approaches when creating an application. Let’s dive deeper into MVC in regards to web applications.</p><h3>Let’s break down MVC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*inDwdYBFuYZa8cQU.png" /></figure><p>Imagine someone goes on google and searches for all types of cars. There are two things I want you to pay attention to in the screenshots. The first is what the URL looks like before the person clicks search and the second is after the user has clicked search.</p><h4>URL Before the user clicks search</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/0*hVVXHmKTPaN3qs9m.png" /></figure><p>Currently, the URL is just ‘<a href="https://www.google.com/">https://www.google.com/</a>&#39;. Let’s see what happens when the user clicks the search button to find information on cars.</p><h4>URL After the user clicks search</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*HSyBFX9a5swoHOAy.png" /></figure><p>It’s obvious that you notice a huge difference between the two URLs so let&#39;s look at how MVC comes into play.</p><h3>Router</h3><p>So the router is part of the MVC pattern even though it doesn’t have its own specific letter in the acronym. The router has ONE job and it does it very well. The router&#39;s job is to look at the URL (when the user makes a request) and pass that information along to the appropriate controller.</p><h3>Let’s look at some code!</h3><p>The MVC model can apply to many different languages but let’s use JavaScript (NodeJS/ExpressJS) for example.</p><p>So here we have a basic Node server:</p><pre>const express = require(&#39;express&#39;)<br>const app = express()<br>const connectDB = require(&#39;./config/database&#39;)<br>**const homeRoutes = require(&#39;./routes/home&#39;)**<br>const todoRoutes = require(&#39;./routes/todos&#39;)</pre><pre>require(&#39;dotenv&#39;).config({path: &#39;./config/.env&#39;})</pre><pre>connectDB()</pre><pre>app.set(&#39;view engine&#39;, &#39;ejs&#39;)<br>app.use(express.static(&#39;public&#39;))<br>app.use(express.urlencoded({ extended: true }))<br>app.use(express.json())</pre><pre>**app.use(&#39;/&#39;, homeRoutes)**<br>app.use(&#39;/todos&#39;, todoRoutes)</pre><pre>app.listen(process.env.PORT, ()=&gt;{<br>    console.log(&#39;Server is running, you better catch it!&#39;)<br>})</pre><p>You don’t have to understand everything going on. Let’s just focus on the two lines of code that’s that is starred.</p><p>The first line:</p><pre>const homeRoutes = require(&#39;./routes/home&#39;)</pre><p>is essentially just <em>importing</em> a module and storing it in a variable to use later. The module in this sense is just a directory that’s inside of your project.</p><p>So now that you know that, let’s look at the next important line of code:</p><pre>app.use(&#39;/&#39;, homeRoutes)</pre><p>P.S. app.use is just <em>middleware</em> and middleware is just essentially what is happening (logic, functionality, etc.) in the MIDDLE of the request and response.</p><p>So this line is just saying “Hey server, when someone makes a request to the root route (‘/’ is the root route) go to the homeRoutes so our homeRoutes router can send this information to the appropriate controller”. Remember homeRoutes is a variable that points to the module(the directory in your project).</p><p>So when the user goes to the root route (ex: <a href="http://www.something.com/">www.something.com/</a>) the server knows what to do which is to go to the router made for the root route. Now, let’s look at what happens when we actually get to where the router is at.</p><p><em>P.S. the router is usually inside of a directory (folder) named Routes</em></p><h3>Looking at our router</h3><pre>const express = require(&#39;express&#39;)<br>const router = express.Router()<br>const homeController = require(&#39;../controllers/home&#39;)</pre><pre>router.get(&#39;/&#39;, homeController.getIndex) </pre><pre>module.exports = router</pre><p>I don’t want to focus too much on the code but rather on the high-level concept so I will just focus on the most important part of the code.</p><pre>router.get(&#39;/&#39;, homeController.getIndex)</pre><p>This is the router. This is what knows what to do when a user makes a request. This router is saying “Hmm, I see the user made a GET request to the root route and I know exactly what controller(homeController) to send this request to so that they can process this! Not only do I know the controller to send this to but I know the method that the controller is going to use to process this(getIndex)”. Remember, the router ONLY JOB is to look at the URL (and what kind of request was made) and send that information to the appropriate controller to process.</p><p><em>P.S. remember the variable that was set in the server code to specify where the module (directory) is coming from? This is the same concept with the homeController variable</em></p><h3>MV(C)- The C is for Controller</h3><p>Before we look at the code let’s understand what the controller does. I like to look at the controller as the job of the “Middle Man” since it communicates with multiple parts of the application. The controller&#39;s job is to take the request and process it based on the information of the request. Sometimes the controller receives the information from the router and only needs to talk to the <strong>view</strong> and sometimes it needs to talk to the model AND the view. In the simplest way put, the controller takes a request and converts that to commands the model and/or view can understand and process. Let’s look at some code.</p><pre>module.exports = {<br>    getIndex: (req,res)=&gt;{<br>        res.render(&#39;index.ejs&#39;)<br>    }<br>}</pre><p>In this code, the controller received the information (request) from the router and this is HOW IT’S RESPONDING (Remember, everything on the internet is just requests and responses). So essentially it’s just RENDERING A VIEW. So the controller is saying “Hey router thanks for that information, based on that request all I need to do is go tell the <strong>view</strong> what to do with this”.</p><h3>M(V)C — The V is for View</h3><p>The view ONLY job is to take the information that the controller sends and present that to the client (browser). In this case, the view is just going to render some ejs which just spits out some html code. I think the view is the easiest to understand because this is what we see when we get on the internet every day. This blog post you are reading is just a view! Now that we understand that. Let’s look at the model.</p><h3>(M)VC — The M is for Model</h3><p>This can be intimidating to understand but I will try to make it as simple as possible! The model&#39;s job is to define the data structure. The model is what talks to the database to get any information the controller asks for and also does any deleting, inserting, updating, or selecting from the database. Let’s think about the google example from earlier. When someone searches for cars and hit enter, the router sends the request to the controller and the controller asks the model “Hey model, can you give me ALL the information that you have on cars?” The model then checks the database and says “Here is all the information the database has stored”.</p><p>I hope you now have a better understanding of how MVC works on a high level. If you are still confused please watch this video (<a href="https://www.youtube.com/watch?v=1IsL6g2ixak&amp;t=639s">https://www.youtube.com/watch?v=1IsL6g2ixak&amp;t=639s</a>) to help you better understand.</p><p>Feel free to give me a follow on these social sites:<br>Twitter: <a href="https://twitter.com/NickAHollins">https://twitter.com/NickAHollins</a><br>LinkedIn: <a href="https://www.linkedin.com/in/nicholas-hollins/">https://www.linkedin.com/in/nicholas-hollins/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1456eb88f34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Understanding of JavaScript Objects Part 1]]></title>
            <link>https://nickahollins.medium.com/simple-understanding-of-javascript-objects-part-1-f6fd9665fef7?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6fd9665fef7</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Thu, 03 Jun 2021 19:17:40 GMT</pubDate>
            <atom:updated>2021-06-03T19:17:40.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ZlCVSAxqMP13STKhcXzY2g.jpeg" /><figcaption>Source: Dev.To</figcaption></figure><h3><strong>So what is a JavaScript object anyway?</strong></h3><p>First, let’s look at an object in a more non-programming sense such as a car. A car can have different colors, it can be manufactured by different companies (e.g. Ford, Kia, Tesla(What’s up Elon 😁), Chevy, etc.…), it can have different engines, different tire sizes, and plenty of other different properties. We can look at JavaScript objects the exact same way! So an object in JavaScript is simply just a entity that has properties to define the characteristics of that entity. If we created a car object in JavaScript (we will later), one of the properties of that car would be a color.</p><h3><strong>Ok, that’s cool but what does objects have to do with coding?</strong></h3><p>If you are a developer, you may have seen the term “OOP” or “Object-Oriented Programming” at some point, and if you haven’t yet I’m sure you will. Object-Oriented Programming is a way to write code using objects. When doing this, you can write, create, and even manipulate objects. Those objects will become the thing that makes up your program. This is important because OOP changes the way that you write a program and how that program is organized (for the better in my opinion). So before learning about objects in JavaScript we were coding using function-based code . Now let’s learn how to create these objects.</p><h3><strong>Let’s Create A Tesla Using JavaScript!</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*q7T6jwfdNb9ya5H2w-0Y3w.jpeg" /><figcaption>Source: izmocars</figcaption></figure><p>Since I am a fan of Elon Musk (when he’s not manipulating the crypto market 😕) We are going to create the Tesla that you see in the picture above just based on what we see. You can create a JavaScript object almost the same way as you create variable(kind of) but let’s take a look at this code example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*hAI2BFioHn_awes9bMKtzQ.png" /><figcaption>Creating a Tesla Object in JavaScript</figcaption></figure><h3><strong>The Code Explained</strong></h3><p>Ok, so these six lines of code just created a very basic example of the Tesla that we seen earlier. Let’s break this down line by line to understand better. Line 62 we are initiating the object. In the simplest terms we are creating a object named tesla. You could have used let instead of const in this example also. The main thing to take note of on line 62 is that after you declare the the object name there should be an equal sign “=” sign along with curly brackets “{}” right after it. On line 63–66 is everything that goes inside of the curly brackets. Think of it as the object body. Also, line 63–66 are what you call properties of the object, in other words these properties is what defines the characteristics of the tesla. It’s important to note that these properties are name-value pairs (color being the name and ‘red’ being the value) and this is called an object literal. So line 63–66 are just name-value pairs but pay special attention to the comma that separates each property because that is very important to add. Now lets access some of the properties of this tesla(object).</p><h3><strong>Accessing a Object Property</strong></h3><p>Once you create a object there is a way that you can access the properties of that object. So for example, let’s say that we wanted to access the color of the tesla. We can do that by using the dot notation (myObject.myProperty) to access that color. We would say<strong><em> tesla.color </em></strong>to access the color of the tesla. We can put that inside of a console.log to see the results inside of the browser’s console.</p><h3><strong>End of part 1</strong></h3><p>If you have never seen or heard of JavaScript Objects then that can be a lot to take in and that’s ok. We will dive more into objects in part 2 and create an actual program using JavaScript Objects. This simple concept will start getting complex the more we dive into objects.</p><h3><strong>Follow Me/Reach out for help</strong></h3><p><a href="http://www.instagram.com/nickahollins">Instagram</a></p><p><a href="https://www.facebook.com/TheDevNick/?modal=admin_todo_tour">Facebook</a></p><p><a href="http://www.linkedin.com/in/nicholas-hollins">LinkedIn</a></p><p><a href="http://www.twitter.com/nickahollins">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6fd9665fef7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[8th Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/8th-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-ebe0e475a88c?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebe0e475a88c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 21:52:48 GMT</pubDate>
            <atom:updated>2020-07-06T21:52:48.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>Topic I learned This Week: Practice/Project!</strong></h3><p>Unfortunately I had to skip a week of coding because I have been moving, but I am back on track and learning. I have not learned any new concepts, but I have been practicing what I have learned so far by creating a small project which is a dice game.</p><h3><strong>What have I incorporated in the project?</strong></h3><p>The first thing that I incorporated in this project is generating a random number for the dice when the player click the roll button. My thought process went like this: So the maximum number of a regular dice can be from 1 to 6. So my first google search was “how to generate a random number using JavaScript?”. I figured out that there is a method for this called Math.random() which generates a floating point from 0 to less than 1 inclusive of 0 but NOT 1. So I figured I can just code Math.random() * 6 and get random numbers between 1 and 6 right? Wrong! I quickly ran into a problem. The problem was that Math.random() * 6 generated a floating point from 0 up to but not including 6. Another problem was that I wanted the random numbers to be from 1 to 6 and I wanted these to be whole numbers not floating point numbers. Lucky for me these problems was only a google search away. So since I wanted the random numbers generated to be between 1 and 6, I found the Math.floor() method which basically returns the largest integer less than or equal to a given number. Knowing this I should have been able to add the Math.random() method to the Math.Floor() method in order to generate whole random numbers between 1 and up to and including 6 right? wrong! So once I entered the code : Math.<strong>floor</strong>(Math.<strong>random</strong>() * 6) in the browser console to test if it worked this is what I got:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*SkRjhc6rE2nxinvfnKC0Ow.jpeg" /></figure><p>As you can see on the last test I did, I got a a result of 0 but I wanted 1–6 not 0–5. No worries, just another google search away from figuring this out. I soon found out that all I had to do was add + 1. So once I entered the code: Math.floor(Math.random() * 6) + 1 I got the results that I was looking for. The only thing that was left for me to do was to take that whole piece of code and store it inside of a variable named dice so the outcome looked like this : var dice = Math.<strong>floor</strong>(Math.<strong>random</strong>() * 6) + 1;</p><h3><strong>What did I learn from this?</strong></h3><p>One of the biggest things I learned from this is the fact that the best way to solve a problem is to solve it piece by piece. What I am learning to do is break down a problem into the most smallest pieces that I can and work from there. This is better than trying to solve too many things at once, taking baby steps is perfectly fine. Another thing that I realized is that the more mistakes you make coding, the more you learn. This is another reason why you shouldn’t just follow tutorials and not try things on your own. In tutorials you don’t get the experience of making mistakes because you are just copying what you see and it works. Just understand you have to make mistakes in order to learn.</p><p>Follow me on social media</p><p><a href="https://facebook.com/thedevnick">Facebook</a></p><p><a href="https://www.instagram.com/thedevnick/">Instagram</a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebe0e475a88c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7th Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/7th-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-9998beb219e3?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9998beb219e3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 22:19:48 GMT</pubDate>
            <atom:updated>2020-06-22T22:19:48.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>Topic I learned this week: NONE!</strong></h3><p>I surprisingly have not learned anything new this week. The reason for this is that I did not want to get stuck in tutorial hell (this is a big problem beginners face). So instead of learning something new, I decided to take on my first small JavaScript project!</p><h3><strong>The mini project is called “The Pig Game”</strong></h3><p>Overall, this is a online dice game. when determining how to code the game I had to first establish the requirements(rules) for the game.</p><h3><strong>The Game Rules</strong></h3><ul><li>The game has only 2 players</li><li>Each turn a player rolls the dice as many times as they wish. Each result will get added to the ROUND SCORE.</li><li>If the player rolls a 1 then they round score is lost. After that it is the next player turn.</li><li>The player can choose to HOLD, which just mean the ROUND score gets added to the global (overall) score. After the player choose to hold it is the next players turn.</li><li>The first player to reach the overall score of 100 wins.</li></ul><h3><strong>The UI</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LdPewhiCh7f1Ff8BqKir5Q.png" /></figure><p>The User Interface was already designed so that I can focus on just JavaScript even though I find myself tweaking things that I think look better.</p><h3><strong>Overall</strong></h3><p>I do not want to get into the code too much today because I haven’t really did too much. I can say I have learned how to manipulate the DOM, work with on click event listeners, and anonymous functions. This project is based on a tutorial but to get out of tutorial hell I decided to implement different features that is not in the tutorial. I also already have a mini project that I will work on in the future based off these concepts I am learning now.</p><h3><strong>Follow me on social media</strong></h3><p><a href="https://www.instagram.com/thedevnick/"><strong>Instagram</strong></a></p><p><a href="https://facebook.com/thedevnick"><strong>Facebook</strong></a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9998beb219e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6th Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/6th-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-914e08a1b404?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/914e08a1b404</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[100daysofcode]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 23:33:17 GMT</pubDate>
            <atom:updated>2020-06-15T23:33:17.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>Topic I learned this week: JavaScript Hoisting!</strong></h3><p>When I took a JavaScript course about two years ago in college, the topic of JavaScript hoisting didn&#39;t really get mentioned for some reason. It could be that I don’t remember but I know that this is a important topic to understand. I haven’t got a chance to really see how it works in a real project, but I now understand the basic concept of what it does. The simplest way that I can define hoisting is when variable and function declarations are moved to the top of their scope before code execution. So basically, no matter where the variables or functions are declared in the code, they will be moved to the top of their scope. Lets take a look at a code snippet to see how this works. I will first show a code snippet of how you would normally declare a function and then another snippet of how it works with hoisting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nb_WM_p5mXPCSdirLh0XKw.png" /><figcaption>Function not using hoisting</figcaption></figure><p>In the example above, I just declared a function as I normally would without using any type of hoisting. Lets see what happens when I put the function call above the function declaration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6YzEIcGGzUTGSRUgANapg.png" /><figcaption>function using hoisting</figcaption></figure><p>In this code example, I called the function before I even declared it and I still got the same result. This still works because of how context execution works in JavaScript. It is important to note that JavaScript hoist declarations and not initialization. Lets look at how this works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQryYTTBFltm1myhtgshZA.png" /></figure><p>The console will return undefined because only the declaration was hoisted and not the initialization. I am still new to this but this is the general understanding of how hoisting works.</p><h3><strong>Summary</strong></h3><p>Overall, I feel like I learned a important concept in JavaScript. I feel like I will understand why certain things work when creating a project. I actually started working on a project to learn DOM manipulation which is another important concept. This is my favorite thing that I learned so far. The game will be a dice game. I will talk more about this next week but it is super exciting!</p><h3><strong>Follow me on social media</strong></h3><p><a href="https://www.instagram.com/thedevnick/">Instagram</a></p><p><a href="https://facebook.com/thedevnick">Facebook</a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=914e08a1b404" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5th Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/5th-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-30636c180a18?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/30636c180a18</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[inspiration]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 22:32:31 GMT</pubDate>
            <atom:updated>2020-06-08T22:32:31.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3>Topic I learned this week: Loops!</h3><p>This week I learned another important concept in JavaScript which is loops. Loops is used in any programming language I can think of. You will always use this in programming. Loops are a way to repeat the same code multiple times. I am no expert but here is a example: If you wanted to execute code from 1–10 you can use a loop instead of writing that same code 10 times. Lets take a look at how the while loop work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*8AEBVipXl1IOHfg1NFXAew.png" /></figure><p>In this code snippet, I show how the while loop is set up. You have the keyword ‘while’ and then you have the ‘condition’ inside of the parentheses (kind of like a if statement). Inside of your brackets you have the code and the loop body. So while the condition is <strong>true, </strong>the code inside of the loop body is executed. Lets actually put some code inside of the while loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*yDqliUYTDi5s5gFvWKOHvg.png" /></figure><p>A single execution of a loop is called a iteration. In this example the loop will go through 4 iterations. In simpler terms, the loop will execute 4 times and no more than that because it only executes as long as i is less then 4. First I declared the variable i to be 0. Then I created the while loop with a condition that says as long as i is less than 4 keep executing whats in the loop body. So the browser console will keep printing numbers until it reaches 3. The last piece of code (i++) in the loop body is to stop the from running forever (in theory). Lets talk about the do…while loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*02vOyyaD6wUDmykRWJhKEg.png" /></figure><p>In this code snippet, the loop body is moved above the condition. Its important to note that you would only use this kind of loop if you want the execute the body of the loop at least one time regardless of the condition being true. Other than that, the regular while loop is acceptable. So this will execute 4 times just like the example of the while loop. It’s the same exact concept just a different loop. Lets talk about the more complex and common loop which is the for loop!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*LDQ0GAORVPsneg47-2zZBQ.png" /></figure><p>This one was more confusing to me than the other loops but it is the most common type of loop. This is a for loop and its basic syntax. The begin piece of code executes once upon entering the loop. The condition piece of code is checked on each iteration of the loop and it stops when the condition is false. The step piece of code executes after the body on each iteration (do not put a semi colon after this one). Lets look at how this works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*aRUnw8-62mgqBzrtGaXj6A.png" /></figure><p>In this example, I learned this by reading it in pseudo-code. So this loop is saying: “begin loop” (i = 0;), “if condition is true, run the loop body and run step as well ” (i &lt; 4) { console.log(i); i++ }. “Run this loop until it reaches 3 which is the furthest you can go for i to be less than 4”. Hopefully this makes sense to you because I had a hard time figuring out how this works.</p><p>Normally, a loop will terminate once the condition becomes false. However, we can terminate or exit the loop anytime we want to by using a loop break. Lets look at a example of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*ruJts_3idqc2ntcoRkbHuQ.png" /></figure><p>A break is a pretty simple concept. In this example, the for loop originally supposed to iterate 6 times but due to the break that was added it will only iterate 5 times starting from 0 until it hit 4. On line 2 , I added a if statement saying if i is equal to 4 then stop the loop (break). There is also a continue statement that is really just a “lighter” break statement. So basically it does not stop the whole loop, it just stops the iteration of the loop and starts a new one if the condition allows it.</p><h3><strong>Summary</strong></h3><p>Overall, I felt like learning loops was fun to play around with and definitely useful. I see why loops are so common in programming and I cant wait to actually start using them in a project. This was the last of the basic concepts that I needed to learn and now I will start getting into the fun stuff which is building projects!</p><h3><strong>Follow me on social media!</strong></h3><p><a href="https://www.instagram.com/thedevnick/">Instagram</a></p><p><a href="https://facebook.com/thedevnick">Facebook</a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30636c180a18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4th Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/4th-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-bda219fd606f?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/bda219fd606f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[100daysofcode]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 22:35:11 GMT</pubDate>
            <atom:updated>2020-06-01T22:35:11.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>I finally made it to a month of the #100DaysOfCode challenge!</strong></h3><p>It feels so good to finally be consistent at learning how to program in JavaScript! Its been a month and I feel like I learned so many different concepts but it also feel like I have so much longer to go (which i’m sure I do) until I can feel competent in this language. One thing I noticed is that I am learning more than I did in the past by taking time to really understand the concepts. It is no rush for me, I rather take my time and really get a grasp of these basic concepts.</p><h3>Topic I learned this week: Challenging myself</h3><p>Sometimes I go through concepts without really practicing what I just learned so this week I decided to do a coding challenge to test my knowledge on JavaScript objects. So the challenge looked like this: “person A and person B wants to compare their BMI (Body Mass Index)”. I did this same challenge before but just with if/else statements. So there was two things that I needed to implement in order to pass the coding challenge. The first was to create 2 objects for each person with their full name, height, and mass. The second step was to add a method to each object to calculate the BMI of each person, save the BMI to the object, and return it from the method. The last step was to log who has the highest BMI and to make sure I have a solution if they both have the same BMI.</p><h3><strong>The first step: create 2 objects for each person with their full name, height, and mass.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*splBhN2jRyKXjThJRQx_nA.png" /><figcaption>Creating Object for person A (Mark)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*DVkvW7-urkwhktoteEbPOg.png" /><figcaption>Creating Object for person B(John)</figcaption></figure><p>At this point I have created two objects (mark and john) and added properties (first name, last name, height, mass) to the object. This was pretty simple so far.</p><h3><strong>The second step: add a method to each object to calculate the BMI of each person, save the BMI to the object, and return it from the method.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6xjPH55JouErSLynHxK3w.png" /><figcaption>adding method to object to calculate BMI</figcaption></figure><p>This is where things got tricky for me. In this instance, a method is basically just a function. This is where I learned how important the keyword ‘this’ is. So I created a method named calcBMI and then added a function inside of that method. In order to calculate mass, you have to calculate mass divided by the height squared. So knowing this formula, I basically just did simple math. What I did get wrong is that I didn&#39;t add the ‘this’ dot notation and I got an error. The next thing I did wrong was forget to return this.bmi back to the method so I was getting ‘undefined’ when I console.logged the method.</p><h3><strong>The Last Step: log who has the highest BMI and to make sure I have a solution if they both have the same BMI.</strong></h3><p>I didn&#39;t add the picture of the second object because it is basically the same but with different numbers and names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ViUvbE0E2DMqgZup0FWb9A.png" /><figcaption>logging who has the higher BMI</figcaption></figure><p>This part was pretty simple for me. All I did was add an if/else statement to log who has the higher BMI. I talked about learning the else/if statement in a previous<strong> </strong><a href="https://medium.com/@NickAHollins/1st-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-1ec4e0cb2bee"><strong>article</strong></a><strong>.</strong></p><h3><strong>Summary</strong></h3><p>I also learned a little bit about loops but I haven’t grasp the concept of them enough to talk about them in depth so that’s on the list for next week. Overall I just been practicing what I had learned already because that’s the only way you can really understand a concept. I look forward to learning more about JavaScript.</p><h3><strong>References</strong></h3><p><a href="http://javascript.info/">JavaScript.Info</a></p><p><a href="https://www.udemy.com/course/the-complete-javascript-course/">Jonas udemy Course</a></p><h3><strong>Follow me on social media</strong></h3><p><a href="http://instagram.com/thedevnick">Instagram</a></p><p><a href="https://facebook.com/thedevnick">Facebook</a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bda219fd606f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3rd Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/3rd-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-cf7208df1ab?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf7208df1ab</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 25 May 2020 19:13:51 GMT</pubDate>
            <atom:updated>2020-05-25T19:13:51.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>Topic I learned this week: JavaScript Arrays</strong></h3><p>JavaScript arrays is a important topic that I learned this week. Arrays are definitely another one of those concepts that you will see over and over again in programming. A JavaScript array is basically something you would use when you want to store a ordered collection of information. I didn’t learn every aspect of an array such as a multidimensional array, internals, etc. Lets take a look at how you would declare an array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1FcxlvKQBMheruz1Vf_nGQ.png" /><figcaption>Declaring an array</figcaption></figure><p>In this code snippet I am declaring an array that has a list of fruits. I could have also declared an array using the syntax: let fruits = new Array(); .</p><p>The most common way to declare an array is the way I did it in the code snippet. We can access each element in the array. The elements in the array are numbered starting with zero. Lets take a look at how this work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJj49KEW54EPM_HSk-oxlg.png" /><figcaption>Accessing each element in the array</figcaption></figure><p>In this code snippet I am accessing each element inside of the array. It is always important to know that indexing starts at 0. You can also mutate elements in the array as well. I will give an example of what I mean by that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IQ5RIZJeTDHQWd4JOT6Qww.png" /><figcaption>Mutating elements in the array</figcaption></figure><p>In this example, I changed the first element in the array (apple) to banana instead. This is called mutating elements. We can also add elements to the array using the same concept.</p><p>These are the extreme basics of a JavaScript array but I have the overall concept of what they are and what they do.</p><h3><strong>Topic I learned This Week: JavaScript Objects</strong></h3><p>This is a concept that I am still learning but I will talk about what I do know about it so far. A JavaScript Object penetrates almost every aspect of the language according to JavaScript.info. Objects are used to store keyed collection of various data. An Object can have a optional list of properties. These properties has a key: value pair. The key is the is the property name and the value could be anything. Lets take a look at how we would declare a object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRSglCJXNk2GSZ5nftfx2A.png" /><figcaption>Declaring a Object Literal</figcaption></figure><p>In this example I declared a object named ‘nick’. Inside of the object I have different properties to describe the object such as first name, last name, birth year, and siblings. Notice how some of these properties have different data types. It do not have to be one type of data type inside of the object. There is another way to declare an object. The way that I declared the object is called an Object Literal. I could&#39;ve also declared it like this: let nick = new Object(); This is called the object constructor syntax.</p><p>Usually it is common to see the object literal syntax more. In the example above , firstName would be the ‘Key’ and Nick would be the ‘value’ to that key. You can access elements in the object using the dot notation. So in the example above, I used console.log(nick.firstName); This will print my first name on the browser console. Unfortunately this is pretty much all that I have learned about objects this week but I am definitely excited to learn more about objects and how they work.</p><h3><strong>Summary</strong></h3><p>I think that I am moving at a decent pace for learning JavaScript. I like the fact that I am struggling to figure out how some of these concepts work because that just mean I am learning! I look forward to learning more things this week.</p><h3><strong>References</strong></h3><p><a href="https://javascript.info/object">JavaScript.info</a></p><p><a href="https://www.udemy.com/course/the-complete-javascript-course/">Jonas Udemy Course</a></p><h3><strong>Follow Me On Social Media</strong></h3><p><a href="https://www.instagram.com/thedevnick/"><strong>Instagram</strong></a></p><p><a href="https://www.facebook.com/TheDevNick/?modal=admin_todo_tour"><strong>Facebook</strong></a></p><p><a href="https://www.linkedin.com/in/nicholas-hollins/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf7208df1ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2nd Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/2nd-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-d34add9cb217?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/d34add9cb217</guid>
            <category><![CDATA[100daysofcode]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 18 May 2020 23:43:35 GMT</pubDate>
            <atom:updated>2020-05-18T23:43:35.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_8azx7LD0r6kuhPhE9wjg.png" /></figure><h3><strong>Consistency is key, as usual.</strong></h3><p>So I talked about my first week of the 100 days of code challenge in a previous article which you can find <a href="https://medium.com/@NickAHollins/1st-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-1ec4e0cb2bee">here.</a> This has been a interesting journey and the more I learn JavaScript, the more difficult it gets. That can be discouraging for beginners like myself but I like the challenge! What that being said, lets go over what I learned this week.</p><h3><strong>Topic I learned this week: JavaScript Functions</strong></h3><p>So JavaScript functions is the only thing that I learned this week. That may not seem like a lot but to me that is a huge deal because functions is one of those concepts that I will be using over and over again.</p><p>In JavaScript (or programming in general) you often perform a similar action in many places of your script. A quick example of this would be if you wanted to show a nice looking message when a user logs in and out of of your site. Functions is the perfect solution for this without repetition. This is important because of a concept called D.R.Y (Do Not Repeat Yourself).</p><h3><strong>Declaring a function</strong></h3><p>When creating a function, you must declare it first by using the function keyword, followed by the name of the function, followed by parentheses “()” immediately after the function name(no space between them), followed by brackets “{ }” . Lets take a look at the actual code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Tn-HEJxzfvzhGGpZ7YQUw.png" /><figcaption>Declaring a function</figcaption></figure><p>So as you can see above, I declared a function named calculateTwoNumbers. It is important to remember that you ALWAYS want to name your functions based on what action the function is doing . In this function I want to calculate two numbers (hence the name) and this is how you would start the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWJfNgYrpJf_WofXZPCJ0A.png" /><figcaption>adding two numbers inside a function</figcaption></figure><p>Now the function is actually going to do something. In line 1, I added values inside the parentheses which we call parameters or arguments. The parameters must be separated by commas if it is more than one. When the function is called (which it is being called on line 6) the given values (1, 2) is copied to the local variables (a, b) and the function uses those values to calculate. On line 3, the return keyword adds a + b which is 1 + 2, calculates it and then RETURNS the result to the function and then ends the function. The function just stores that result until it is called at a later time.</p><h3><strong>Local Variables</strong></h3><p>A local variable is a variable that is declared inside of the function. This means that the variable is only <strong>visible </strong>inside of that function. Lets look at a example of how local variables work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIaw1aK1itgOwtXLJ1PQsw.png" /><figcaption>Local variables</figcaption></figure><p>In this example I defined variables a and b inside of the function. Since these variables are defined inside of the function that means they are <strong>local. </strong>Variables that are local can not be called outside of the function. On line 9 I tried to console.log (which this just writes something on the browser console) the variables a + b. When I ran that on the browser I got a error that says “a” is not defined. However, the variables a and b <strong>are </strong>defined, just not <strong>globally. </strong>Lets look at how you would declare a global variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ziSsbkVZQLumTZlMUjcqtw.png" /><figcaption>declaring global variables</figcaption></figure><p>As you can see, variable a and b are defined <strong>outside the function</strong> which makes them global now. So now you can call these variables from anywhere in the script. Just know that it is good practice to define variables locally. There may be certain situations where you should define variables locally but most variables resides in their function.</p><h3><strong>Default values</strong></h3><p>If a parameter is not given, then its default becomes <em>undefined</em>. Lets look at a new example to understand what this means. First I will give a code snippet of a function with parameters and then a code snippet with a <strong><em>undefined</em></strong><em> </em>parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2Vo7JfuP5vjil-xAWTYng.png" /><figcaption>function with parameters</figcaption></figure><p>The cool thing about learning is that a week ago if I seen this I wouldn&#39;t really know what this function is doing, now I do! So this function is basically going to show a message from a contact and the message of the contact. Notice How I defined the variable contact outside of the function and the function still modified a copy of it since its global. The message would show in a browser as “Message from Nick: Hello”. Lets look at what happens if I take the “hello” parameter out of the function call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dRzsyLNXnvNYAnaC2v-hg.png" /><figcaption>function call without the “text” parameter</figcaption></figure><p>In the browser, the message shows as “message from Nick: undefined”. This is not a error, since there is no value for <strong>text </strong>JavaScript automatically assumes text === undefined (text is equal to undefined).</p><h3><strong>References I used to understand these concepts</strong></h3><p><a href="https://www.udemy.com/course/the-complete-javascript-course/">The Complete JavaScript Course 2020</a></p><p><a href="https://javascript.info/function-basics#function-declaration">JavaScript.info</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions">JavaScript MDN</a></p><h3><strong>Summary</strong></h3><p>Overall, There is a few (or maybe a lot idk i’m still learning) things about JavaScript functions that I might&#39;ve missed but I am sure that I have the overall concept of functions down. I really do this to teach myself more than to teach others but if you get something from this then great!</p><h3><strong>Follow me</strong></h3><p><a href="https://www.instagram.com/thedevnick/">Instagram</a></p><p><a href="https://www.facebook.com/TheDevNick/?modal=admin_todo_tour">Facebook</a></p><p><a href="http://www.linkedin.com/in/nicholas-hollins">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d34add9cb217" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1st Week of #100DaysOfCode with JavaScript. What did I Learn so far?]]></title>
            <link>https://nickahollins.medium.com/1st-week-of-100daysofcode-with-javascript-what-did-i-learn-so-far-1ec4e0cb2bee?source=rss-39c3aa25e3ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ec4e0cb2bee</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nick Hollins]]></dc:creator>
            <pubDate>Mon, 11 May 2020 22:14:27 GMT</pubDate>
            <atom:updated>2020-05-11T22:14:27.624Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptMUsgArx7QLFF7XPyUuzw.jpeg" /><figcaption>Image from Pexels.com</figcaption></figure><h3><strong>Why did I start the #100DaysOfCode challenge?</strong></h3><p>Throughout my journey of learning to program I learned one of the most important things you could possibly learn, <strong>which is being consistent</strong>! I took a JavaScript course while being in college a few years ago. Guess how much of that JavaScript I remember and can implement? NONE! Wonder why? I do not remember anything because after I took the course I was not consistently working on bettering my skills in JavaScript. So if you are learning programming, the best advice that I can give is consistency is key. With that being said, I started the #100DaysOfCode challenge to force me to be more consistent. I will be documenting my journey of what I learned in JavaScript every week.</p><h3><strong>1st Topic I learned: JavaScript Variables</strong></h3><p>So this topic was pretty easy for me because I had worked with variables in different programming languages. A variable is basically a container for a value. That value can consist of different data types. For example, you can store numbers and strings (text) into a variable. You can store more than those two data types but I want to keep it simple for now.</p><p>Lets look at a code snippet of a JavaScript variable and how they work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*lRfjVYLVdpjdfzj93x_Vjw.png" /></figure><p>So in this code snippet I am declaring a variable. I want Nick to be assigned to the variable firstName. I declared this variable using the keyword var. Its important to note that you can declare a variable using different keywords such as let and const but since I am just learning I will stick with using the keyword var for now. Another important thing is when you want to declare a string as a variable, you must put the string(text) inside quotations using either “ double quotes” or ‘single quotes’. Both ways work but I tend to use single quotes. The semi-colon at the end of the line of code is not required but is extremely recommended. I have it set in my brain that it is required so I always include the semi-colon.</p><p>Now lets declare a number as a variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkAvis3upJUCebDOuJ3oeQ.png" /></figure><p>In this code snippet I wanted the variable myAge to be 24. I also declared another variable otherAge (which is a example of bad naming for a variable, so always make sure you name a variable related to what is going on so this variable should be timAge instead). This variable has the value of 25 but it is inside a string. Once I open the console on the browser,<em> </em><strong><em>console</em></strong><em>.</em><strong><em>log</em></strong><em>(‘Tim is ‘ + otherAge + ‘ years old’); </em>will be converted to a actual number instead of a string. guess what I learned this is called? <strong>Type Coercion</strong>!</p><p>Don’ts when declaring variables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Tdr4-QbdvMJ6DDtpdISUw.png" /></figure><h3><strong>2nd Topic I learned : JavaScript Basic Operators</strong></h3><p>JavaScript basic operators such as arithmetic operators is used to take numeric values as their operands and return a single value. You have probably seen these operators at some point when in school.</p><p>Lets take a look at some basic arithmetic operators</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*4zdiRuaWnhXGAXJztxlqbA.png" /></figure><p>Basically, these are the basic arithmetic operators. So you have addition, subtraction, multiplication, and division. Simple right? there are more arithmetic operators but as I said earlier, I want to keep it simple and beginner friendly because I am considered a beginner myself!</p><p>Arithmetic operators is not the only operators JavaScript have. Lets talk about the logical operator. As far as I know, logical operators are usually used with boolean (true or false) values. Lets take a look at how this works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*jKuGIO2x2DtbS2FTlHUaMg.png" /></figure><p>So in this code snippet we declared variable <strong>a</strong> which is 3, and declared variable <strong>b</strong> which is -2. So with logical operators we are expecting a <strong>true</strong> or <strong>false</strong> value. So what this console.log is saying is “Hey browser, is <strong>a </strong>greater than 0 <strong>AND </strong>is <strong>b </strong>greater than 0?” if <strong>BOTH </strong>of these values are not <strong>true</strong> then return false. So even though <strong>a</strong> is in fact greater than 0, <strong>b </strong>is not. With the AND(&amp;&amp;) operator both have to be true for the output to be true. With the OR (||) operator, one can be true and the other can be false and the output would be true. So in the code snippet, if it was a || instead of a &amp;&amp; the outcome would have been true. There is also another operator called the typeof operator. From my knowledge, this operator just tells you the data type of something so if I went into the browser console and typed <strong>typeof 3</strong> the browser would give an output that says number so 3 is a number. Obviously that is a extremely simple example but I feel like this can be very helpful when debugging and at some point down the road I am sure I will use it.</p><h3><strong>3rd Topic I learned: JavaScript If/Else Statements</strong></h3><p>This is by far one of my favorite topics I learned so far this week! So basically an if/else statement has a <strong><em>condition </em></strong>and a <strong><em>statement. </em></strong>A<strong><em> condition </em></strong>is a expression that is considered to be truthy (true) or falsey (false). A <strong><em>statement </em></strong>is what is executed if the <strong><em>condition is true. </em></strong>The second statement (Which would be inside the “else” block) will execute if the condition is false. Lets look at a example so this all can make more since.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_i3XAyojITE39O3g1QyUkQ.png" /></figure><p>In this code snippet, the variable<strong> firstName</strong> has a string value of <strong>Nick. </strong>The console.log could be a little confusing for beginners seeing it for the first time (it would confuse me a little also) so here is the basic structure of a if/else statement:</p><p><strong><em>if (condition) {</em></strong></p><p><strong><em>statement 1 to be executed }</em></strong></p><p><strong><em>else {</em></strong></p><p><strong><em>statement 2 to be executed }</em></strong></p><p>So what this is saying is “Hey <strong>if</strong> that <strong>condition</strong> is <strong>true, </strong>execute <strong>statement 1</strong>, or <strong>else </strong>execute <strong>statement 2.</strong>” This is just kind of the pseudo-code version of the code snippet above.</p><h3><strong>4th Topic I learned: JavaScript Ternary Operator “A poor man’s if statement”</strong></h3><p>This topic is interesting. I talked about the if/else statement, but what if I told you that there is a way to shorten the if statement? Cool right? So basically if you ever want to use a shortcut instead of using a if statement, then try the ternary operator! I could of talked about this operator when I was talking about operators above, but since I talked about if statements this seems like an appropriate spot. Basically, the ternary operator is the only operator that takes <strong>three</strong> operands which is: a <strong>conditional </strong>followed by a question mark <strong>(?), </strong>then a expression that executes if the <strong>condition </strong>is true which is then followed by a semi-colon <strong>(:) </strong>and finally the expression that will be executed if the condition is false.</p><p>The syntax of a ternary operator looks like this :</p><p>condition ? expressionIfTrue : expressionIfFalse</p><p>Lets use a real world example instead of pseudo-code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vDF2Wng2l059slPjWTrL1Q.png" /></figure><p>This is basically saying “Hey, if myAge is greater than 20 write ‘The age is higher than 20’ or else write ‘The age is not higher than 20’. It is not a huge shortcut for a if statement but the less code you have to write the better!</p><h3><strong>Conclusion</strong></h3><p>Overall, this has been a interesting week and I learned important concepts. I know that things will get harder to grasp as I keep learning but that’s the fun part. I left out a few topics that I learned such as operator precedence, truthy and falsey values, and switch statements. I did not want this post to be extremely long so I focused on my favorite topics so far. For the record, I am in no way an expert I just wanted to put this article out there because there are someone that might enjoy it. If only one person gets something from this I will be satisfied and if no one gets anything from this then at least I am still drilling these concepts in my head by trying to explain them.</p><blockquote>Follow Me on <a href="https://www.instagram.com/thedevnick/">Instagram</a> and <a href="https://www.facebook.com/TheDevNick/">Facebook</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ec4e0cb2bee" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>