<?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 Cory Adams on Medium]]></title>
        <description><![CDATA[Stories by Cory Adams on Medium]]></description>
        <link>https://medium.com/@coadams9?source=rss-870b26dfdaee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ub0Ead35ubPF91wU</url>
            <title>Stories by Cory Adams on Medium</title>
            <link>https://medium.com/@coadams9?source=rss-870b26dfdaee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:08:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@coadams9/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[Git Flow for noobs]]></title>
            <link>https://medium.com/@coadams9/git-flow-for-noobs-ade467a60011?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/ade467a60011</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 23:11:10 GMT</pubDate>
            <atom:updated>2019-10-16T23:11:10.373Z</atom:updated>
            <content:encoded><![CDATA[<p>So you’ve seen it on every application everywhere. You’ve heard it in interviews, “how are you with Git Flow?” What even is git-flow? What is git? To a new developer, when you’re trying to learn OOP, and SQL, and Closure, and Promises, and instance variables, and any one of the other seemingly endless things you could learn, keeping up with git-flow can feel like, “really ya’ll?” It was definitely like that for me when I began. Little did I know, it’s one of the most valuable tools out there. I’m going to try to provide a guide to git with most everything I have learned so far(everything would be a blog far too long to care about) and keep it to a must-know level.</p><p><strong>What is Git?</strong></p><p>“Git is a <a href="https://git-scm.com/about/free-and-open-source">free and open-source</a> distributed version control system designed to handle everything from small to very large projects with speed and efficiency.” But what is it tho? To me, you can picture git as a 3d mapper from code on your laptop in front of you to a giant hologram image in the sky. Picturing it as 3d mapper helps me to keep in mind how easy it is to manipulate this giant hologram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkla4FUC4r866yiNifv8Jg.jpeg" /></figure><p>Git is a way to control your workflow and collaborate with others on that work. Everyone(who’s included as a collaborator) has access to the hologram. They can add to it or remove from it. It’s a “single source of truth” amongst programmers.</p><p><strong>git add. commit. push.</strong></p><p>These commands are the ones that I find myself using most often. They are typed like so.</p><p>git add . or git add &lt;filename&gt;</p><p>The add command in git is a way of taking any work you have done on your local machine and adding it to a “staging area.” This staging area is comparable to gathering everyone for a photo before you actually push the button. Before you take a picture and send it to be added to that hologram in the sky, you first have to get everyone together.</p><p>git commit -m &#39;notes about the commit&#39;</p><p>So once you finally have everyone together it’s time to push the button. Committing your work saves it to your local history. So say your first picture of person A and B is like this, ‘AB’. You then run into a few more people and want to take another picture. You get them all together, git add ., and then you snap the picture, git commit -m &#39;added my uncles and aunts&#39;. Your picture and commit history now looks like this:</p><p>‘AB’(you still have your original) =&gt; ‘ABCD’(after adding more people)</p><p>Committing allows you to still have access to your previously committed work while also updating your current picture with the new people. This is why I keep the whole 3d mapper to hologram in mind. What you’re looking at is the most current version of the picture, but you can still have access to everything you did prior to what you’re looking at.</p><p>git push</p><p>This is the big one. This is when you take all your work and “push” it to the hologram in the sky. It’s now official(for the most part). Usually, once you push your code it’s being pushed into/onto an active server or website or mobile app, etc. This is comparable to a plate of food you ordered being put onto the table. Once it’s on the table it’s out for public use/enjoyment and is expected to taste/work well. Your code is pushed to the hologram and overwrites what’s on the hologram. If you have a website that previously had picture ‘AB’ on it and you git push pic ‘ABCD’, your website is updated to now show pic ‘ABCD’. This is the general workflow.</p><p><strong>Branches</strong></p><p>Understanding branches is VITALE! Branches allow you to make changes to your code and not worry about changing what’s on your master branch. It’s like using a different memory card in the camera to take the picture. It’s an amazingly useful tool. When you originally start writing code you’re on what is known as your “master” branch. This branch is automatically configured to track your remote master branch as well, meaning pushes and pulls will(unless otherwise instructed), be done in relation to this branch.</p><p>One thing about writing code, “fixing” a problem, or “adding” a feature, can break evvvverything! The sad thing is these problems can “hide” within your code and you won&#39;t know it’s not working until you’re several lines of code in and with several new files created/deleted. In short, you’ll have no idea what you did while trying to “fix” one thing that broke everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*5uWRgnCpxLVsboktTgDksg.jpeg" /></figure><p>Such is life. This is where being able to use branches comes in for the big save. I’ve gotten to the point now where when I start working on something, once I’ve changed about 5 lines, I have an almost nervous tic. A little voice that says, “hey, you’re going to break everything, you know that don’t you?” If you do it once, you’ll never do it again. I stop what I’m doing and switch branches immediately.</p><p>git checkout -b branchname</p><p>This single line typed into your terminal can and will save you a large headache later on. If you’re about to “fix the login form real quick”, git checkout -b loginformfix, “add a search feature that I should be able to finish before lunch”, git checkout -b addingsearch. Just do it. I learned the <strong>extremely</strong> hard way! What this does is allow you to add that code to a kind of copy of your code and not touch the original. Once you are done fixing something or adding a feature and you’re sure everything won’t break you can git merge it into your master branch. This workflow will save you a headache.</p><p><strong>Merging</strong></p><p>Merging, as previously noted, is when you take that copy(branch) of code and combine it with another copy(branch) of code. When applications start to get larger you’ll want to use a workflow like this. This style is what puts your code that may be on separate branches back into one cohesive working tree. Generally, the flow will be:</p><ol><li>Decide you need a NavBar.</li><li>git checkout -b navbar- makes a different copy of your code and switches you over to that copy/branch.</li><li>Type your awesome amazing code to add your super cool NavBar!</li><li>git add . + git commit -m &#39;added the NavBar&#39;- This commits the changes to the history being tracked on the navbar branch.</li><li>git checkout master- switches you back over to the master copy/branch of your code(things will disappear when you do this because you are going back in time to an older/different version).</li><li>git merge navbar- now that you’re back on master you can merge into that branch from other branches. This will take all the code that you wrote on the navbar branch and copy it into the master branch.</li><li>git branch -d navbar-Deletes the branch you name. It is usually a good idea to remove the branch you were working on because it can get confusing down the road to have eight different branches, unless you plan on adding more to it, in which case, you can add just git checkout -b addingToNavbar.</li><li>git push- Pushes your local changes through that “3d mapper” and adds them to the hologram on the remote branch, thus building up what the world now sees.</li></ol><p><strong>Pulling</strong></p><p>git pull. This command pulls down the changes from a remote repository. It’s the opposite of git push. This is helpful for getting the remote changes from a branch and “pulling” them to your local branch. This is useful if you are collaborating with another developer and you are both pushing things to the master branch as you go. Before you can push anything you must first have the code that’s on the remote branch. If the remote branch is ahead of your local master branch you won’t be allowed to push anything until you pull the changes. This happens to avoid merge conflicts and helps to keep both of you on the same page.</p><p><em>Remote Branch Master: 1 =&gt; 2 =&gt; 3 =&gt; 4</em></p><p><em>Local Branch Master: 1 =&gt; 2 =&gt;3</em></p><p>In order to push my changes from my number 3 commit, I must pull down the changes that are the number 4 commit. Once I have these changes I’ll be asked to fix any “merge conflicts”, these are usually something along the lines of if I wrote in my code the button should be blue, but my partner wrote the button should be red. Git is saying, “Hey, you two need to decide which color the button should be! I can only do so much!” Once we decide on a color(blue), I can now push my code with my changes from commit 3 and have it merge into that hologram, which now has a blue button. :)</p><p><strong>Cloning</strong></p><p>One of the essential steps to getting anything even started is cloning a repo. This is pretty straight forward. I’m making a clone of that remote hologram that exists and already and “cloning” it down to my laptop. This is the first thing you will do in most situations unless you’re building your own from scratch. However, if you’re joining someone and being a collaborator on a project you’ll want a copy to work on yourself. This is what cloning does. It’s saying, “Hey, give me a copy of that so I can work on it too.” You can type it something like so:</p><p>git clone <a href="https://github.com/username/repo-name">https://github.com/username/repo-name</a></p><p><strong>Forking</strong></p><p>Another important first step is forking a repo. Forking a repo creates a repository on GitHub under your username which you can then cloned. This is for if your plan is to not directly be a contributor but to maybe work on the project yourself. It’s important to note the major differences between the two. Forking is a Github to Github thing. Cloning is a GitHub to local machine thing. Forking is done all by pushing a “Fork” button on GitHub.</p><p>This is a basic rundown of git-flow and some of the most basic commands. I think if you know this much you can effectively use git.</p><p>Here are some of the other random’s I use frequently and my “go-to’s.”</p><p>git stash- I’ve found this helpful for temporarily storing changes I don’t want to commit at the moment. This creates a kind of “off to the side” branch that you may want to keep but don’t want to commit to the current history.</p><p>git stash apply- Will allow you to apply your stashed code to the HEAD of a current branch.</p><p>git branch -a-shows you all the branches both local and remote</p><p>git branch -vv-shows you all of your branches and where they are pushing/pulling to/from.</p><p>git reset &lt;commit-name&gt;- Takes the commit you specify and moves it to be the current HEAD while un-staging any local differences and keeping them. This allows you to do a kind of…well, reset to a different point of your history, but keep all the changes you have currently. This is helpful to compare an older version of your code to a current one. Side note: <em>git reset --hard &lt;commit-name&gt;will throw away any current committed code that is ahead of the reset.</em></p><p>git branch -u &lt;upstream/branch&gt;- This sets the current branch to track the remote branch you tell it to.</p><p>git status -sb- Shows you <strong>only </strong>the local branch you are on and where it’s pushing.</p><p>git config push.default &lt;option&gt;- It allows you to set where you want a branch to push to.</p><blockquote>Side note. The importance of the tab key cannot be overstated. While learning Git I would reccomend just pushing tab at complete random and seeing what happens. It will auto complete a bunch of commands for you so you can get a clear idea of what options are available. I STILL do this and probably will forever! Hey, sometimes you just gotta push the damn buttons and see what happens!? True Story.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ade467a60011" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form Validations React Hooks]]></title>
            <link>https://medium.com/@coadams9/form-validations-react-hooks-fa48b4869fbb?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa48b4869fbb</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Wed, 09 Oct 2019 23:53:10 GMT</pubDate>
            <atom:updated>2019-10-10T16:29:30.378Z</atom:updated>
            <content:encoded><![CDATA[<p>I wrote my first client-side validations for forms in React a few days ago. About midway through the process, I decided to change up one of my older applications to use hooks instead of the older React Lifecycle Methods. I wanted to add it to one of my projects just to make sure my database was getting the right information. I’ll walk step by step through what I did here in order to achieve this and include all of the fun things I learned!</p><ol><li>Know how React Hooks work. If you don’t, don’t worry, I’ll provide a brief description of how I used it and getting it setup. You can make use of one of the hooks by including this line at the top of the component you want to use the hook in. import React, {useState} from &#39;react&#39; This line of code allows you to use the React hook useState throughout all of your code. Mine looks something like this:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*B2KDQLBiLakx1Cnn_6LH_Q.png" /></figure><p>Two really cool things about using hooks are that you, 1. Do not have to make your components classes, and 2. You can have multiple states that handle different things. I used number 2 quite a bit while building out my form validations. The hook useState always returns two variables that allow you to 1. Get your entire state object, and 2. Change properties of that state object. This is an example of the syntax.</p><pre>const [state, setState] = useState({ dog1: &#39;Dixie&#39;, dog2: &#39;Rover&#39; })</pre><pre>const [owner, setOwner] = useState({ owner1: &#39;Tom&#39;, owner2: &#39;CJ&#39;})</pre><p>I included two separate states here to show you how you can use more than one. Now at any point in my code, I can call state.dog1 and use the value &#39;Dixie&#39; or owner.owner1 and get &#39;Tom&#39;. This beats this.state.dog1 or the even more verbose, going through the process of destructuring the object and then calling it inside of the render. You can also set any state object by calling the second variable returned from the array. So, setState or setOwner can be called like so. setState({ ...state, dog1: &#39;Rover&#39; })</p><p>Two gotchas with this I’d like to be clear on. 1. setState is <strong>ASYNCHRONOUS!! </strong>Meaning you should be wary of where you call it and what’s happening around it, because…JavaScript. 2. If you notice above I used the spread operator to return the previous state. This is because setState when using hooks, does not replace just one property like the previous version, this.setState({ select a property: &#39;change to this value&#39; }), it instead changes the <strong>ENTIRE OBJECT! </strong>So, setState({ dog1: &#39;Cookie&#39; )} will <strong>overwrite the entire state, </strong>changing the entire state object to dog1:&#39;Cookie&#39; and removing dog2: &#39;Rover&#39;, unless you “spread” out the previous properties using the “spread” operator first and then select one with the same name to overwrite. I hope this saves someone some time. :) P.s. There is much more to learn on Hooks but since this is a blog about form validations I’m limiting it to what I need for this blog. Feel free to read more or check out my previous blog for more depth on the different hooks!</p><p>2. Add a place in your render for your errors to show if they are present. A controlled form generally looks something like this.</p><pre>&lt;Form&gt;<br>    &lt;Form.Input onChange={handleChange} value={somevalue} /&gt; <br>&lt;/Form&gt;</pre><p>When making a form for form validations it should look something like this.</p><pre>&lt;Form&gt;<br>    &lt;Form.Input onChange={handleChange} value={somevalue} /&gt;<br>    &lt;div&gt;{errorState.nameError}&lt;/div&gt;</pre><pre>    ....other inputs structured this way.</pre><pre>&lt;/Form&gt;</pre><p>Having this here will allow your form to show errors if the user tries to submit a form that isn’t valid(which we’ll get to soon). This part of your code will only render if the value is truthy so you don’t have to worry about it showing if nothing is there which takes me to my next step.</p><p>3. Create an “error state”. When I was making these form validations I found a bunch of posts about using one state and creating an object like so:</p><pre>state = {<br>   name: &#39;&#39;,<br>   nameError: &#39;&#39;,<br>   email: &#39;&#39;,<br>   emailError: &#39;&#39;<br>}</pre><p>The problem with this for me was that I was using my state as part of a ‘POST’ method to send data. I didn’t want to send back extra empty properties once the user had filled out the form correctly, hence I decided to use Hooks! Using hooks allowed me to create an entirely different state object just for rendering errors. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*8-pXMQ7Fz16eI7Crg7nuAA.png" /></figure><p>Incredibly useful! I created two different states and didn’t have to worry about it messing up my POST to the backend. You can see that properties in the two state objects mostly correspond with one another. My intention here is to have a form that asks for “make” and show “makeError” if the user omits it, “modelMake” and “modelError” if it’s omitted, so on and so forth.</p><p>4. Add a const assigned to a function that returns true or false before allowing your form to post. Here you simply need to add a const containing a function to your handleSubmit that returns true or false to allow the post to happen or not. I did it like so:</p><pre>const handleSubmit = (event) =&gt; {<br>    event.preventDefault()<br>    <strong>const err = validate()</strong><br>    if (!err){<br>        fetch(localhost...)<br>        ...rest of your code...</pre><p>Here I’m only allowing my fetch to happen if this validate function is false or, “IF there are no errors, run this function”.</p><p>5. The fun part! Write the validate function. This is the part where we actually write the logic that decides if the form should show errors or not or if the fetch should happen. A condensed version of mine:</p><pre>const validate = () =&gt; {<br>    let isError = false</pre><pre>    const errors = {<br>        makeError: &#39;&#39;,<br>        modelError: &#39;&#39;,<br>        yearError: &#39;&#39;,<br>    }</pre><pre>    if(!state.make){<br>        isError = true<br>        errors.makeError = &#39;Please enter Car&#39;<br>    }</pre><pre>    if(!state.modelMake){<br>        isError = true<br>        errors.modelError = &#39;Please enter Car Model&#39;<br>    }</pre><pre>    if (!state.year){<br>        isError = true<br>        errors.yearError = &#39;Please enter Car Year&#39;<br>    }</pre><pre>    setErrorState({ ...errorState, ...errors })</pre><pre>    return isError<br>}</pre><p>Here, the first thing I did was create a “checker” with isError. This will allow me to return true or false based on whether or not there is an error. Remember when I talked about the validate function and how it needs to return true or false and “IF there are no errors run this function”? This is what will keep track of true or false. If at any point during the running of this function one of my “if” statements is indeed false, meaning that the user has not typed in anything into the associated input and that value has not been updated in the state object, I’m changing isError to true and also updating the corresponding property on my object ‘errors’ to equal a now “truthy” value with the “Please enter …”. I then go on to update my errorState using setErrorState({ ...errorState, ...errors }). Here, as mentioned before I use the spread operator to 1. return the previous state, and 2. update it with any new errors.</p><p>To break this down a bit more, here is what is actually happening. ...errorState returns makeError: &#39;&#39;, modelError: &#39;&#39;, yearError: &#39;&#39;, colorError: &#39;&#39;... when I spread out the errors ...errors , all I’m doing is putting those key-value pairs into the errorState object. If all those if statements get run it would be: makeError: &#39;Please Enter Car&#39;, modelError: &#39;Please Enter Model&#39;, yearError: &#39;Please Enter Year&#39;. When operating on objects if you call the same key and assign it a value the key-value pair is over-written, hence updating the errorState with a new value.</p><p>When the user clicks the submit button and this function returns true, my fetch never happens and the state is updated with these new error values. When state is changed the page re-renders and all of those old &lt;div&gt;{errorState.nameError}&lt;div&gt; or in my case &lt;div&gt;{errorState.makeError}&lt;/div&gt; are now truthy so they render on the page. You also handle the case in which the user fixes one thing and leaves another blank because each time they click the submit button the const errors object inside of validate gets reset with falsey values. If there is no error for that specific input the value is now falsey and disappears from your render!</p><p>This was my experience learning form validations using React Hooks. Super cool stuff!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa48b4869fbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ruby Keyword Arguments]]></title>
            <link>https://medium.com/@coadams9/ruby-keyword-arguments-9c77f82b79a4?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c77f82b79a4</guid>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Fri, 27 Sep 2019 00:47:39 GMT</pubDate>
            <atom:updated>2019-09-27T00:47:39.239Z</atom:updated>
            <content:encoded><![CDATA[<p>As most know Ruby allows you to define methods. These methods to are used to do just about anything we want them to. Also as most know, Ruby lets you define and call these methods with arguments. Until Ruby 2.0, methods could only be defined with positional arguments and an optional hash parameter. This would look something like this.</p><pre>def say_pets_name(name = &#39;Sparky&#39;)<br>   puts name<br>end</pre><pre>say_pets_name # =&gt; Sparky<br>say_pets_name(&#39;Tobi&#39;) # =&gt; Tobi</pre><p>The say_pets_name method is defined with a default argument of Sparky . When I call say_pets_name with no arguments I get that default value of Sparky. When I call it with an argument passed in it overwrites that default argument and I get back Tobi. This was the way things were done up until Ruby 2.o was released. This introduced a new way of both defining methods and calling them with their arguments. I’ll re-write the code above with the new named argument syntax.</p><pre>def say_pets_name(name: &#39;Sparky&#39;)<br>   puts name<br>end</pre><pre>say_pets_name # =&gt; Sparky<br>say_pets_name(name: &#39;Tobi&#39;) # =&gt; Tobi</pre><pre><em>note: Now saying say_pets_name(&#39;Tobi&#39;) will not work because you named the argument and it now must be called as a named argument.</em></pre><p>That wasn’t that hard huh? Nope. At first glance, it may seem as if you’re writing more code. What you’re actually doing, at least in my opinion, is making your code much more readable when you’re calling your methods. Let&#39;s take a look at why I believe this makes your code more readable. Say you have some code like this.</p><pre>def allergies(ok, not_ok)<br>   @ok &lt;&lt; ok<br>   @not_ok &lt;&lt; not_ok<br>end</pre><p>Here you have a method that could be somewhat confusing when calling it later on and just so happens to be kind of important! With the method defined as it is, it would be very easy later on to type:</p><pre>person.allergies(&#39;dairy&#39;, &#39;nuts&#39;)</pre><p>If this person said they were very allergic to dairy but nuts were ok, you might have a lawsuit on your hands. This is what named arguments help clear up. If you defined the method like this:</p><pre>def allergies(ok:, not_ok:)<br>   @ok &lt;&lt; ok<br>   @not_ok &lt;&lt; not_ok<br>end </pre><pre><em>note: You can still give the arguments a default value when the method is being defined like `not_ok: nil`.</em></pre><p>Now, whenever you call this method you MUST call it with those NAMED arguments. So now it’s:</p><pre>person.allergies(ok: &#39;nuts&#39;, not_ok: &#39;dairy&#39;)</pre><p>This adds explicitness to the code and makes it much harder to make small mistakes as you type. Every time you call this method later on you have to explicitly type the keywords ok: and not_ok:. This makes it very hard to mess this up. It also makes for much better readability when you’re 100 lines away, three tabs over to remember what’s going on. If you see cory.allergies(&#39;nuts&#39;, &#39;onions&#39;) as opposed to cory.allergies(ok: &#39;nuts&#39;, not_ok: &#39;dairy&#39;), you will have a much better understanding of what is actually going on much later in the code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c77f82b79a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS to Scss!!]]></title>
            <link>https://medium.com/@coadams9/css-to-scss-1430c1692556?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1430c1692556</guid>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Mon, 16 Sep 2019 21:08:08 GMT</pubDate>
            <atom:updated>2019-10-10T16:02:57.211Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started to learn how to code, it was plenty difficult. It, as a matter of fact, still has its moments. I remember in particular building out my first Rails app along with one of my fellow students. Getting the routes to work, the forms to show up, the buttons to do the right things, so on and so forth, was all hard enough by itself. Then we finally got the program up and running and realized that it looked like absolute….it didn’t look good, but we were so happy that it was up and running we thought that the styling would be the easy part. I mean, how hard could it be? I’ve used powerpoint before! “What, do you just drag and drop some things here and there?” Short answer, NO. You do not “just drag and drop things here and there”. We even tried to use Semantic-UI and Bootstrap for the styling. We, collectively, spent hours trying to get it to work and eventually just gave up(there was no time left to work on the project I mean). Hey, it wasn’t pretty, but it worked. Fast-forward almost a year, and my skills have grown by leaps and bounds. I went back and redid that project because I couldn’t bear to leave it like that. I now know so much more CSS and have so much fun with it, I can’t believe how much I used to not know. What follows is some of what I’ve learned over time.</p><p>One thing I have to mention is the vs code extension “Live Sass Compiler”. This extension takes your Scss and maps it to CSS! This blew my mind! So, even though my skills with CSS and Scss have grown, I ran into a problem recently with cross-browser functionality. Meaning I can build a website using chrome and it might look entirely different on another browser. Needless to say, this is a major headache. To build an awesome looking website on your screen and then to open it on someone else&#39;s CPU and have it look awful. What Live Sass Compiler does is help alleviate some of those problems. It can transform your Scss into a more multi-browser compatible CSS that other browsers can read. Here’s an example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1ad826b7a6e72d2d03d5d6b659540b8/href">https://medium.com/media/a1ad826b7a6e72d2d03d5d6b659540b8/href</a></iframe><p>I write some Scss that looks like the above snippet of code. By using the Live Sass Compiler it maps this Scss to CSS that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*c_0segKTLGR6-DXKwdkmsg.png" /></figure><p>You can see here that it automatically adds some CSS code for different browsers which is really cool! Now, here are a few things I’ve learned about using Scss.</p><ol><li>Nesting. Yes, that’s right. Scss allows you the ability to nest code which is super interesting. To take it back a bit, in regular CSS if I have some HTML/JSX that is written like so:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*dyiI-C8h3S0YWaYLEdbV6w.png" /></figure><p>In order to get to my profile pic before I might have to do:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*EHkLGtsibb6-FPERhnKMYQ.png" /></figure><p>The problem with writing CSS like this is that it can quickly get out of hand and it’s easy to lose track of where things are. When your CSS gets to 7 stylesheets and each stylesheet has 100 lines of code it can become difficult to find what you’re looking for. This is where nesting comes in. It allows me to write my code like this:</p><pre>.landingPage {<br>  display: flex;</pre><pre>  .background {<br>    background-image: url(https://medium.com/images/profilePic.jpg&quot;);<br>    background-size: cover;<br>    height: -webkit-fill-available;<br>    width: -webkit-fill-available;<br>    display: flex;<br>    flex-direction: column;<br>    justify-content: center;<br>    align-items: center;<br>    position: relative;</pre><pre>    .middle-container{<br>      display: flex;<br>      flex-direction: row;<br>      justify-content: space-evenly;<br>      width: -webkit-fill-available;<br>      margin-left: 10px;<br>      margin-right: 10px;<br>    }</pre><pre>    .profilePic{<br>      background-image: url(https://medium.com/&#39;../../images/cory.jpg&#39;);<br>      height: 24em;<br>      width: 33em;<br>      background-size: cover;<br>    }</pre><pre>}</pre><p>Here you can see the different classNames are nested inside of their parent classes. This makes for much better readability and makes it much easier to keep track of what’s what. I personally love it.</p><p>2. Variables. With Scss you can also use variables. This allows you to set variables that are like global variables and use them anywhere in the Scss file. Here’s an example:</p><pre>$primaryBtn: red;<br>$hoverBtn: green;</pre><pre>header{<br>    background: lightblue;<br>    display: flex;<br>    justify-content: center;<br>    button{<br>        background: $primaryBtn;<br>        &amp;:hover{<br>            background: $hoverBtn;<br>        }<br>    }<br>}</pre><p>This code allows me to set variables with the use of the ‘$’ sign. Above, I’m going into my header tag, and in the “button background” nest im using the variable “$primaryBtn” to set the initial background color of the button to red, which is what I set that variable to mean at the very top. You can also use the “&amp;:” to set other actions on the button so, where I use “&amp;:hover” inside of the button nest is saying that when this button is hovered over change the background color to green. This makes writing CSS so much easier and it&#39;s, again, so much easier to keep your code organized.</p><p>3. “@mixin”’s. mixins are like JavaScript functions, in that they allow you to write some code inside of a block and use the return value of that function inside of your Scss styles. Heres an example:</p><pre><a href="http://twitter.com/mixin">@mixin</a> center {<br>    display: flex;<br>    justify-content: center;<br>    align-items: center;<br>}</pre><pre>header{<br>    <a href="http://twitter.com/include">@include</a> center();<br>    background: lightblue;<br>    button{<br>        background: $primaryBtn;<br>        &amp;:hover{<br>            background: $hoverBtn;<br>        }<br>    }<br>}</pre><p>In the above code I am taking out the “display, justify-content, and align-items” rules from the “header” tag and separating them into their own “mixin”. This works like a function. Then I include the mixin into the style properties of the header tag in the form of “@include center()”, (ha, you even invoke it like a function). This then returns those properties inside of the header tag and gives “header” access to those properties. I can now use the “@mixin” function anywhere and it will add those properties.</p><p>4. Custom parameters. Inside of the mixin you can even pass parameters like a function. You can do this like so:</p><pre><a href="http://twitter.com/mixin">@mixin</a> center($direction, $height) {<br>    display: flex;<br>    justify-content: center;<br>    align-items: center;<br>    flex-direction: $direction;<br>    height: $height;<br>}</pre><pre>header{<br>    <a href="http://twitter.com/include">@include</a> center(column, 100vh);<br>    background: lightblue;<br>    button{<br>        background: $primaryBtn;<br>        &amp;:hover{<br>            background: $hoverBtn;<br>        }<br>    }<br>}</pre><p>Here, in the mixin definition, I am giving it an argument of “$direction, $height” and assigning those arguments to the value of the flex-direction and height properties. When I call “<a href="http://twitter.com/include">@include</a> center(column, 100vh)”, im passing in arguments to let my mixin know I would like it to use the flex-direction value of “column” and the height value of “100vh”.</p><p>These are some of the things I have learned about Scss while using it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1430c1692556" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lexical scoping, “let”, “const”, and “var”]]></title>
            <link>https://medium.com/@coadams9/lexical-scoping-let-const-and-var-4a8c4271eb82?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a8c4271eb82</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Thu, 15 Aug 2019 16:08:58 GMT</pubDate>
            <atom:updated>2019-08-15T16:08:58.986Z</atom:updated>
            <content:encoded><![CDATA[<p>This stuff is tricky. I’ve recently decided to go back and take a more in-depth look at scoping in JS. JS being my preferred language, there are things I actually use all the time without knowing completely why I was using them. I was taught to never use the keyword ‘var’, soooo…I didn’t. I knew I had to declare things I wanted to use inside of other functions at the top of the page, but not 100 percent sure why. I’d chalk this up to learning in the time frame in which I did, which was blazing fast. I was definitely taught the best practices, and they work assuredly, but now with more time on my hands, I wanted to go back, refresh and increase my overall understanding. What follows is my attempt to explain some of these topics.</p><p>Lexical Scoping. Sigh…What even is lexical scoping. What does lexical mean, number one? Lexical is defined as “relating to the words or vocabulary of a language.” What?! What does that even have to do with programming?! “You’re killing me, Webster!” is what I first thought when trying to put together these pieces. Then I found something a little more useful. Lexical does mean that relating to words jargon above but in terms of programming it means, “Having to do with the words you(the programmer) typed when you defined the function.” Another useful tidbit is, “A function doesn’t care where it was invoked, only where it was defined.” This gets me back to the “Lexical” part. The words you type on the screen and where you type said words give the function it’s scope. This is my understanding in a nutshell. An example of this is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa43d8b557e51090669f6f4c5086dbb9/href">https://medium.com/media/aa43d8b557e51090669f6f4c5086dbb9/href</a></iframe><p>The above code logs “inside one and num is 6”. Let us walk through it.</p><p>On line 14 function two is invoked, this sets a local variable to two()’s scope called “num” and sets it equal to 3. Then “one()” is called and that logs the “inside one and num is 6” part. So when I first saw this code I thought that ‘num’ would equal 3 because it was called first inside of the ‘function two()’. I was wrong clearly..lol(happens often, I’m used to it). What I learned tho was that ‘function one()’ has no idea what is going on inside of ‘function two()’. Although function two() calls function one() function one() still has it’s own scope. When it goes to find a value for ‘num’ it first looks inside of its scope and then traverses up to the outer scopes. Function two() has its own scope and function one() can’t get inside it to see what “num” is so it looks upward and outward. This is actually the first thing it does, I just wanted to make it clear that one() cannot see what’s going on inside of two(). It looks up and finds the global ‘const num = 6’ and says “ok, this is the only “num” I have access to so this is what I&#39;m going to use.” This is what I mean when I say a function doesn’t care where it gets invoked, only where it’s defined.</p><p>If I were to change the code above to look like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3eb26b7bcf9cf2493a9c335e613aa38d/href">https://medium.com/media/3eb26b7bcf9cf2493a9c335e613aa38d/href</a></iframe><p>Here I’ve changed two()’s scope to know about one(). If you invoke one() you’ll get “inside function two and var is function ones scope changed me”. Why? Because function two() is now inside function one(). Meaning, when it goes to look for the next level up where “variable” is defined it first finds ‘function ones scope has changed me’, and not the global variable definition of ‘global’. Your code will bubble up and outwards until it gets to the outermost level it can. You can also picture it with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3d20fce1e0f83191dc52cb3ecb1de3d/href">https://medium.com/media/e3d20fce1e0f83191dc52cb3ecb1de3d/href</a></iframe><p>Everything in between the curly braces is a new scope. When I try to console.log(x) it looks inside of its own curly braces and can’t find x so it continues to move up. The first thing it finds is ‘x = 3’ so that’s what it uses. In the above example, I use the keyword var, note var is not “block” scoped so I could use it outside of these blocks elsewhere. It is however function scoped!</p><p>Keywords “let”, “const”, and “var” all do different things in JS. It’s important to know what each does and when to use them. We’ll start with “const”. The <strong>const</strong> keyword is used when declaring or defining a variable. It is used if you want to set something that will <strong>not</strong> change. It is a constant in your function. If you assign a variable with const, it means you cannot change it later. So “const arr = []” will always be an array and will not ever change. The content inside of the array may change but what you assign that variable to be will be what it remains as for its entire duration.</p><p>The <strong>let </strong>keyword means that you are allowing this variable to change to have a new identity while you’re using it. So “let i = 0” is a very common use. It will allow the value of “i” to change over the course of your program. This is very helpful when you’re trying to change something over and over again, such as counting items. For instance:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cbc4bb8d134c8e3a209abea085cb740/href">https://medium.com/media/6cbc4bb8d134c8e3a209abea085cb740/href</a></iframe><p>In the above example, both “count” and “i” are assigned using the <strong>let </strong>keyword. This allows both of their values to change throughout their duration. Inside of that for loop, “i” is changing and allowing you to iterate through each item. Also, “count” is changing in the for loop to allow you to add up each item.</p><p><strong>Var </strong>an interesting one. The var keyword, as far as I know, is one you should use as little as possible. Var creates variables that are <strong>not </strong>block scoped. Meaning that if you use <strong>var </strong>outside of or inside of brackets you will create a global variable. If it’s used inside of function scope the variable will become scoped to that function, meaning it’s accessible everywhere inside of that function. If you use it outside of a function you create a global variable attached to the window. This can be bad because you create a variable that can be changed anywhere else in the function. Typically you’d like for your variables to be only available in the scope that you created them in.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd58ff215c2af271ed2c6cc795eaae6b/href">https://medium.com/media/dd58ff215c2af271ed2c6cc795eaae6b/href</a></iframe><p>In the above example, I still have access to the variable ‘x’ because var is not block-scoped, whereas if I defined that variable with the keyword <strong>let </strong>or <strong>const</strong>, it would not be accessible outside of those brackets. These are some of the things I have found out about lexical scope and the var, let, and const keywords in JS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a8c4271eb82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recursion]]></title>
            <link>https://medium.com/@coadams9/recursion-f6f3a967af1b?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6f3a967af1b</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Sun, 11 Aug 2019 20:25:46 GMT</pubDate>
            <atom:updated>2019-08-11T20:25:46.325Z</atom:updated>
            <content:encoded><![CDATA[<p>There&#39;s a topic that had me in perplexed for a while so I decided to explore a little bit more about it. That topic is the one of Recursion. I first heard about this during my time in school, but never really had a bunch of time to explore what it really meant. Now, with all of my spare time, I’ve done a bit more research into it. Here’s what I’ve found so far.</p><p>Recursion is when you call a function inside of itself in order to solve a problem. Meaning that the function calls itself while running. What do I mean by this? Let’s say you wanted to do something very basic, like add some numbers. You could always do something like this:</p><pre><strong>const</strong> addNumbers = nums <strong>=&gt;</strong> nums.reduce((a, b) <strong>=&gt;</strong> a + b)</pre><pre>//OR</pre><pre><strong>const</strong> addNumbers = nums <strong>=&gt;</strong> {<br>   <strong>let</strong> total = 0<br>   for (<strong>let</strong> num of nums) {<br>     total += num<br>   }<br>   return total<br>}</pre><p>These are the ways that first come to mind for me when I first consider adding some numbers. To explore Recursion, I’ll try to do the same thing except recursively. In the below example, I’ll add some numbers but I’ll expect to simply add all the numbers in between that number and zero for readabilities sake.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9f4fe9c1d464c95e4186c136a0211c7/href">https://medium.com/media/c9f4fe9c1d464c95e4186c136a0211c7/href</a></iframe><p>Inside of this function ‘addNumbers()’ I&#39;m calling it over and over again until I get to zero. I’m simply returning the number that I pass to it as an argument and then calling it again with the next number down all the way to zero. If the function ever reaches zero it will just return zero.</p><p>In JavaScript, we have what is called the Call Stack. Recursion works by adding each function onto the stack and then waiting until it can resolve this function before popping it off. So you end up with a stack that looks kind of like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*mbX-mBbI8_skeEfMiu54yg.png" /></figure><p>And once each one of these functions evaluates you’ll be looking at:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2611db0432366eb72a05875e7721972c/href">https://medium.com/media/2611db0432366eb72a05875e7721972c/href</a></iframe><p>This is the overall idea of how Recursion works. One problem that recursion can have sometimes is the dreaded “Max call stack size exceeded” error. This happens when you have a number too big for your browser to handle. A call stack can only handle so much information before it eventually is too much. Like, if I called this function with “addNumbers(1000000)” then I exceed the maximum call stack limit, which causes an error.</p><p>This is how Recursion works on a pretty basic level. You call a function inside of itself to have it repeat and get a solution, along with some base case so it knows when to stop running.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6f3a967af1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Hooks: useEffect()]]></title>
            <link>https://medium.com/@coadams9/react-hooks-useeffect-3d902999c0ce?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d902999c0ce</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Tue, 23 Jul 2019 16:29:01 GMT</pubDate>
            <atom:updated>2019-10-10T16:42:48.814Z</atom:updated>
            <content:encoded><![CDATA[<p>React is one of the hottest and always evolving newer languages being used by programmers and companies everywhere. One of the newer features of React is that you can now use things called ‘hooks’ to manage things like state, or even replace the frequently used ‘componentDidMount()’ lifecycle method. I’ve been doing some work with some of these new features and this is what I have found out about the react hook ‘useEffect()’.</p><h4><strong>It can take the place of “componentDidMount()”.</strong></h4><p>“componentDidMount” was a way for programmers to control what happened inside of a component once it was mounted. Common things that were usually done inside of such functions were things like API requests. The new useEffect() hook allows you to exclude this method. It is also important to note that useEffect() runs at the same time that componentDidMount ran. It runs after the component has mounted and it takes a function as a callback. No matter where you place it in the functional component it will always run after the component has been rendered on the page. You can use it like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*rGF29u6o938KRo9fTmkP7g.png" /></figure><p>In the above example, I’m telling react to do a fetch to that API endpoint AFTER the component mounts. This is what useEffect does for you, along with granting you the ability to now make the entire component just a function and not a class. You can now safely have:</p><pre>const App = props =&gt; {</pre><pre>useEffect(() =&gt; {<br>     fetch(API)<br>   })</pre><pre>return(code...)</pre><pre>}</pre><pre>export default App</pre><p>“useEffect” will only execute after the return statement here. Now there is one problem with this hook. If I had some portion of the state that I was changing inside of useEffect the component would continually reload. In react, whenever state or props change then the component is re-rendered, therefore if my state changes or props change then the component is going to get re-rendered, during which, the state changes, so the component re-renders, during which, state changes, so-on, and so forth. Hence the problem of being stuck inside of the dreaded continuous loop(which I’ve found is usually a bad thing, your computer breathing hard and spazzing out and things, no one wants that). So how do you stop this from happening?</p><h4><strong>The second argument to ‘useEffect()’</strong></h4><p>The second argument to useEffect is an array of dependencies. This array holds the variables that we tell our function to watch for. If ‘something inside of the array changes’, then, re-execute useEffect, if not, only run it the initial time. The way to be sure useEffect only runs once is to make the second argument an empty array. This would look something like this:</p><pre>useEffect(() =&gt; {<br>   fetch(API)<br>}, [])</pre><p>When you set up useEffect as such you are not giving the method any dependencies to watch for. I think of it almost as saying, if null changes, then do this. Since there is nothing for it to watch for and change it will never re-run.</p><p>These are a few features of the useEffect hook that react now provides.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d902999c0ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visual Studio Code Debugger]]></title>
            <link>https://medium.com/@coadams9/visual-studio-code-debugger-2446eb27d49?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/2446eb27d49</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 02:52:33 GMT</pubDate>
            <atom:updated>2019-07-15T02:52:33.160Z</atom:updated>
            <content:encoded><![CDATA[<p>As most programmers know, or have come to find out, writing perfect code the first time is about as probable as running into bigfoot. Even the most seasoned programmers can often have code that they think will do one thing but often does another. On my path to writing the seamless, perfect, beautiful, fully functional, flawless code I usually write(definitely sarcasm in there somewhere), I often find myself staring at my screen wondering why my code is returning ‘undefined’ or ‘NaN’ or ‘abcd’ instead of “dcba” or honestly any other multitude of things. Someone out there agrees with me! Also, I’d like to point one of the other uses, besides fixing my mistakes, that I love VS code’s Debugger tool.</p><p>…..wait for it…..</p><p>IT ALLOWS ME TO DISSECT PEOPLES CODE WHO ARE MORE EXPERIENCED THAN ME! MAN OH MAN! This is an amazing functionality that I honestly use this for all the time. Having a problem you can&#39;t figure out is painful. Being given a working solution that you can’t figure it out is almost unbearable. Like, I’ve seriously at times wanted to run away screaming. Using VS codes Debugger allows me to do something I seriously love doing.</p><p>Understand what the hell I’m looking at!</p><p>It allows me to slow it down and literally understand every single line of code and what it’s doing. No more trying to keep track of things in my head like, ‘var x’ when ‘x’ is about to change a hundred times because it’s inside of a for loop that takes ever-changing information or part of a reduce function that is doing straight-up magic inside of that function.</p><p>I used to use, and there’s still a soft spot in my heart for, debugging in my applications web-browser console, don’t get me wrong, but VS’s Debugger is a gift from the programming Gods. Here I’ll include some instructions on how to set it up and how I usually use it.</p><ol><li>Add the file name to the ‘{} launch.json’.</li></ol><p>So in VS code, on the sidebar, you have an icon that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*56K_499qXHv5sB5tEdDRlQ.png" /></figure><p>This is the button you want to hit to get to the Debug window to open on the side panel. Once you have this up you’ll want to hit the gear tool along the top left of the screen. This will open the ‘{} launch.json’ tab where it will prompt you to ‘Add Configuration’. Once you click this button you will be prompted to enter in the way you would like to test this file. Depending on the file you’re in, you can pick from a few different ways to run it. I usually go with the “Node.js: Launch Program”. It will automatically add an object to the ‘configurations’ array inside of ‘{} launch.json’. Once you get this far the next important lines are the ‘name’ and the ‘program’ properties. Here, you’ll write up what you want the name of the program to appear as in the Debug box and give it a path to the file to run it. So for instance, if I had a file named ‘index.js’ my screen should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*eS-o6wG_aCN6UIp_jHQeEw.png" /></figure><p>The name property allows me to pick my own name for easy reference and the program property is telling my VS code how to get to where I want it to go. Note you don’t even have to include the ‘.js’ part in the program name.</p><p>2. Run the file in the Debug window.</p><p>Once you have the ‘launch.json’ properly set up the next step is to simply run your program. You’ll want to make sure, as is usually the case, that any functions you want to test are actually being called inside of the program before you run it. That’s it! That is all it takes to use this incredible tool. Now, here is why I like it so much:</p><p>It allows you to set up and watch variables that may change. For instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfR6tJheW9SgV_ARCfu9yQ.png" /></figure><p>Here there is a section in the sidebar that is called “WATCH” where I have some variables set. ‘reversed’ and ‘char’. While my function is executing I can see exactly what is happening all the time. I set whatever variables I want to keep track of set inside of this ‘WATCH’ box. As my function runs through this for loop I can actually see the variables changing and what the updated variables are. This is an amazingly helpful resource to have at your disposal right in your VS code’s browser. You can see your actual code being run through line by line and what is happening. You are also provided with a Debug Console and Terminal which can easily be opened right underneath your code. Here you can ‘console.log’ items and see them print outright as your code is running. You can also choose to step through every single step in your code as it executes. Up at the top of the next pic, you can see the arrows that give you full control over how your code executes the next step as well as my set breakpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Y5O9t6c0BEo3NfvVqsvnQ.png" /></figure><p>This tool has been incredibly useful to me so far and I look forward to, as my skills grow, seeing everything else it can do.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2446eb27d49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Hooks: useState()]]></title>
            <link>https://medium.com/@coadams9/react-hooks-usestate-cc527fdff604?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc527fdff604</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Mon, 08 Jul 2019 05:07:19 GMT</pubDate>
            <atom:updated>2019-10-10T16:36:31.121Z</atom:updated>
            <content:encoded><![CDATA[<p>React is an ever-updating language. It is new and becoming more popular seemingly every day. As most know React uses state. State is used to control the data in the rendering app as well as child components. With the release of React version 16.8, there are now some updates. One of the main differences being that you no longer have to use class methods to control State. First I’ll start with some traditional React code where State is managed inside of a class component and then change it to a functional component and show the newer way of managing state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*die14AedrnFRvhRCtiN8qQ.png" /></figure><p>Here there is a traditional React Component that uses a class component to manage the state. React version 16.8 introduces a hook called useState(). ‘useState()’ allows you to destructure state to look like so:</p><pre>const [boolean, setBoolean] = useState(false)<br>const [list, setList] = useState([choc, dough, sugar, icing])<br>const [money, setMoney] = useState(30)</pre><p>The useState() method always returns two variables, the original state, and the updated state. When you use React hooks you can then change the state by using the second item in the array to update it. For instance, if I had a handler like:</p><pre>const moneyHandler = (amount) =&gt; {<br>   setMoney(amount)<br>}</pre><p>I can call my ‘setMoney’ method inside of that handler and it’ll change my state. Using ‘useState’ also allows you to, as discussed earlier, no longer use strictly a class component. So the updated component without using a class can look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMyynciF3IS_PPgL0bZawQ.png" /></figure><p>As you can see above all of my code is in a const, yet I still have state set and also have a way to change state. If and when the ‘moneyHandler’ const is called it will pass in an argument of ‘amount’ that will change the money value. Also worth noting is that you have to import the ‘useState’ hook.</p><pre>import React, { useState } from &#39;react&#39;</pre><p>This is important as the hook will not work without being imported. This is an overview of my experience with React Hooks so far. I plan on building an app and using ‘useEffect’ in my next project to further explore these methods.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc527fdff604" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loops and Conditionals]]></title>
            <link>https://medium.com/@coadams9/loops-and-conditionals-b62e59f9c397?source=rss-870b26dfdaee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b62e59f9c397</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[loop]]></category>
            <dc:creator><![CDATA[Cory Adams]]></dc:creator>
            <pubDate>Mon, 01 Jul 2019 03:24:15 GMT</pubDate>
            <atom:updated>2019-07-01T03:24:15.354Z</atom:updated>
            <content:encoded><![CDATA[<p>Lately, I have been doing a bunch of practice algorithms to try to prepare myself for coding interviews. What I’ve seen lately, more so than ever before are a bunch of Loops and Conditionals. Loops inside of loops with conditionals to decide what does or does not happen are now a common part of my day to day life, and I’ve gotten a bunch of practice with them.</p><p>What makes loops so useful to programmers is their ability to do things to large amounts of data. Imagine for instance you wanted to simply print out every number from 1 to 100. If loops had not been invented you may end up doing something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*okE-QgdQwt4mdFC79aZVmQ.png" /></figure><p>This is every bit as annoying as it seems. Just typing that little bit annoyed me. Luckily loops were invented. These nifty little guys allow you to tell your program to do things kind of on autopilot. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*ewhC-8P462LsysJ_QE4H2w.png" /></figure><p>This function will console log all of the numbers from 1 all the way to 100, and it only took 3 lines of code vs the 100 I would’ve had to type. Loops were created to make out lives easier and they are an essential part of programming.</p><p>Loops allow us to set up some logic that defines a starting point and an end for our function. In the above example, I say ‘let i = 1’, this means I want my loop to start at one. The second part is the ‘i ≤ 100’, here I&#39;m telling this loop that as long as 1 is less than or equal to 100 I want you to do this, whatever my this is. The next part is ‘i++’, which means to then increment ‘i’ each time by 1. I compare this to grilling vs putting something in the oven. If you’re grilling you can’t leave or you risk the burning the food. With the oven, you simply set the timer and then go sit in front of the tv.</p><p>Another type of loop is the ‘while’ loop. This loop is similar to the for loop it just lets you do something while a certain condition is met. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*bkmA28pW4kseGZB5pSU2yw.png" /></figure><p>In the above function, I set my i = 1 and then instruct my while loop to console log ‘i’ as long as i is less than or equal to 100. Since I started off my function at 1 and then increment it after the console log with the ‘i++’, it repeats as long as the condition inside of the parenthesis is true.</p><p><strong>Conditionals </strong>allow us to set up more logic to let the computer know to do something or not. Conditionals look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*1auKnedp283xJTWpAkekWQ.png" /></figure><p>This conditional will execute the ‘2 is not greater than 3’ because in my logic I said “if two is greater than three do this” because it’s not, the ‘else’ statement runs.</p><p>These are some of the tools programmers have at their disposal to make life easier. There are a couple of things I’ve picked up(and mistakes I’ve made) while learning to use loops that are pretty much just getting better with recognizing how they are used. For instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*610fg1AdLDFJNXPyo9UK9w.png" /></figure><p>A common mistake I used to make would be to put my variable that I’m starting with inside of the loop. If you do this it sets ‘count’ equal to zero each time. You generally do not want this as you are trying to change the value of count. If you make the mistake of putting ‘count’ inside of the array the loop will set it equal to zero each time over and over again. Another mistake I would make is to do this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*ObzXMfXaTLq0R7TeTmnv6Q.png" /></figure><p>You can see here that in the second line with my iteration I typed ‘i++’ instead of ‘j++’. This is a headache you do not want. This would cause my loop to get stuck as ‘i’ would be changing instead of ‘j’. It was a very common mistake of mine until I slowed down a bit. It’s almost muscle memory to type ‘i++’ and it can take some time and practice to remember this small but easy to make mistake, which can throw off an entire function and leave you searching for what’s wrong.</p><p>This is a function I’m currently working on which is a bit more complex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*ggnVhGKDxnXOz3bJQYuirA.png" /></figure><p>This is a bunch of what I’ve been staring at the past few weeks. In order to solve algorithms sometimes a function can run several layers deep with if statements and loops inside of loops working together in order to get the right answer. In order to solve these problems understanding loops has become essential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b62e59f9c397" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>