<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonathan Sexton</title>
    <description>The latest articles on DEV Community by Jonathan Sexton (@jsgoose).</description>
    <link>https://dev.to/jsgoose</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F142157%2F3353caa3-56c3-4a7a-b081-6ce7062cb35c.PNG</url>
      <title>DEV Community: Jonathan Sexton</title>
      <link>https://dev.to/jsgoose</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jsgoose"/>
    <language>en</language>
    <item>
      <title>How I Quit My Job and Started Freelancing Full Time</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Tue, 05 Oct 2021 13:37:45 +0000</pubDate>
      <link>https://dev.to/jsgoose/how-i-quit-my-job-and-started-freelancing-full-time-9di</link>
      <guid>https://dev.to/jsgoose/how-i-quit-my-job-and-started-freelancing-full-time-9di</guid>
      <description>&lt;p&gt;A lot of us have some variation of the dream where we quit our 9 to 5 grind and work for ourselves while we rake in the cash.  As of 2020, &lt;a href="https://elitecontentmarketer.com/freelance-statistics/" rel="noopener noreferrer"&gt;36% of the total US work force (59 million people)&lt;/a&gt; were freelancers and that percentage is growing faster relative to other forms of work.  &lt;/p&gt;

&lt;p&gt;But how do you get there? &lt;/p&gt;

&lt;p&gt;The answer is: &lt;em&gt;There are hundreds, if not thousands, of ways.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;There isn't an exact formula unfortunately as the journey can be an uncertain one.  I'm going to share the way I did it.  It may work for you or you may need to adapt certain aspects to fit your particular situation.&lt;/p&gt;

&lt;p&gt;Some of you may be looking to go straight from learning/graduating into freelancing and that's definitely a viable option, it's just not the route I took.&lt;/p&gt;

&lt;p&gt;I had a full time job before starting to freelance, so my advice will be centered around that path.&lt;/p&gt;

&lt;p&gt;Also, I'm assuming you understand the legalities of freelancing in the US (&lt;em&gt;i.e. You've already taken care of the appropriate local, state, and federal paperwork, setting up a bank account, paying taxes, etc&lt;/em&gt;). &lt;/p&gt;

&lt;h2&gt;Brief History of Working Background&lt;/h2&gt;

&lt;p&gt;I have been working in the tech industry for going on three years now but before that I was in sales and customer service industry for roughly twelve years.&lt;/p&gt;

&lt;p&gt;I won't go too deep into details but if you want a deeper dive into my history, I've written several relevant articles: &lt;a href="https://jonathansexton.me/blog/conquering-job-interview-code-challenges-v1-0/" rel="noopener noreferrer"&gt;Conquering Interview Code Challenges v1&lt;/a&gt;, &lt;a href="https://jonathansexton.me/blog/conquering-job-interview-code-challenges-v2-0/" rel="noopener noreferrer"&gt;Conquering Interview Code Challenges v2&lt;/a&gt;, and &lt;a href="https://jonathansexton.me/blog/landing-my-first-development-job-what-a-crazy-journey/" rel="noopener noreferrer"&gt;How I landed My First Job in the Tech Industry&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Shortly after getting hired as a full time developer, I started freelancing on the side to bring in extra income for bills and to squirrel away for a financial rainy day. &lt;/p&gt;

&lt;p&gt;Now that you're up to speed, let's get into the good stuff: how did I go from freelancing as a side hustle to freelancing as a main job?  &lt;/p&gt;

&lt;h2&gt;Sacrifices Must Be Made&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F10%2Fimage-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F10%2Fimage-1.png" alt="the daily schedule of jonathan sexton showing times throughout the day for different activities" title="Daily Schedule" width="800" height="400"&gt;&lt;/a&gt;Here's a look at my daily schedule while I was making my way into full time freelancing&lt;/p&gt;

&lt;p&gt;Since I had a full time job, I needed to make time in my schedule before and after my 9 to 5 to accommodate my freelance work.&lt;/p&gt;

&lt;p&gt;I started scheduling everything about my day from the time I woke up, to down time I spent with my family, to the time I went to bed, etc.  This will required me to take a good look at where I could cut out time wasting activities.&lt;/p&gt;

&lt;p&gt;Some of the things I sacrificed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spending time with friends on the weekend&lt;/li&gt;
&lt;li&gt;Social events&lt;/li&gt;
&lt;li&gt;Watching TV, playing video games or scrolling through social media in free time&lt;/li&gt;
&lt;li&gt;Spending on vacation trips&lt;/li&gt;
&lt;li&gt;Spending on adventures and experiences&lt;/li&gt;
&lt;li&gt;Dining out regularly&lt;/li&gt;
&lt;li&gt;Staying up late at night&lt;/li&gt;
&lt;li&gt;Spending my lunch break watching funny videos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list could go on and on but the point is I had to revamp my schedule to make time for what I wanted.  I cut out things in my schedule that weren't productive or helpful.  &lt;/p&gt;

&lt;p&gt;One caveat, prioritize getting at least 7-8 hours of sleep, eating as healthy as possible, and family time.  Some things are just too important to be cut out.&lt;/p&gt;

&lt;h2&gt;Have a Support System&lt;/h2&gt;

&lt;p&gt;There's no way I would have been able to go full time freelance without my wife - plain and simple.  She has been my support system through all of this transition.  I know it's been difficult for her as well but by being open and hones with each other we've made this a much smoother transition.&lt;/p&gt;

&lt;p&gt;She was able to carry health insurance for our family during the first part of this transition.  &lt;/p&gt;

&lt;p&gt;If you live in the US, you know that everything related to finding fairly priced, reliable, and sufficient coverage without an employer subsidizing a portion of the cost is nigh impossible.&lt;/p&gt;

&lt;p&gt;Without my wife bearing this burden, I would have no choice but to stay at my 9 to 5.&lt;/p&gt;

&lt;p&gt;Freelancing income can be "peaks and valleys".  One month you finish a project, get paid, and you're riding high.  The next month you could have no work and you're in conserve mode again.&lt;/p&gt;

&lt;p&gt;My wife helped stabilize our monthly income so that it's more predictable while I make this transition.&lt;/p&gt;

&lt;p&gt;So what's the point of all this?  Am I telling you to go out and get married so that person can help you move into full time freelancing?  No, of course not.   But having someone you can rely on while making this transition will make the process infinitely less stressful.  &lt;/p&gt;

&lt;p&gt;That person can be your friends, relatives, or even a mentor.&lt;/p&gt;

&lt;h2&gt;Save Money Relentlessly&lt;/h2&gt;

&lt;p&gt;This heading speaks for itself.  No matter how you get paid at your current position, &lt;em&gt;&lt;strong&gt;save whatever you ca&lt;/strong&gt;&lt;/em&gt;&lt;strong&gt;&lt;em&gt;n for as long as you can before making the transition&lt;/em&gt;&lt;/strong&gt;.  The more you save now, the better off you'll be when you decide to make the leap.&lt;/p&gt;

&lt;p&gt;Everything you put back now will help you down the road during those "peaks and valleys" I mentioned earlier.  This nest egg you create will offset costs you run into once you've quit your full time job.&lt;/p&gt;

&lt;p&gt;One way my wife and I save money is to make meal plans (my wife does all the planning, I chip in with ideas) before we go grocery shopping for the week.  Doing this allows us to see the ingredients we need for a week's worth of meals and keeps us focused while shopping.&lt;/p&gt;

&lt;p&gt;If you're like me and have trouble making and sticking to a budget, these apps can help: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://pocketguard.com/" rel="noopener noreferrer"&gt;PocketGuard&lt;/a&gt; (free)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mint.intuit.com/" rel="noopener noreferrer"&gt;Mint Budget Tracker&lt;/a&gt; (free)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.honeydue.com/" rel="noopener noreferrer"&gt;Honeydue&lt;/a&gt; (free)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youneedabudget.com/" rel="noopener noreferrer"&gt;You Need a Budget (YNAB)&lt;/a&gt; (paid after a 34 day trial)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Have at Least One Long Term Client&lt;/h2&gt;

&lt;p&gt;This is the 2nd most important aspect, behind relying on my wife, that allowed me to transition to freelance full time.  Having at least one long term client/project is game changing.  This stream of predictable income has helped alleviate an untold amount of stress.&lt;/p&gt;

&lt;p&gt;How do you find a client like this?  The major job boards are a great way to start.  There is no shortage of clients and companies looking for a reliable, albeit temporary, extra set of hands so to speak.&lt;/p&gt;

&lt;p&gt;Typically, these companies aren't looking for full time employees - they just need help on a contractual basis.  This is the perfect arrangement!&lt;/p&gt;

&lt;p&gt;I've also had this type of relationship turn into plenty more work from the same client.  I already had a contract with the company for one project, they approached me and asked if I'd be interested in working on a second project as well.  I now have two, long term (more than 6 months) projects that provide predictable income.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A word of caution though, don't let this be your only source of income.  Always be looking for more work/clients/opportunities&lt;/em&gt;.&lt;/p&gt;




&lt;p&gt;Only you can determine what the right choices are for your particular situation.  I hope this guide helps with your move into freelancing.  If you have any questions, I'm always willing to help.  Leave a comment or shoot me a DM on social media. &lt;/p&gt;

&lt;p&gt;When you've made the leap, I'd love if you'd share your store with me!&lt;/p&gt;

&lt;p&gt;Since you've made it this far, why not sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;?  You can do that at the top right of my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;. I promise I’ll never spam your inbox and your information stays with me. I like to occasionally send out interesting resources I find, interesting tweets I see, articles about web development, a list of my newest posts, etc.&lt;/p&gt;

&lt;p&gt;If you haven’t yet, you can also connect with me on social media! I love connecting with others and meeting new people so don’t afraid to say hi.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lastly, I'm available for hire!  You can contact me through social media or by using the form the form on my website to get in touch :)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have an awesome day my friend and happy coding!&lt;/p&gt;

</description>
      <category>freelance</category>
      <category>freelancing</category>
      <category>webdev</category>
      <category>job</category>
    </item>
    <item>
      <title>I Abandoned My Old Website Design After Going Full Time Freelance</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Mon, 27 Sep 2021 12:43:06 +0000</pubDate>
      <link>https://dev.to/jsgoose/i-abandoned-my-old-website-design-after-going-full-time-freelance-3k46</link>
      <guid>https://dev.to/jsgoose/i-abandoned-my-old-website-design-after-going-full-time-freelance-3k46</guid>
      <description>&lt;p&gt;Refreshes, redesigns, and rebuilds are always fun and exciting for me.  I get the sense of giving new life to something that hasn't seen it for a while.  However, it wasn't an easy task to re-imagine the purpose, layout, and design of something I love as much as my own website.  &lt;/p&gt;

&lt;p&gt;It holds a special place in my developer heart.  I mean it was, quite literally, the very first website I put on the live web.&lt;/p&gt;

&lt;p&gt;It was a fun, albeit long, process that really tested my ability to mesh colors, design, and purpose but I'm very happy with the finished design and build.&lt;/p&gt;

&lt;h2&gt;My Previous Website&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F07%2Fimage-1024x574.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F07%2Fimage-1024x574.png" alt="jonathan sexton's previous portfolio website with links at the top" width="800" height="400"&gt;&lt;/a&gt;My previous portfolio was built with the purpose of getting a developer job and was roughly 3 years old&lt;/p&gt;

&lt;p&gt;The previous version of my website was built with the intention of landing my first developer job.  As such, it had sections and content that's relevant to that purpose.  &lt;/p&gt;

&lt;p&gt;It reads like a resume which is exactly what I wanted at the time because when the site was built I was looking for my first developer job.&lt;/p&gt;

&lt;p&gt;Now that my focus has changed (check my &lt;a href="https://twitter.com/jj_goose/status/1432702211662909441" rel="noopener noreferrer"&gt;tweet about going full time freelance&lt;/a&gt; ) from &lt;a href="https://jonathansexton.me/blog/landing-my-first-development-job-what-a-crazy-journey/" rel="noopener noreferrer"&gt;getting a full time job &lt;/a&gt;to going freelance, it was time my website reflected that.&lt;/p&gt;

&lt;p&gt;To prepare, I did quite a bit of research on accessibility, &lt;a href="https://en.wikipedia.org/wiki/Color_theory" rel="noopener noreferrer"&gt;color theory&lt;/a&gt;, and layout design so I’d have a good foundation to start from on the visual aesthetic.  I asked for some input from my daughter and that’s where the initial purple color came from.&lt;/p&gt;

&lt;p&gt;I also shifted the layout to have multiple pages instead of the landing page style that my previous website implemented.&lt;/p&gt;

&lt;h2&gt;What Made This the Right Time&lt;/h2&gt;

&lt;p&gt;It’s been nearly 3 years since I changed industries by landing my first developer job.  In that time I’ve learned a ton, grown as a person and as a developer, and met some amazing people.&lt;/p&gt;

&lt;p&gt;My ultimate goal is (and was from the beginning) to move into freelancing full time.  This redesign is just one of the many steps I’ve taken in that direction.&lt;/p&gt;

&lt;p&gt;The freedom and flexibility that freelancing affords me and my family is what initially drew me to freelancing but the love for helping people/small businesses has truly become my calling.&lt;/p&gt;

&lt;p&gt;Being in a place financially, emotionally, and mentally stable enough to make the transition into full time freelancing made this the most opportune time for this redesign.&lt;/p&gt;

&lt;h2&gt;The Results&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F09%2Fnew_landing_page-min-1024x350.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F09%2Fnew_landing_page-min-1024x350.png" alt="the new landing page for jonathansexton.me" width="800" height="400"&gt;&lt;/a&gt;The new landing page - complete with a color/style/layout refresh&lt;/p&gt;

&lt;p&gt;This refresh took much longer than I anticipated or wanted (but isn't that always the case with our own projects?) but I'm very happy with the end result. &lt;/p&gt;

&lt;p&gt;I wanted a new design that was bright and vibrant - I think I hit the mark on that one with the purple and orange/red combination.&lt;/p&gt;

&lt;p&gt;I use a custom but simple form for the contact portion - after all I don't need much from a potential client at this stage. &lt;/p&gt;

&lt;p&gt;Without going too much into the technical weeds, it's built on &lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; which means I get greater control over what's being sent to the client and it's super fast:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F09%2Fnew_website_performance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F09%2Fnew_website_performance.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also took the time to make accessibility a focus from the ground up - focusing on color contrast, element flow, and &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/semantics" rel="noopener noreferrer"&gt;semantic HTML&lt;/a&gt;.  I want my website to be usable by anyone that visits it.  &lt;/p&gt;

&lt;p&gt;I'm extremely happy with the way this process turned out and I feel like the results speak for themselves :D&lt;/p&gt;

&lt;h2&gt;Planned Upgrades&lt;/h2&gt;

&lt;p&gt;Like any project, it's never finished so I do have some upgrades planned for the not-so-distant-future.  Here are a few ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I want to bring the blog posts into the Gatsby ecosystem via a &lt;a href="https://en.wikipedia.org/wiki/Headless_content_management_system" rel="noopener noreferrer"&gt;headless CMS&lt;/a&gt;.  I feel like this will have a much better user experience while bringing my website and blog design inline with one another.&lt;/li&gt;
&lt;li&gt;I'm also eying a dedicated contact page. I haven't decided on the specifics of this implementation yet&lt;/li&gt;

&lt;li&gt;Adding customizable banner/notification area at the top of pages for special events/promos/important messages&lt;/li&gt;

&lt;li&gt;Easter eggs for developers/curious visitors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm sure this list will grow before everything above is complete, but it's good to have a starting point :D
&lt;/p&gt;




&lt;p&gt;This was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;Since you've made it this far, why not sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;?
&lt;/p&gt;  

&lt;p&gt;You can do that at the top right of the main blog page.  I promise I’ll never spam your inbox and your information stays with me.  I like to occasionally send out interesting resources I find, interesting tweets I see, articles about web development, a list of my newest posts, etc.
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lastly, I'm available for hire!  You can use the form on my portfolio or send a message to &lt;em&gt;hello at jonathan sexton dot me&lt;/em&gt; to get in touch :)&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;Have an awesome day my friend and happy coding!&lt;/p&gt;

</description>
      <category>freelance</category>
      <category>redesign</category>
      <category>website</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>Personal Updates</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Fri, 21 May 2021 17:48:10 +0000</pubDate>
      <link>https://dev.to/jsgoose/personal-updates-49la</link>
      <guid>https://dev.to/jsgoose/personal-updates-49la</guid>
      <description>&lt;p&gt;It's been quite some time since I did a less technical more personal post.  This will be more of an informal post that mostly focuses on updates around me (kinda selfish huh?) and my personal life as opposed to tech.&lt;/p&gt;

&lt;p&gt;I've tended to shy away from these types of posts because my negative self talk creeps in and tells me these aren't useful to anyone but me.&lt;/p&gt;

&lt;p&gt;This time though, I've decided not to listen to those thoughts and publish this post anyway :)  You'll have to let me know if I was right to do so haha&lt;/p&gt;

&lt;p&gt;I've also sprinkled in some helpful tidbits here and there that have proven useful to me.  Hopefully you'll get the same value out of them but as always I make no guarantees.&lt;/p&gt;

&lt;p&gt;Alright, let's get started! &lt;/p&gt;

&lt;h2&gt;Life&lt;/h2&gt;

&lt;p&gt;Alright, let's start with a few life updates.  If you follow me on social media (you can find all of my links on the home page of my blog) you've likely seen a few of these updates already.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My daughter was born&lt;/strong&gt; - happy and healthy thankfully - thus making me the father of two wonderful children.  My wife and I have slowly been learning how much we miss sleep.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We've started putting tile floors down in our home.&lt;/strong&gt;  If I can provide you with any advice on the home improvement front, it's to do it before or after you move - at least for larger projects like what we are currently doing.  &lt;/p&gt;

&lt;p&gt;The alternative is you end up living out of one bedroom for a few weeks and you learn just how much you can tolerate being in one room of your house for a while.  &lt;strong&gt;Spoiler alert&lt;/strong&gt; - it's likely not that long.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My wife and I were fortunate enough to get both rounds of the COVID 19 vaccine.&lt;/strong&gt; We're hoping life can return to some sense of normalcy soon-ish.  Stay safe and get the vaccine if you are eligible - that's my advice :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lastly, I'm going on almost 2 years at my first professional development job.&lt;/strong&gt;  It's hard to believe that nearly 730 days have passed since I was hired.  If you haven't read about my journey, I invite you to read how &lt;a rel="noreferrer noopener" href="https://jonathansexton.me/blog/landing-my-first-development-job-what-a-crazy-journey/"&gt;How I Landed My First Development Job&lt;/a&gt; as it was a crazy ride.&lt;/p&gt;

&lt;p&gt;Side note - &lt;em&gt;Here's a sneak peak for you as well: I'm rebuilding my personal website (as well as this blog) in anticipation of eventually going full time freelance!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F05%2FScreen-Shot-2021-05-08-at-9.23.15-PM-1024x598.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2021%2F05%2FScreen-Shot-2021-05-08-at-9.23.15-PM-1024x598.png" alt="" width="800" height="400"&gt;&lt;/a&gt;I'm hoping to have it ready for launch by the end of June 2021&lt;/p&gt;

&lt;p&gt;If you have a project/idea you'd like to talk about or are searching for a developer, use the form below to get in touch with me.  I'd love to talk about how I can bring your project to life :)&lt;/p&gt;

&lt;h2&gt;Random Advice&lt;/h2&gt;

&lt;p&gt;It should be noted that I learn as I go - I learn by doing.  Some of the lessons I've learned along the way have come to me the hard way and some have been easier to handle &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You get what you pay for&lt;/strong&gt; - this isn't true in every situation (I've had many great wines that were under $10 for example) but in this situation I should have known better.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This pertains to the reference above where I said my wife and I are getting tile floors put in our house.  We decided to go with a cheaper option for an installer.  Long story short, we've spent many thousands of dollars, 5 weeks of our time, and our floors still aren't finished.&lt;/p&gt;

&lt;p&gt;I can directly relate this lesson to learning to code or building a project.  &lt;span&gt;Don't take short cuts.&lt;/span&gt;  &lt;/p&gt;

&lt;p&gt;Spend extra time to do things right up front and you will be rewarded.  Cut corners by not testing your code or by not adhering to best practices and I promise you will pay for it later down the road (see &lt;a href="https://en.wikipedia.org/wiki/Technical_debt" rel="noopener noreferrer"&gt;technical debt&lt;/a&gt;). &lt;/p&gt;

&lt;p&gt;Sometimes the hard lessons are the most important ones because they give you the opportunity to learn and grow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can manage your time or it can manage you&lt;/strong&gt; - there will only ever be 24 hours in a day for everyone.&lt;/p&gt;

&lt;p&gt;I have a thriving freelance business, a wife, two children, bills, a busy schedule, etc but I also want time to work on side projects and write articles.  So I maximize my free time as we only get so much. Here are some things that help me and might help you:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Batch similar tasks (this will not be the only article I write today)&lt;/li&gt;
&lt;li&gt;If something can be done in less than 5 minutes, do it now, don't put it off because it could become a much larger issue in the future&lt;/li&gt;
&lt;li&gt;Set your future self up for success - for example if you have a hard time getting up at a certain time, set your alarm and put your phone or alarm clock out of reach so you have to get up to turn it off&lt;/li&gt;
&lt;li&gt;Meal prep on the weekends and freeze those meals so you can have lunches/dinners ready on the weekdays when you have less free time (make use of that batching I mentioned above)&lt;/li&gt;
&lt;li&gt;Keep a time journal - write down everything you do, how long you spend on it, and in a week or a month look at where you can make changes in your schedule to cut out time wasting tasks&lt;/li&gt;
&lt;li&gt;Make a daily priority list with no more than 5 tasks- rank these tasks from 1-5 and focus on them ruthlessly&lt;/li&gt;
&lt;li&gt;Discipline will always beat out motivation - I am wholly unmotivated to write this post but I made a plan to increase my output of blog posts.  Discipline &amp;gt; motivation&lt;/li&gt;
&lt;li&gt;Schedule everything - even downtime.  My calendar looks like a garbled mess of events but I schedule everything in my day right down to the minute.  Thus far it has helped me tremendously.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few of the tips I have that have helped me be more productive.  They may work for you or you may find little value in them.  Find what works for you through trial and error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allow yourself to take breaks for as long as you want or need&lt;/strong&gt; - Breaks are just as important, if not more important, than working.  Enjoy all that your life has to offer.  Spend time with your family, go outside and walk around, play video games, veg out on the couch all day and watch TV - do all the things you want to do for your mental/physical health.  &lt;/p&gt;

&lt;p&gt;And here is the most important part: don't feel bad or guilty for not working.  As much as we try to squeeze every ounce of free time out of our schedules for working and focusing we also have to have down time.  If for nothing else than to avoid burnout.  So go ahead, enjoy time with friends and family (socially distanced or virtually), go for an extended walk, or just enjoy not working.  We deserve it!&lt;/p&gt;

&lt;p&gt;This is something I struggle with but I'm getting better at it one day at a time.&lt;/p&gt;

&lt;h2&gt;That's a Wrap&lt;/h2&gt;

&lt;p&gt;If you've made it this far - thank you.  I appreciate you sticking around for the personal stuff.  These types of posts are few and far between from me so if you're looking for technical content I have you covered there as well.&lt;/p&gt;

&lt;p&gt;I have posts covering large ideas like &lt;a href="https://jonathansexton.me/blog/get-a-basic-understanding-of-the-life-cycles-of-software-development/" rel="noopener noreferrer"&gt;software development life cycles&lt;/a&gt;, &lt;a href="https://jonathansexton.me/blog/negotiating-rates-with-your-clients/" rel="noopener noreferrer"&gt;negotiating freelance rates&lt;/a&gt;, and (if you're interested) more technical based content like &lt;a href="https://jonathansexton.me/blog/how-to-install-and-begin-using-typescript/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If those don't satiate your technical article needs check out my &lt;a href="https://www.freecodecamp.org/news/author/jonathan/" rel="noopener noreferrer"&gt;freeCodeCamp articles&lt;/a&gt; which cover a wide range of topics like SQL queries and JavaScript.&lt;/p&gt;

&lt;p&gt;While you’re here don’t forget to sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;  –  you can do that at the top right of the main &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; page.  I promise I’ll never spam your inbox and your information will not be shared with anyone/site.  I like to occasionally send out interesting resources I find, articles about web development, and a list of my newest posts.&lt;/p&gt;

&lt;p&gt;If you haven’t yet, you can also connect with me on social media!  All of my links are on my main &lt;a href="https://jonathansexton.me" rel="noopener noreferrer"&gt;website&lt;/a&gt; or found on my profile here.  I love connecting with others and meeting new people so don’t afraid to say hi 🙂&lt;/p&gt;

&lt;p&gt;Have an awesome day friend and happy coding!&lt;/p&gt;

</description>
      <category>personal</category>
      <category>update</category>
      <category>time</category>
      <category>management</category>
    </item>
    <item>
      <title>Get a Basic Understanding of the Life Cycles of Software Development</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Tue, 25 Feb 2020 02:43:09 +0000</pubDate>
      <link>https://dev.to/jsgoose/get-a-basic-understanding-of-the-life-cycles-of-software-development-25fp</link>
      <guid>https://dev.to/jsgoose/get-a-basic-understanding-of-the-life-cycles-of-software-development-25fp</guid>
      <description>&lt;p&gt;When I decided to teach myself how to code almost four years ago I had never heard of, let alone thought about, the software development life cycle.  As a brand new developer I was focused on learning the technologies that would help me land that coveted first developer job, not the nuances of how those teams operated.&lt;/p&gt;

&lt;p&gt;When I did learn of them, I thought they would be useless to me because I considered myself a web developer not a software developer.&lt;/p&gt;

&lt;p&gt;I've since learned that this couldn't be further from the truth and these principles/practices play a large role in my day-to-day activities (whether I realize it or not).&lt;/p&gt;

&lt;p&gt;I'm fortunate enough to see how the code I write, the features I build, and the bugs I inadvertently introduce (more than I care to admit) affect the end user and their experience. That experience has helped shape how I think about the process of building products and solving problems for my users.&lt;/p&gt;

&lt;p&gt;I've had some time to think about the differences (and similarities) each of these approaches offer.  At their core, each is focused on delivering high quality software as efficiently and as cost effectively as possible.  &lt;/p&gt;

&lt;p&gt;Professionally, I've only used one or two of these methodologies (I don't believe I've been in the industry long enough to experience them all and I have yet to have someone explicitly tell me that the team adheres to a specific methodology) but I still find value in at least a basic understanding of all of them.&lt;/p&gt;

&lt;p&gt;I hope to give you just that after you've finished this article.  This is not an in-depth examination of each life cycle but more of a broad strokes type of approach.&lt;/p&gt;

&lt;p&gt;So, here are the software development life cycles in no particular order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Lean_software_development" rel="noopener noreferrer"&gt;Lean&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.agilealliance.org/agile101/" rel="noopener noreferrer"&gt;Agile&lt;/a&gt;  &lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Waterfall_model" rel="noopener noreferrer"&gt;Waterfall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Iterative_and_incremental_development" rel="noopener noreferrer"&gt;Iterative&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Spiral_model" rel="noopener noreferrer"&gt;Spiral&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/DevOps" rel="noopener noreferrer"&gt;Dev Ops&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's dig in to the differences and similarities of each method.&lt;/p&gt;

&lt;h2&gt;Lean&lt;/h2&gt;

&lt;p&gt;The Lean methodology relies heavily on and is comprised of seven principles.  In no specific order they are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Eliminate Waste&lt;/li&gt;
&lt;li&gt;Amplify Learning&lt;/li&gt;
&lt;li&gt;Decide As Late As Possible&lt;/li&gt;
&lt;li&gt;Deliver As Fast As Possible&lt;/li&gt;
&lt;li&gt;Empower The Team&lt;/li&gt;
&lt;li&gt;Build Integrity&lt;/li&gt;
&lt;li&gt;See/Optimize The Whole&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each principle has a specific purpose with benefits that compliment each other.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Eliminating waste&lt;/em&gt; (extra features, incomplete work, managerial engagements, etc) creates more value for the customer which, in turn, enhances satisfaction.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Amplifying learning&lt;/em&gt; allows teams to reinvest in their ability to deliver products to customers.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Deciding as late as possible&lt;/em&gt; refers to all major decisions, giving teams an option based or a set based approach.  This allows teams to gather facts rather than opinions to help influence decisions when made.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Delivering as fast as possible&lt;/em&gt; is self explanatory - build the product as quickly as possible to deliver it to customers for evaluation/iteration.&lt;/p&gt;

&lt;p&gt;In a typical scenario, the managers dole out assignments/work to the developers.  In the Lean methodology developers "teach" managers how to listen to the "people in the trenches" thus influencing the decisions/choices of management.  &lt;/p&gt;

&lt;p&gt;This helps teams feel more &lt;em&gt;empowered&lt;/em&gt; to speak up about ides and solutions.&lt;/p&gt;

&lt;p&gt;Making &lt;em&gt;integrity&lt;/em&gt; a rule instead of an exception means that the customer is confident in the system being built.  The customer knows the system is being built to withstand the appropriate amount of growth and "stretching" if need be.&lt;/p&gt;

&lt;p&gt;I like to think of the integrity part along the same lines as sitting in a chair.  When you sit in the chair you believe it was constructed with the best material that will hold you up every time you sit in it for the life of the chair.  The customer needs to that same confidence in the product being built.&lt;/p&gt;

&lt;p&gt;Lastly, &lt;em&gt;seeing and optimizing the whole&lt;/em&gt; refers to the entirety of the system being built.  By optimizing for the whole we look at software not as a sum of many components, but as one large entity that is optimized for efficiency.&lt;/p&gt;

&lt;p&gt;This means that during development, the product is broken into manageable pieces and that inadvertent bugs are not only discovered but resolved swiftly.&lt;/p&gt;

&lt;h2&gt;Agile&lt;/h2&gt;

&lt;p&gt;This is the "fail fast" approach to building software.&lt;/p&gt;

&lt;p&gt;It places emphasis on small, incremental releases with on-going release cycles.  With each iteration teams strive to identify and address small issues before they become big problems.&lt;/p&gt;

&lt;p&gt;This also means that the teams must engage stakeholders (people/organizations that the code can ultimately affect such as managers, technical leads, CTOs, and customers) to get their feedback.  &lt;/p&gt;

&lt;p&gt;If you're a freelance, your stakeholder(s) would be your customers - ultimately you need to ensure their satisfaction with the work before moving on.&lt;/p&gt;

&lt;p&gt;Agile is technically an offshoot of the Lean methodology with some notable differences - mainly it prioritizes customer satisfaction from the outset and allows teams to respond quickly to customer feedback. &lt;/p&gt;

&lt;p&gt;Although it is beyond the purview of this article, there is another more complex framework within Agile that is called &lt;a href="https://en.wikipedia.org/wiki/Scrum_%28software_development%29" rel="noopener noreferrer"&gt;SCRUM&lt;/a&gt;.  This methodology is used for large, extremely complex projects and has even been used outside of software development.&lt;/p&gt;

&lt;h2&gt;Waterfall&lt;/h2&gt;

&lt;p&gt;The waterfall methodology is, by most accounts, the oldest one in the list.  It was never meant to be a model for software development and got its start in the construction and manufacturing worlds.&lt;/p&gt;

&lt;p&gt;This approach is simple in its structure - finish all parts of a phase before moving on to the next phase with more momentum building towards the project finish as stages are completed. Each stage's beginning (except for the first) and completion is contingent on the previous stage's completion/transfer of information.&lt;/p&gt;

&lt;p&gt;Under the waterfall approach each stage has its own rigid project plan that finishes off with testing for previously completed work.  It should be noted that this approach is not recommended for larger/longer lasting projects because of the aforementioned rigidity.&lt;/p&gt;

&lt;p&gt;Think about the genesis of this methodology and you'll understand it more.  It came from the construction/manufacturing world where it is common to complete one phase at a time.  During the building of a house you wouldn't start putting in the plumbing before the frame has been put up.&lt;/p&gt;

&lt;p&gt;That's not the way software development works generally. As we all know it sometimes becomes necessary to revisit a phase that was previously thought to be finished.&lt;/p&gt;

&lt;h2&gt; Iterative&lt;/h2&gt;

&lt;p&gt;This is known as the "repetitive approach" or the "make it better the next go around" approach because of the different opportunities it provides to improve the product with each cycle iteration.&lt;/p&gt;

&lt;p&gt; I'm biased (as we all are :D) but this happens to be my favorite life  cycle for development.  I believe it works best for my current situation  both in my freelance and career path because it allows me to constantly  "move forward while making things better" &lt;/p&gt;

&lt;p&gt;With the iterative approach, teams implement a solution, test that solution, evaluate its effectiveness/throughput, and then pinpoint further areas for improvement.  This happens for each cycle (iteration) of the development process.&lt;/p&gt;

&lt;p&gt;With each version released comes another iteration until the final product is completed and ready for rollout to users.&lt;/p&gt;

&lt;p&gt;One of the great features of the iterative approach is you and your team get a working version of software early on in the development process.  This can be especially useful to show to stakeholders to gauge their response/feedback.&lt;/p&gt;

&lt;p&gt;One of the big drawbacks to this approach is it can consume a large amount of resources very quickly.  Imagine all of the people, hours, bug fixes and wages that go into each iteration of the development cycle and you'll get a good picture of the resource usage.&lt;/p&gt;

&lt;p&gt;Within this approach is a subset of principles developed by Rational Software Corporation (bought by IBM) called the &lt;a href="https://en.wikipedia.org/wiki/Rational_Unified_Process" rel="noopener noreferrer"&gt;Rational Unified Process (R.U.P.)&lt;/a&gt; which consists of 4 phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inception&lt;/li&gt;
&lt;li&gt;Elaboration&lt;/li&gt;
&lt;li&gt;Construction&lt;/li&gt;
&lt;li&gt;Transition (product release)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This set of principles is meant to be flexible and tailored to the needs of each team using it.&lt;/p&gt;

&lt;h2&gt;Spiral&lt;/h2&gt;

&lt;p&gt;The spiral methodology is likely the most flexible out of the six.  It's a methodology built on risks - identifying and negating them.  Risk (identification &amp;amp; aversion) drives every decision in this model.  It is broken into four sub-phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Planning (objectives)&lt;/li&gt;
&lt;li&gt;Risk Analysis (identify possible roadblocks)&lt;/li&gt;
&lt;li&gt;Develop &amp;amp; Test (current &amp;amp; next version)&lt;/li&gt;
&lt;li&gt;Evaluation (review of current phase &amp;amp; plan for next phase)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each iteration of each phase begins with planning for the next phase.  This way potential risks are identified before they are encountered.  This also allows for a plan of action when said risks arise.&lt;/p&gt;

&lt;p&gt;During phases teams also work to mitigate these risks and their impact on future iterations of the spiral development.&lt;/p&gt;

&lt;p&gt;As the development process continues, each of these four sub-phases is repeated in spiral fashion.  This allows for multiple rounds of refinement for each sub-phase until completion.&lt;/p&gt;

&lt;h2&gt;Dev Ops&lt;/h2&gt;

&lt;p&gt;If you do a quick search, you will find no shortage of information on this development life cycle method.  It is the new kid on the block that brings software development and information-technology operations teams into the same fold.&lt;/p&gt;

&lt;p&gt;These teams work in conjunction to provide small, but impactful, updates to products that come at a frequent pace.  In turn, this creates a continuous feedback and improvement loop that drives development.&lt;/p&gt;

&lt;p&gt;This particular methodology is known for automating the manual parts of development as well (think deployment).&lt;/p&gt;

&lt;p&gt;The overall goal of this methodology is, like most others, the shorten the development life cycle and provide quality products.&lt;/p&gt;

&lt;p&gt;One of the drawbacks to this methodology is the significant mindset and culture changes within an organization.  Teams that may have been accustomed to working on many things find their tasks narrowed to only one or two.  &lt;/p&gt;

&lt;p&gt;For example, a general purpose developer may find he or she is now being tasked with only the testing portion or the end-user experience portion.&lt;/p&gt;

&lt;h2&gt;Bringing It All Home&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F02%2Fclever-visuals-iMwiPZNX3SI-unsplash-1024x690.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F02%2Fclever-visuals-iMwiPZNX3SI-unsplash-1024x690.jpg" alt="a light bulb on a book" width="800" height="400"&gt;&lt;/a&gt; Photo by &lt;a href="https://unsplash.com/@clever_visuals?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Clever Visuals&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/bright-idea?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you can now see the importance and the benefits of each of these methodologies.  Each of these possess their own strengths and weaknesses.  &lt;/p&gt;

&lt;p&gt;They are, at their most basic level, a set of guidelines and principles that seek to deliver high quality, efficient work to stakeholders.&lt;/p&gt;

&lt;p&gt;When I first started learning to code I didn't have a mentor.  By sharing what I've learned I hope to those who are learning to code when/where they can.&lt;/p&gt;

&lt;p&gt;I want to share as much information and experience as I possibly can with other developers.  If you are teaching yourself to code or if you're a seasoned developer I hope this article helps, even if in a small way.  &lt;/p&gt;








&lt;p&gt;Check out my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; where I frequently post articles about web development.&lt;/p&gt;

&lt;p&gt;While you're there why not sign up for my newsletter?  You can do 
that at the top right of the main blog page.  I like to send out 
interesting articles (mine and others), resources, and tools for 
developers every now and then.&lt;/p&gt;

&lt;p&gt;If you have questions about this article or just in general my DMs are open -- come say hi on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;
 or any of my other social media accounts which you can find below the 
newsletter sign up on the main page or on my profile here :)&lt;/p&gt;

&lt;p&gt;Have an awesome day and happy coding, friend! &lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>sdlc</category>
      <category>development</category>
      <category>software</category>
    </item>
    <item>
      <title>How to Install and Begin Using TypeScript</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Tue, 14 Jan 2020 01:50:48 +0000</pubDate>
      <link>https://dev.to/jsgoose/how-to-install-and-begin-using-typescript-384o</link>
      <guid>https://dev.to/jsgoose/how-to-install-and-begin-using-typescript-384o</guid>
      <description>&lt;p&gt;TypeScript is one of the current hot topics in web development and for good reasons.&lt;/p&gt;

&lt;p&gt;It allows us to type cast when declaring variables which means we explicitly set the type of data we expect back, throws errors if the returned data is not the type we expected to get back or if a function call has too few or too many arguments, and that's just a sampling of everything it offers.&lt;/p&gt;

&lt;p&gt;If you'd like an overview of the data types you will find it helpful to read my &lt;a href="https://jonathansexton.me/blog/learn-typescript-data-types-from-zero-to-hero/" rel="noopener noreferrer"&gt;previous article&lt;/a&gt;. Reading that article isn't required but it will give you a great understanding of the data types and syntax for TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before we start, it's important to note that TypeScript can be used in conjunction with a framework/library (TypeScript is the default in Angular projects and I have an article in the works about getting started with it) but it can also be used independent of a framework/library.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Also, this article assumes you have a basic understanding of JavaScript programming.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, now we're ready to get  started with TypeScript and start making use of it's awesome features.&lt;/p&gt;

&lt;p&gt;Let's dig in!&lt;/p&gt;

&lt;h2&gt;Installing TypeScript&lt;/h2&gt;

&lt;p&gt;There are two main ways to install TypeScript.  The first is through &lt;a href="https://visualstudio.microsoft.com/vs/" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt; (not to be confused with &lt;a href="https://code.visualstudio.com/?wt.mc_id=DX_841432" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt;) which is an &lt;a href="https://en.wikipedia.org/wiki/Integrated_development_environment" rel="noopener noreferrer"&gt;IDE&lt;/a&gt;.  The 2015, 2017, and I believe 2019 versions come with TypeScript installed already.  &lt;/p&gt;

&lt;p&gt;This is not the route I'll be covering today since I mainly use Visual Studio Code for all of my needs.&lt;/p&gt;

&lt;p&gt;The second way, and the way we'll focus on, is through &lt;a href="https://www.npmjs.com/get-npm" rel="noopener noreferrer"&gt;NPM&lt;/a&gt; (Node Package Manager).&lt;/p&gt;

&lt;p&gt;If you don't already have NPM and/or &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node&lt;/a&gt; installed (you get NPM when you install Node), now is a great time to do so as it's a requirement for the next steps and by association a requirement to use TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-1-1024x550.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-1-1024x550.png" alt="the node js download page" width="800" height="400"&gt;&lt;/a&gt; The Node download page - it's a good idea to use the LTS version as it's the most stable &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Once you have Node and NPM installed, open your terminal in VS Code and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g typescript&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once it's finished installing, you'll see that 1 package has been added and you'll see a message stating the version of TypeScript that was installed.&lt;/p&gt;

&lt;p&gt;This is everything you need to start compiling TypeScript to JavaScript.&lt;/p&gt;

&lt;p&gt;Now you're ready to start writing TypeScript!&lt;/p&gt;

&lt;h2&gt;Starting A TypeScript Project&lt;/h2&gt;

&lt;p&gt;Let's create a TypeScript project so we can take advantage of all those great features that come along with using TypeScript.&lt;/p&gt;

&lt;p&gt;In your editor of choice (I'm using VS Code) let's create an HTML file to be the visual side of our code.  Here's what my basic HTML file looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-2-1024x376.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-2-1024x376.png" alt="html text on a dark background" width="800" height="400"&gt;&lt;/a&gt;Basic HTML boilerplate with some placeholder text&lt;/p&gt;

&lt;p&gt;Honestly, we're just using this HTML so we can have something to look at on the page.  What we're really concerned with is using the console.&lt;/p&gt;

&lt;p&gt;You'll notice I have &lt;code&gt;app.js&lt;/code&gt; linked in the head of our &lt;code&gt;index.html&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;You're probably saying to yourself &lt;em&gt;I thought this was an article about TypeScript?&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Well hold your horses, it is. I just want to highlight some of the differences between JavaScript and TypeScript (You'll learn where this file comes from down below).&lt;/p&gt;

&lt;p&gt;Below you'll see a simple variable declaration and a console log statement:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-4.png" alt="javascript code showing a username variable declaration" width="800" height="400"&gt;&lt;/a&gt;A simple variable declaration and console log statement&lt;/p&gt;

&lt;p&gt;As a side note, if you want to disable some &lt;a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint" rel="noopener noreferrer"&gt;ES-Lint&lt;/a&gt; rules you can place the rules at the top in comments like I've done above.  Or if you want to &lt;strong&gt;completely&lt;/strong&gt; disable ES-Lint for that file only you can place &lt;code&gt;/* eslint-disable */&lt;/code&gt; at the top of the file.&lt;/p&gt;

&lt;p&gt;And here is the browser console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-5.png" alt="the console inside of the firefox browser" width="800" height="400"&gt;&lt;/a&gt;Our userName variable inside FireFox&lt;/p&gt;

&lt;p&gt;Let's pretend that I'm building an application and for the &lt;code&gt;userName&lt;/code&gt; I expect to always get a string back.  Along the way, I may make a mistake or my data may get mutated from another source.  &lt;/p&gt;

&lt;p&gt;Now, &lt;code&gt;userName&lt;/code&gt; is a number :(&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-6.png" alt="javascript code showing a username variable declaration" width="800" height="400"&gt;&lt;/a&gt;Now userName is a number!&lt;/p&gt;

&lt;p&gt;And here is the browser console showing the changes to &lt;code&gt;userName&lt;/code&gt; that we likely didn't want to happen if this were a production application:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-7.png" alt="" width="800" height="400"&gt;&lt;/a&gt;The FireFox console showing the results of the variable mutation&lt;/p&gt;

&lt;p&gt; What if the returned &lt;code&gt;userName&lt;/code&gt; was then passed into another function or used as a piece of a larger data puzzle? &lt;/p&gt;

&lt;p&gt;This would not only be a mess to figure out where the mutation occurred  (especially if we had a larger application) , but also would create an untold amount of bugs in our code.  &lt;/p&gt;

&lt;p&gt;Now, let's try that same experiment in TypeScript.  To do that, we'll need to create a new file with the&lt;code&gt; .ts&lt;/code&gt; extension to denote a TypeScript file.&lt;/p&gt;

&lt;p&gt;I'll name mine &lt;code&gt;app.ts&lt;/code&gt; to stay consistent with naming conventions and put the same code from our JavaScript file into our new TypeScript file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-8.png" alt="typescript code on a dark background " width="800" height="400"&gt;&lt;/a&gt;The same code from our JavaScript copied over into the TypeScript file&lt;/p&gt;

&lt;p&gt;You'll notice that I'm using type casting when declaring my variable now and I'm explicitly telling TypeScript that this variable should point to a string value only.&lt;/p&gt;

&lt;p&gt;You'll also notice that I have an error line under &lt;code&gt;userName&lt;/code&gt; when I'm reassigning it's value.  &lt;/p&gt;

&lt;h2&gt;Compiling TypeScript With the CLI&lt;/h2&gt;

&lt;p&gt;To see what this looks like in our console we have to compile it to JavaScript and we do that by running &lt;code&gt;tsc app.ts&lt;/code&gt; in our VS Code console (you can also run the same command in any terminal as long as you're in the correct directory).&lt;/p&gt;

&lt;p&gt; When we run this command it will compile our TypeScript into JavaScript  and generate another file with the same name only with a &lt;code&gt;.js&lt;/code&gt; extension. &lt;/p&gt;

&lt;p&gt;This is where that &lt;code&gt;app.js&lt;/code&gt; file came from that I mentioned earlier in the article.&lt;/p&gt;

&lt;p&gt; To compile multiple files at once, just provide those names in your command, one after the other: &lt;code&gt;tsc app.ts header.component.ts&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;It's possible to compile multiple TypeScript files into a single JavaScript file by adding the &lt;code&gt;--out&lt;/code&gt; flag:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tsc *.ts --out index.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There’s also a watch command which will recompile all of the TypeScript automatically anytime a change is detected, keeping you from having to manually run the compile command over and over:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tsc *.ts --out app.js --watch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here's the output from that &lt;code&gt;tsc app.ts&lt;/code&gt; command above:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-9-1024x408.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F12%2Fimage-9-1024x408.png" alt="" width="800" height="400"&gt;&lt;/a&gt;The error in my console&lt;/p&gt;

&lt;p&gt;This error tells us that there's a problem with the reassignment of &lt;code&gt;userName&lt;/code&gt;.  Because we  explicitly set our variable to be a string (&lt;em&gt;even if I hadn't set the variable to a string the error would still occur because TypeScript infers data types&lt;/em&gt;) we cannot reassign it to a number.&lt;/p&gt;

&lt;p&gt;This is a great feature because it forces us to be explicit with our variable declarations and saves us from making mistakes that could prove annoying and time consuming.  If you expect a particular type of data you should get that data, otherwise you should get an error.&lt;/p&gt;

&lt;h2&gt;Using Explicitly Declarative Arrays and Objects&lt;/h2&gt;

&lt;p&gt;Let's say I'm building a project and instead of manually setting the navigation links, I want to store that info in an array of objects.&lt;/p&gt;

&lt;p&gt;I'll expect a specific format for the information that's stored so it's consistent across all of the links.&lt;/p&gt;

&lt;p&gt;Here's how I can set a "complex" array in TypeScript:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-1-1024x51.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-1-1024x51.png" alt="" width="800" height="400"&gt;&lt;/a&gt;An array with a specific format&lt;/p&gt;

&lt;p&gt;On the left side we declare the name of the variable &lt;code&gt;navLinks&lt;/code&gt;, followed by a colon.  At the curly braces is where we start declaring the format of the information we expect in this array.&lt;/p&gt;

&lt;p&gt;We're telling TypeScript that we expect this array to contain an object or objects with these property names and types. We expect a &lt;code&gt;name&lt;/code&gt; which is a string, a &lt;code&gt;link&lt;/code&gt; which is a string, and an &lt;code&gt;alt&lt;/code&gt; which is also a string.&lt;/p&gt;

&lt;p&gt;As with other &lt;a href="https://jonathansexton.me/blog/learn-typescript-data-types-from-zero-to-hero/" rel="noopener noreferrer"&gt;data types&lt;/a&gt; if we deviate from the format we established for this variable, we run into errors.  &lt;/p&gt;

&lt;p&gt;Here we tried to add a new entry that was blank and we got the following error:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;Type '{}' is missing the following properties from type '{ name: string; link: string; alt: string; }' : name, link, alt ts(2739)&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-3-1024x97.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-3-1024x97.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We get similar errors if we try to add another entry with the wrong type of information:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{ name: 'Jonathan', link: 15, alt: false }&lt;/code&gt;  ❌ &lt;/p&gt;

&lt;p&gt; &lt;code&gt;{ name: ['Jon','Marley'], link: `https://link123.net`, alt: null }&lt;/code&gt;  ❌  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.navLinks[0].img = '../../assets/img'&lt;/code&gt; ❌   &lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.navLinks[0].name = 'Barnaby'&lt;/code&gt;✔️&lt;/p&gt;

&lt;p&gt;You get the idea though.  Once we establish the format, TypeScript will hold us to that format and inform us if/when we deviate from it with an error.&lt;/p&gt;

&lt;p&gt;Also, here's a few ways to define an array:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const arr1: Array&amp;lt;any&amp;gt; = ['Dave', 35, true];&lt;/code&gt;&lt;em&gt; // will allow us to have any number of elements with any type&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const people: [string,string,string] = ['John', 'Sammy', 'Stephanie'];&lt;/code&gt; &lt;em&gt;// will throw an error if more than 3 string or any non string elements appear in the array &lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const people: Array&amp;lt;string&amp;gt; = ['Jimmy', 'Theresa', 'Stanley'];&lt;/code&gt; &lt;em&gt;//will allow us to have any number of  only string elements in our array&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Objects work much the same way as arrays do in TypeScript.  They can be explicitly defined with set types or you can let TypeScript do all the inferring.  Here's a basic example of an object:&lt;/p&gt;

&lt;p&gt; &lt;code&gt;const person: {name:string, address: string, age: number} = {name: 'Willy', address: '123 Sunshine Ln', age: 35} &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Again, on the left side we're declaring person as the variable name with the first set of curly braces defining the format we want our data to be in.&lt;/p&gt;

&lt;p&gt;It is important to note that in objects, the order we define our properties in does not have to match the order of the format:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-5.png" alt="" width="800" height="400"&gt;&lt;/a&gt;The properties do not have to match the order in which they were defined&lt;/p&gt;

&lt;h2&gt;Functions, Parameters &amp;amp; Arguments&lt;/h2&gt;

&lt;p&gt;Some of the greatest benefits you'll see in TypeScript come when using functions.  &lt;/p&gt;

&lt;p&gt;Have you ever built a function to do a specific task only to find out it's not working as you intended? &lt;/p&gt;

&lt;p&gt;While using TypeScript it won't be because you didn't get/send the correct type of data or use the correct number of parameters/arguments.&lt;/p&gt;

&lt;p&gt;Here's a great example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-1024x454.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-1024x454.png" alt="" width="800" height="400"&gt;&lt;/a&gt;A TypeScript function that should return a number&lt;/p&gt;

&lt;p&gt;In our function we expect to receive 3 arguments when &lt;code&gt;calculator&lt;/code&gt; executes.  However, if we receive the wrong number of arguments (too few or too many) TypeScript will give us a nice error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2020%2F01%2Fimage-4.png" alt="" width="800" height="400"&gt;&lt;/a&gt;The error we get when calling a function with the incorrect amount/type of arguments&lt;/p&gt;

&lt;p&gt;Likewise, if we receive the wrong type of data when executing this function TypeScript will generate an error and the function will not run.&lt;/p&gt;

&lt;p&gt; &lt;code&gt;calculator('12', '11', 'add) ; &lt;/code&gt;❌  &lt;/p&gt;

&lt;p&gt;Now you may be saying to yourself &lt;em&gt;'So what?  That's all well and good but it doesn't seem like that's a huge deal &lt;/em&gt;but imagine you're application is dozens and dozens of files with many layers of abstractions.  &lt;/p&gt;

&lt;p&gt;A great example of this would be an Angular application with services, data models, multilevel components, and all the dependencies that go along with that.  It becomes increasingly difficult to pinpoint where an error is coming from when your application gets to be large.&lt;/p&gt;

&lt;h2&gt;That's All&lt;/h2&gt;

&lt;p&gt;Hopefully you can see the benefits of TypeScript now.  There are plenty more than I have outlined here and I encourage you to read the documentation if you want to find more.&lt;/p&gt;

&lt;p&gt;This article was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.  Swing by and check it out :)&lt;/p&gt;

&lt;p&gt;While you’re there don’t forget to sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;  –  you can do that at the top right of the main blog page.  I promise I’ll never spam your inbox and your information will not be shared with anyone/site.  I like to occasionally send out interesting resources I find, articles about web development, and a list of my newest posts.&lt;/p&gt;

&lt;p&gt;If you haven’t yet, you can also connect with me on social media!  All of my links are also at the top of that page or in in my profile here on DEV.  I love connecting with others and meeting new people so don’t afraid to say hi 🙂&lt;/p&gt;

&lt;p&gt;Have an awesome day friend and happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>learning</category>
    </item>
    <item>
      <title>Learning TypeScript Data Types - From Zero to Hero</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Mon, 28 Oct 2019 09:47:47 +0000</pubDate>
      <link>https://dev.to/jsgoose/learning-typescript-data-types-from-zero-to-hero-5h9n</link>
      <guid>https://dev.to/jsgoose/learning-typescript-data-types-from-zero-to-hero-5h9n</guid>
      <description>&lt;p&gt;It's all the rage these days in the world of web development - &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt;.  I'd wager by now you have heard about it, even in passing.  But, if you haven't or if you're just curious then you've come to the right place my friend!&lt;/p&gt;

&lt;p&gt;I'm currently learning TypeScript in conjunction with Angular (an article on this is in the works, so stay tuned!) because it's what our web application is built in at work.  I decided to write up something easy and simple to follow so you can get up and running with TypeScript data types.&lt;/p&gt;

&lt;p&gt;I'll break this article up into two posts for simplicity - the first will be a brief overview of what TypeScript is, the data types, and some supporting examples.  The second article will be focused on getting TypeScript installed and running locally on your machine.&lt;/p&gt;

&lt;h2&gt;What Is It?&lt;/h2&gt;

&lt;p&gt;Before we start, here's a super condensed description of TypeScript in my own words.  It's a &lt;strong&gt;&lt;em&gt;superset&lt;/em&gt;&lt;/strong&gt; of JavaScript - which essentially means it's a form of JavaScript that gives you certain benefits along with all of the greatness included in 'vanilla' JavaScript.  It's an open source language written and maintained by Microsoft.&lt;/p&gt;

&lt;p&gt;TypeScript transpiles to JavaScript and will run in any environment that native JavaScript runs.  You may use TypeScript for both front end and back end applications.&lt;/p&gt;

&lt;p&gt;It's written just like JavaScript, with a few exceptions that we'll go over soon.  Here's an example of some TypeScript:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage.png" alt="code showing typescript"&gt;&lt;/a&gt;TypeScript in all it's glory&lt;/p&gt;

&lt;p&gt;Try not to focus on all of the colons and extra stuff you see above, we'll dig into that below.  Instead, focus on the things that stand out - we're just declaring variables with values, these are strings, arrays, and objects just like in JavaScript. &lt;/p&gt;

&lt;p&gt;Another great thing that I've learned about TypeScript is you can mix JavaScript in with the code and have no issues doing so.  Check the screenshot below (this is inside an Angular app):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-1.png" alt="typescript and javascript code"&gt;&lt;/a&gt;TypeScript and JavaScript used together in the same file&lt;/p&gt;



&lt;h2&gt;Data Types&lt;/h2&gt;

&lt;p&gt;Let's get started with the fun stuff - data types!  (There are a few data types we won't cover - never, null, undefined.  This is simply because there isn't much to them.  I want you to know they exist and if you'd like to dig in more on those types, here is a link to the official &lt;a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" rel="noopener noreferrer"&gt;TypeScript documentation&lt;/a&gt; for your reference.) &lt;/p&gt;

&lt;p&gt;TypeScript will infer the type of data assigned to a variable without you explicitly setting the type but for simplicity and good measure I like to declare the data type when declaring my variables.&lt;/p&gt;

&lt;p&gt;We assign data types by simply placing a colon after the variable name but before the equal sign: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;const {variable name}: {variable type} = {variable value&lt;/strong&gt;&lt;/em&gt;}  &lt;/p&gt;

&lt;p&gt;This is the convention that the majority of TypeScript data types are declared with the exception of functions and objects.&lt;/p&gt;

&lt;p&gt;Some data types come with a bit more complexity than that, but you get the general idea.  Below are some brief explanations of data types and examples of how to declare them.&lt;/p&gt;

&lt;h4&gt;Boolean&lt;/h4&gt;

&lt;p&gt;Booleans in TypeScript work the same way as they do in JavaScript.  Variables of data type boolean are declared like so: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;const myBool: boolean = false&lt;/code&gt;;&lt;/p&gt;

&lt;h4&gt;String&lt;/h4&gt;

&lt;p&gt;Strings in TypeScript work the same way as they do in JavaScript.  Variables of data type string are declared like so: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;code&gt;let myString: string = 'bacon'&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;Number&lt;/h4&gt;

&lt;p&gt;Numbers in TypeScript work the same way as they do in JavaScript.  Variables of data type number are declared like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const myNum: number = 1207;&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
&lt;strong&gt;Array&lt;/strong&gt; &lt;/h4&gt;

&lt;p&gt;Arrays in TypeScript are, like other data types, just like arrays in JavaScript.  Variables of data type array are declared two separate ways :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const myArr: number[] = [12, 90, 71];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The above way is how you'd declare an array if all of the elements inside that array are numbers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const myArr: Array&amp;lt;number&amp;gt; = [12, 90, 71];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This way of declaring an array uses the generic array type set to number.  Functionally, there is no difference in how these ways produce the end result of declaring a variable with array type.&lt;/p&gt;

&lt;p&gt;If the data types inside the array are unknown or a mixture of data types, the array can be declared using the &lt;em&gt;&amp;lt;any&amp;gt;&lt;/em&gt; type (this is a type all on it's own that is discussed below): &lt;/p&gt;

&lt;p&gt;&lt;code&gt;const myArr: Array&amp;lt;any&amp;gt; = [12, 'thirteen', false];&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;This way will allow you to mix data types in the array.  &lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;Tuples&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;Tuples are a data type unique to TypeScript.  Think of them as arrays with a fixed number of elements.  This data type is best used when you know exactly how many variables you should have.  It is possible to reassign the value of the indices but not the amount of elements in the tuple.&lt;/p&gt;

&lt;p&gt;Variables of data type tuple are declared just like an array:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let mine: [number, string];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we'd like to change the &lt;em&gt;values&lt;/em&gt; of elements, we can do that as long as they match the types we provided when declaring our variable:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mine[0] = 14&lt;/code&gt;  ✔️  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mine[0] = 'Steve' &lt;/code&gt; ❌ &lt;/p&gt;

&lt;p&gt;Since we defined &lt;code&gt;mine&lt;/code&gt; as a tuple, the order of the values matter as well and cannot be changed  Also, assigning an index outside of the original defined number will produce an error:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mine[0] = ['Dave', 71]&lt;/code&gt;  ❌  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mine = [121, 'Dave', 'Steve']; &lt;/code&gt; ❌   &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mine = [121, 'bacon'];&lt;/code&gt;  ✔️ &lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;Function&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;Functions can be as explicit as you want them to be.  What I mean by that is we can apply types to the parameters and returned values.  Below are two examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-2.png" alt="a function that returns the number 91"&gt;&lt;/a&gt;We explicitly define the type of value we expect this function to return&lt;/p&gt;

&lt;p&gt;This function will throw an &lt;em&gt;error&lt;/em&gt; if any value is returned that is not a number or points to a number.  It may return a variable &lt;em&gt;&lt;strong&gt;only if&lt;/strong&gt;&lt;/em&gt; that variable points to a number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-13.png" alt=""&gt;&lt;/a&gt;We can define the types of parameters we expect as well&lt;/p&gt;

&lt;p&gt;Above, we're type checking on the parameters being passed into our function.  This is a  great way to avoid mistakes because if the number of parameters is off  or if their data type doesn't match what we're expecting TypeScript will  let us know with an error.&lt;/p&gt;

&lt;p&gt;If I want a function that should not return a value, I can set the type as &lt;em&gt;void &lt;/em&gt;(a data type that means the absence of any data.  While it can be used when declaring variables it typically isn't because then we'd have to set the variable to &lt;em&gt;null&lt;/em&gt; or &lt;em&gt;undefined&lt;/em&gt;,  I've only used when functions should have no return value) and if the function returns anything TypeScript will throw an error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-3.png" alt="a typescript function with the type set to void"&gt;&lt;/a&gt;A function with the type set to void&lt;/p&gt;

&lt;p&gt;By setting the type to &lt;em&gt;void&lt;/em&gt; I'm being explicit about my returns and establishing that while this function may still run, it should not &lt;em&gt;return&lt;/em&gt; a value.  If it does return a value, I'll get an error.&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;Enum&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;Enums are a welcomed (in my humble opinion) addition to the data types.  Think of them as a more user friendly approach to giving names to numeric values.  Here is an example of an enum:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;enum Foods {'bacon', 'tomato', 'lettuce'};&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;console.log(Foods[0]) // yields 'bacon'
console.log(Foods.bacon) // yields 0 
console.log(Foods['lettuce']) // yields 2 &lt;/pre&gt;

&lt;p&gt;It's also possible to assign the numbering index format with enums as well.  Many languages including C# have enums and I'm happy to see them come to JavaScript.&lt;/p&gt;

&lt;p&gt;You can be as creative as you want with the names.  You can even change the numeric representation of the indices.  If you want your first index to start at 18 instead of 0, it's as simple as:&lt;/p&gt;

&lt;p&gt; &lt;code&gt;enum Foods {'bacon'= 18, 'tomato', 'lettuce'};&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(Foods['bacon']); // 18&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's say we had the value 18 but were unsure of what it mapped to in our &lt;code&gt;Foods&lt;/code&gt; enum, we can check that as well:&lt;/p&gt;

&lt;p&gt; &lt;code&gt;console.log(Foods[18]); // 'bacon'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One piece of noteworthy information is now that we've set the first index to start at 18, the next index will be 19, and so on following the numbering convention you establish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Objects in TypeScript are defined in similar ways as objects in JavaScript are defined.  We can be as implicit or explicit with our definition as we like or as the situation dictates:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let data: = {name: 'Jonathan', age: 30, hobbies: ['running','swimming','coding']};&lt;/code&gt;  ✔️ &lt;/p&gt;

&lt;p&gt;&lt;code&gt;let data: {name: string, age: number, hobbies: string[]} = {name: 'Jonathan', age: 30, hobbies: ['running','swimming','coding']};&lt;/code&gt;  ✔️ &lt;/p&gt;

&lt;p&gt;When creating objects, the property names are immutable, but the order in which they appear does not matter, even if we define them in a specific order. &lt;/p&gt;

&lt;p&gt;Also, we can have simple objects like those above, or we can define complex objects that take advantage of multiple data types like the one below (this object is for demonstration purposes only):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-4.png" alt="a complex object data type in TypeScript"&gt;&lt;/a&gt;Here we explicitly set data types where possible in this complex object &lt;/p&gt;

&lt;h4&gt;Type Alias/Interface&lt;/h4&gt;

&lt;p&gt;With the example of a complex object above, you might be thinking this is awesome but what happens the next time I need to create a complex object?  I need to type all of this out manually again?&lt;/p&gt;

&lt;p&gt;Fear not, the type alias and interface types are here to help!  A type alias is a data type that allows us to save other data types inside of it and then reference a variable instead of rewriting code over and over.  &lt;/p&gt;

&lt;p&gt;As a side note, type aliases and interfaces work in very similar ways.  Both allow us to scaffold an object/blueprint for how our data should be structured.  However, there are &lt;strong&gt;&lt;em&gt;subtle differences&lt;/em&gt;&lt;/strong&gt; that we won't cover here.  Instead, here is a &lt;a href="https://medium.com/@martin_hotell/interface-vs-type-alias-in-typescript-2-7-2a8f1777af4c" rel="noopener noreferrer"&gt;post that explains those differences&lt;/a&gt; in an extremely efficient fashion if you'd like to dig deeper.&lt;/p&gt;

&lt;p&gt;There are details between the two that we should be aware of - when using the type alias, we use an equals sign (=) to declare values, the interface does not require an equal sign. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-6.png" alt="the interface data type in typescript"&gt;&lt;/a&gt;The interface type works very similarly to the type alias but requires no equals sign (=).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-5.png" alt="an alias data type in typescript"&gt;&lt;/a&gt;Alias data types do require an equals sign (=).&lt;/p&gt;

&lt;p&gt;Now that we have our alias declared, it's time to make use of that alias.  When we want to "build" our new variable from this alias, we simply set it as the data type:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-7.png" alt="a typescript object "&gt;&lt;/a&gt;Scaffolding objects using the interface / type data types is extremely useful :)&lt;/p&gt;

&lt;p&gt;It's important to note that the &lt;em&gt;interface&lt;/em&gt; is specific to TypeScript.  It is used only at compile time to do type checking and to catch any errors that may have slipped past our watchful eye.  &lt;strong&gt;The data from our interface will end up in our final code, but the interface itself is compiled out&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Classes are, in part, the veritable "bread and butter" of TypeScript (at least in my humble opinion).  Staying with this idea of scaffolding new objects, classes allow us to build data in a much easier way than just manually typing them out each time the need arises.  &lt;/p&gt;

&lt;p&gt;Classes can be thought of as blueprints for how our data should be defined and what actions, if any, it should be capable of through methods.&lt;/p&gt;

&lt;p&gt;Below is an example of a class in TypeScript (which is made possible by the introduction of classes in ES6):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-10.png" alt="typescript code showing the use of class data type"&gt;&lt;/a&gt;A TypeScript class, ready for instantiation :)&lt;/p&gt;

&lt;p&gt;Now, you might be asking yourself what are the differences between a &lt;em&gt;class&lt;/em&gt;, a &lt;em&gt;type alias&lt;/em&gt;, and an &lt;em&gt;interface&lt;/em&gt;?  Great question!  The main difference between is that classes can be instantiated (we can create new instances of them) but an interface cannot.&lt;/p&gt;

&lt;p&gt;There are, of course, other differences but that's not contained in the scope of this article.  If you'd like to dig deeper, here is a &lt;a href="https://ultimatecourses.com/blog/classes-vs-interfaces-in-typescript#Using_TypeScript_class_vs_using_Typescript_interface" rel="noopener noreferrer"&gt;great article&lt;/a&gt; I read to help me understand those differences.  You'll find use cases for all of them, as I have, when using TypeScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Union&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is, far and away, my favorite data type of TypeScript!  The union type allows us declare a variable and then set it to an "either or" value.  What I mean by that is let's say we're expecting data to be passed into a function but we aren't sure if it's a string or a number - this is the perfect (and intended) purpose of the union type.&lt;/p&gt;

&lt;p&gt;We use the single pipe character (on Windows it's Shift + the key right above Enter) when defining the type.  Here's what it would look like when defining a variable with union data type:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const numOfDoors: string | string[ ];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This tells TypeScript that &lt;em&gt;numOfDoors&lt;/em&gt; is a variable that can hold either a string or an array of strings.&lt;/p&gt;

&lt;p&gt;Here is an example of that function I mentioned earlier using union type:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-11.png" alt="typescript code showing the use of union type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Any &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Any is the type we set whenever we're unsure of the types of data we'll be getting.  Maybe we're getting something from a third party or some dynamic data and we aren't 100% sure if we're getting a string, a number, or maybe an array of information.  This is the perfect use case for type &lt;em&gt;any&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fimage-12.png" alt="typescript code showing use of the any type"&gt;&lt;/a&gt;Data type any is a way to opt out of type checking&lt;/p&gt;

&lt;p&gt;I will caution against using type &lt;em&gt;any &lt;/em&gt;unless you absolutely must because when used we're opting out of one of the core features of TypeScript - type checking.&lt;/p&gt;

&lt;p&gt;However, this data type has it's use cases just like all of the data types mentioned.&lt;/p&gt;

&lt;h2&gt;That's A Wrap!&lt;/h2&gt;

&lt;p&gt;I told you this wouldn't take too long :D &lt;/p&gt;

&lt;p&gt;I hope you enjoyed this article about TypeScript and are exited about the how it can prove useful to your code base.  In the next article, we'll dig into the practical side of TypeScript.  We'll go over installing it, compiling, and using it in your project (not just Angular projects either)!&lt;/p&gt;

&lt;p&gt;This was originally posted to my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; :)&lt;/p&gt;

&lt;p&gt;While you’re here don't forget to sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt; –   you can do that at the top right of the page when clicking the link above.  I promise I’ll never spam your inbox and your information will not be shared with   anyone/site.  I like to occasionally send out interesting resources I  find, articles about web development, and a list of my newest posts.&lt;/p&gt;

&lt;p&gt;If you haven't yet, you can also connect with me on social media!  All of my links are also at the top right of the aforementioned page.  I love connecting with others and meeting new people so don't afraid to say hi :)&lt;/p&gt;

&lt;p&gt;Have an awesome day friend and happy coding!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>learntocode</category>
      <category>datatypes</category>
    </item>
    <item>
      <title>Conquering Job Interview Code Challenges v2.0</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Sat, 17 Aug 2019 04:17:30 +0000</pubDate>
      <link>https://dev.to/jsgoose/conquering-job-interview-code-challenges-v2-0-518l</link>
      <guid>https://dev.to/jsgoose/conquering-job-interview-code-challenges-v2-0-518l</guid>
      <description>&lt;p&gt;As many of you know, I &lt;a href="https://jonathansexton.me/blog/landing-my-first-development-job-what-a-crazy-journey/" rel="noopener noreferrer"&gt;landed my first developer job&lt;/a&gt; at the end of June and I thought it would be great to use the challenge I was given as the subject of today's article.&lt;/p&gt;

&lt;p&gt;It is important to note that I used React to build my project, but this could have been completed with any front end framework or 'vanilla JavaScript'.&lt;/p&gt;

&lt;p&gt;Below is a list of topics we'll go over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accessing the &lt;a href="https://quip.com/dev/automation/documentation#token-endpoint" rel="noopener noreferrer"&gt;Quip Automation API&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Creating spreadsheets/documents with the Quip API&lt;/li&gt;
&lt;li&gt;Installing and using the &lt;a href="https://github.com/axios/axios" rel="noopener noreferrer"&gt;Axios&lt;/a&gt; library (this is optional and you can make API requests without it but I like the syntax) &lt;/li&gt;
&lt;li&gt;Using &lt;a href="https://www.npmjs.com/package/qs" rel="noopener noreferrer"&gt;qs package&lt;/a&gt; to stringify requests (this is not a requirement but I wanted to try something new and if it didn't work I always had the fallback of knowing Axios will stringify my requests by default)&lt;/li&gt;
&lt;li&gt;Making &lt;a href="https://en.wikipedia.org/wiki/POST_(HTTP)" rel="noopener noreferrer"&gt;POST&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="noopener noreferrer"&gt;GET&lt;/a&gt; requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For context, here is a snippet of the requirements as I received them: &lt;/p&gt;

&lt;p&gt;"&lt;em&gt;Create a front-end web app that interacts with the Quip API in the following ways:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Create a spreadsheet (bonus points to import data into the newly created spreadsheet). &lt;/em&gt;&lt;ul&gt;&lt;li&gt;&lt;em&gt;By import data, I mean upload an Excel spreadsheet, or copy and paste data into Quip spreadsheet. &lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Export a Quip spreadsheet to .xlsx&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Download (backup) a folder/multiple documents.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Create the UI for the page in whatever way you see fit (buttons, dialog boxes, etc).&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;I was a little worried when I read the requirements as I wasn't exactly sure where to begin.  So, I dug into the API docs and started soaking up information.  Thankfully, no time limit was given to me but I wanted to be done with this as soon as possible to see where I stood in the interview process.  &lt;/p&gt;

&lt;p&gt;To start, I designed a prototype of the finished product in Figma so I'd have a road map to go off of.  This is not a required step, but it does make your project building experience run much smoother.  &lt;/p&gt;

&lt;p&gt; Alright, let's dig in! &lt;/p&gt;

&lt;h2&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;I built my Nav, Footer, and Content components so I'd have a solid foundation for my app.  &lt;/p&gt;

&lt;p&gt;Each of these components return some basic JSX and there isn't much to them (If you'd like to see the code for each you can check out the project's &lt;a href="https://github.com/JS-goose/gibson-code-challenge" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I decided the majority of the requests would be split between the &lt;em&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;CenterContent.js&lt;/code&gt;&lt;/em&gt; files.&lt;/p&gt;

&lt;p&gt;For reference, here is my project structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage.png" alt="react code showing a project structure" width="800" height="400"&gt;&lt;/a&gt;My project structure&lt;/p&gt;

&lt;p&gt;You'll see me reference POST and GET requests throughout this post.  If you aren't familiar with those now is a good time to do some research on those.  I'll be honest in that I wasn't 100% on them when starting this project and had to go through some resources myself.&lt;/p&gt;

&lt;p&gt;In a nutshell, a POST request is when we ask the server to &lt;strong&gt;&lt;em&gt;accept&lt;/em&gt;&lt;/strong&gt; some incoming data (that we are sending) - in our case that data comes in the form of creating a new spreadsheet file.&lt;/p&gt;

&lt;p&gt;A GET request is when we ask the server to &lt;strong&gt;&lt;em&gt;send&lt;/em&gt;&lt;/strong&gt; us data from a specified resource on the server.&lt;/p&gt;

&lt;p&gt;I used the &lt;a href="https://insomnia.rest/" rel="noopener noreferrer"&gt;Insomnia REST Client&lt;/a&gt; to help debug issues with my requests.  I'm working on a beginner's guide for it so stay tuned for that!&lt;/p&gt;

&lt;h2&gt;Using the Quip API&lt;/h2&gt;

&lt;p&gt;If you're like me, you've never heard of the Quip API and had no idea what it does.  At it's core, Quip is an automation tool that allows you to integrate with tools like &lt;a href="https://www.salesforce.com/" rel="noopener noreferrer"&gt;SalesForce&lt;/a&gt; to make your sales team more collaborative.&lt;/p&gt;

&lt;p&gt;For our purposes, we will be using it to create Excel spreadsheets on my Quip account (if you want to replicate this project you'll need to create a Quip account - it is free to do so).&lt;/p&gt;

&lt;p&gt;You'll also need to create a personal developer token in order to make requests.  You can do that &lt;a href="https://quip.com/dev/token" rel="noopener noreferrer"&gt;here&lt;/a&gt; (requires an account).  Once you have your token, keep it in a safe spot because we'll be making use of it soon.&lt;/p&gt;

&lt;p&gt;To start, I installed Axios into my project by running &lt;code&gt;npm install axios&lt;/code&gt; and then I import it into the files where I need to make my requests with &lt;code&gt;import axios from "axios";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-1.png" alt="a code snippet of react import statements" width="800" height="400"&gt;&lt;/a&gt;My import statements for required packages&lt;/p&gt;

&lt;h2&gt;Authentication&lt;/h2&gt;

&lt;p&gt;Before making any kind of requests to the server, I needed to authenticate with my credentials.    I decided to put this in the &lt;code&gt;App.js&lt;/code&gt; file inside a &lt;code&gt;componentDidMount&lt;/code&gt; &lt;a href="https://reactjs.org/docs/state-and-lifecycle.html" rel="noopener noreferrer"&gt;lifecycle method&lt;/a&gt; so it would load every time the page loads:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-4.png" alt="some react code showing an authentication call to an outside API" width="800" height="400"&gt;&lt;/a&gt;My authentication function&lt;/p&gt;

&lt;p&gt;So I built my function, I called my function and for a moment thought all is well, until I ran into this dreaded error: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at $websiteName"&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Noooooooo!!! The dreaded &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors" rel="noopener noreferrer"&gt;CORS&lt;/a&gt; monster rears it's mighty head!  (CORS is actually a useful intermediary between me and the server but can be annoying to deal with if you've never seen this error before).  &lt;em&gt;*Side note - if you've never seen this error before don't worry!  I still don't fully understand it but I know enough to debug it.  If you get stuck, check out the link above for some helpful info or look below for a quick work around.*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;An easy way to get around this is to use a proxy like the &lt;a href="https://cors-anywhere.herokuapp.com/" rel="noopener noreferrer"&gt;CORS Anywhere&lt;/a&gt; free resource.  Essentially, place this link &lt;code&gt;https://cors-anywhere.herokuapp.com/&lt;/code&gt; in front of your end point URL and it'll resolve the problem, for now.&lt;/p&gt;

&lt;p&gt;This handy tool will allow you to make your requests &lt;strong&gt;&lt;em&gt;while developing on localhost&lt;/em&gt;&lt;/strong&gt;.  If I were you, I would do some research before using this approach in production.  Full disclaimer, I don't know enough about this little trick to tell you if it's safe to use in production or not.&lt;/p&gt;

&lt;p&gt;So, after some tweaking of the authentication function I got the desired result to log to the console.  Time to move on to making requests!&lt;/p&gt;

&lt;h2&gt;Making Requests&lt;/h2&gt;

&lt;p&gt;Now that my authentication is working, we're ready to make some requests.  I knew I was going to make a POST request whenever I wanted to create a new document and that I also wanted to tie that action to the click of a button.  So, below is my POST function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-3.png" alt="a POST function call to an outside API" width="800" height="400"&gt;&lt;/a&gt;My POST function&lt;/p&gt;

&lt;p&gt;You'll notice this is where our &lt;code&gt;qs&lt;/code&gt; package I mentioned at the beginning of this article comes into play.  I'm not an expert but from what I gleaned after reading the docs on it, this package turns my request into a string to be sent to the server.  If you prefer not to use this package that's no problem as &lt;code&gt;Axios&lt;/code&gt; will do this by default.  I know that  &lt;code&gt;qs&lt;/code&gt; offers more than just stringifying data but I'm unfamiliar with the full range of its capabilities.&lt;/p&gt;

&lt;p&gt;Now, I want this function to fire when clicking a button.  Thus, a basic button came to life!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-5-1024x96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-5-1024x96.png" alt="some react code for a simple button" width="800" height="400"&gt;&lt;/a&gt;A simple React button with an on click method&lt;/p&gt;

&lt;p&gt;My POST function has been built, my button has been built, and the method tied to it.  It's time to cross my fingers and see what my function spat out into the console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-6.png" alt="a console log statement from an outside API call" width="800" height="400"&gt;&lt;/a&gt;The result of my server request - it works!&lt;/p&gt;

&lt;p&gt;At this point I'm over the moon!  I'm beyond excited that I've gotten this API call to not only work but to return something as well.  Now the real test...does this show up as a new spreadsheet on my Quip account?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fimage-7.png" alt="a quip account showing the creating of a spreadsheet" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have the console statement and the confirmation from my Quip account showing that I have successfully created a new spreadsheet - this is awesome!  I'm ecstatic and I literally jumped out of my chair and yelled "YEEEEEEESSSSSS!!!" once I got both of these.&lt;/p&gt;

&lt;p&gt;That feeling of getting something to work after struggling with it is like nothing else I've experienced in my professional life.  I tell myself that I have to keep riding this wave of enthusiasm and elation so I push on to the next item on the list.&lt;/p&gt;

&lt;h2&gt;Import Data Into the Newly Created Spreadsheet&lt;/h2&gt;

&lt;p&gt;I had some great ideas for this section of the "assignment" but at this point it has been almost two weeks since I started this project and I'm anxious that the interviewer will have forgotten about it (i.e. me) or is getting impatient with me.&lt;/p&gt;

&lt;p&gt;So, I scrap those grand plans and opt for something of a more simple nature so I can get this project turned in ASAP.&lt;/p&gt;

&lt;p&gt;I built a small function to at least attach to the upload button so that I would have some type of functionality for it.  At it's core, this function waits until a file has been uploaded, sets the state to the first element in the event target array, then creates headers based off of that information, with the eventual goal being it posts to my Quip account with that information.&lt;/p&gt;

&lt;p&gt;However, you can tell by the comment at the top of this function block that I was unable to get it to work properly.  However, I did not have time (at least I thought I didn't) to dig deep into this problem and get it fixed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage-3.png" alt="a snippet of react code showing an upload function" width="800" height="400"&gt;&lt;/a&gt;My import function that never quite worked properly :)&lt;/p&gt;

&lt;p&gt;At this point, I've been working on this project after work and at night for over two weeks.  I decide that it's time to turn it in without the other parts working (import, export, and downloading data).&lt;/p&gt;

&lt;h2&gt;The Final Touches&lt;/h2&gt;

&lt;p&gt;I know my project is unfinished and I'm beating myself up pretty hard about it.  But, as an added bonus I decide that I'm going to design something in &lt;a href="https://www.figma.com/" rel="noopener noreferrer"&gt;Figma&lt;/a&gt; as an added touch to help my chances of getting a call back.&lt;/p&gt;

&lt;p&gt;Here is the finished product modeled off of their current colors/font/theme:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage-4-1024x731.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fimage-4-1024x731.png" alt="a react app showing database table data" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;And That's A Wrap&lt;/h2&gt;

&lt;p&gt;With my project not finished but at a stopping point, I'm feeling not so good about my progress and my timing but I package everything up and throw it on GitHub.  I throw in the above image and schedule an e-mail to go out the next morning at 9AM to the interviewer.&lt;br&gt;&lt;br&gt;I waited nearly 2 days with baited breath hoping to get some type of call back - something.  It finally came as I was driving into work.  The interviewer had gotten my project and wanted me to come in for another meeting with his lead developer.&lt;/p&gt;

&lt;p&gt;I was terrified and excited all at the same time because I was thinking they wanted to bring me in to make fun of my code or to ask me what the hell I was thinking when I built this monstrosity.  But that wasn't the case at all.  I ended up getting a job offer from this project!  &lt;/p&gt;

&lt;p&gt;If you'd like the whole story about that, it can be found in my previous blog &lt;a href="https://jonathansexton.me/blog/landing-my-first-development-job-what-a-crazy-journey/" rel="noopener noreferrer"&gt;post about landing my first developer job.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you've found some value out of this post.  If you have let me know on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or any of the other platforms I post on :D&lt;/p&gt;

&lt;p&gt;Also, I cross post most of my articles on great platforms like  &lt;a href="https://www.freecodecamp.org/news/author/jonathan/" rel="noopener noreferrer"&gt;freeCodeCamp&lt;/a&gt; and &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; so you can find my work there as well!&lt;/p&gt;

&lt;p&gt;While you’re here why not sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt; –  you can do that at the top right of the page on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.  I promise I’ll never  spam your inbox and your information will not be shared with  anyone/site.  I like to occasionally send out interesting resources I find, articles about web development, and a list of my newest posts.&lt;/p&gt;

&lt;p&gt;Have an awesome day filled with love, joy, and coding!&lt;/p&gt;

</description>
      <category>jobhunt</category>
      <category>interview</category>
      <category>challenge</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Landing My First Development Job – What a Crazy Journey!</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Mon, 08 Jul 2019 09:24:52 +0000</pubDate>
      <link>https://dev.to/jsgoose/landing-my-first-development-job-what-a-crazy-journey-203m</link>
      <guid>https://dev.to/jsgoose/landing-my-first-development-job-what-a-crazy-journey-203m</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fjapheth-mast-Ls3yexjyRpk-unsplash.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fjapheth-mast-Ls3yexjyRpk-unsplash.jpg" alt="the grow with google award badge" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You read the title right!  I was offered a development position with a company and after some negotiating I accepted their very generous offer!  &lt;/p&gt;

&lt;p&gt;I am beyond blown away, excited, happy, and (if I'm being 100% honest) terrified - in a good way though!  I'm still in disbelief that this is really happening but ecstatic to start working on production code!&lt;/p&gt;

&lt;p&gt;I've had a lot of people ask me to distill my journey into an article to share and help others.  So, buckle in because here we go!&lt;/p&gt;








&lt;h2&gt;Getting Started&lt;/h2&gt;





&lt;p&gt;I've always been interested in computers, tech, etc.  Like many people my age, I got to 'cut my teeth' with development by creating a &lt;a href="https://en.wikipedia.org/wiki/Yahoo!_GeoCities" rel="noopener noreferrer"&gt;GeoCities&lt;/a&gt; site and later by personalizing my MySpace page with some basic CSS.  &lt;/p&gt;

&lt;p&gt;I didn't know it at the time but this was development, a crude version of it but still development nonetheless.  At that time, I didn't know that people would pay for this kind of work or I might have stuck with it.  So, I went to college and got a degree in nothing tech related - psychology.  Not a useless degree, but one I ultimately never put into professional use.&lt;/p&gt;

&lt;h2&gt;Finding My Calling&lt;/h2&gt;

&lt;p&gt;Fast forward to the summer time in 2016 where I found myself with an abundance of free time on my hands outside of work.  I had always wanted to teach myself to code/program and decided now was the time - no more delay.  With the amount of free and accessible resources online to teach myself how to code it was the perfect time to jump in.&lt;/p&gt;

&lt;p&gt;I started by searching for resources and came across &lt;a href="https://www.codecademy.com/" rel="noopener noreferrer"&gt;CodeCademy&lt;/a&gt; where I took handwritten notes by copying the entire question, answer, and result into a notebook.  I literally wrote down everything thinking that I would need it.  I came back to these notes from time to time to review them.  It's also interesting to look back on them and compare what I considered difficult then to what I consider difficult now :)&lt;/p&gt;

&lt;p&gt;A friend introduced me to &lt;a href="https://freecodecamp.org" rel="noopener noreferrer"&gt;freeCodeCamp&lt;/a&gt; because he knew I was self teaching and told me this platform was built for people like me.  I had planned to check it out, maybe do one or two lessons and then go to bed.  I finished the entire section on HTML that night!  I was hooked.&lt;/p&gt;

&lt;p&gt;The more I learned the more questions I had.  I felt this urge, this pull to find answers to those questions.  So I continued on working through the lessons and projects.  I finished 2 projects before the curriculum was overhauled and revamped on freeCodeCamp. &lt;/p&gt;

&lt;p&gt;I was finding any excuse to learn and work on projects.  While I was standing in any line waiting for something I would pull out my phone and instead of looking at social media, I began to read web development articles or watch a development related video.  &lt;/p&gt;

&lt;p&gt;I feel like this was a major shift in the way I viewed downtime as compared to previously where 'mindless consumption' &lt;em&gt;(If you enjoy social media or funny animal videos I'm not calling you mindless, I'm simply saying that type of consumption typically doesn't require you to be engaged.  It's the type of consumption that you can do on auto pilot and frankly I still do it from time to time)&lt;/em&gt; ruled my time. &lt;/p&gt;

&lt;p&gt;During that time I had bounced around the various different sources and was like a kid in a candy store.  At one point I had a folder that had roughly 300 links to material I had planned to work through.  I now know that finding a resource and sticking with it is far better than hoping from one resource to another.&lt;/p&gt;

&lt;p&gt;I was doing all of this at night when my wife and daughter were asleep.  I was staying up until 12:30 AM sometimes as late as 2:00 AM and then having to get up at 6:00AM to do my normal day job.  At first, when the topics weren't as mentally taxing this was not an issue.  But as I started moving into JavaScript, learning the basics of networking, servers, accessibility, etc I noticed that the later it got, the more difficult it became to keep my brain engaged.&lt;/p&gt;

&lt;p&gt;Needless to say, this routine only lasted a few months before having to change it.&lt;/p&gt;

&lt;p&gt;I didn't want to stop working on projects/learning but I needed to alter my schedule in order to benefit my well being.  That's when I decided to go to the other end of the work day spectrum.&lt;/p&gt;

&lt;p&gt;I started getting up at 4:00 AM, instead of staying up late, to learn and work on projects before going to the gym then starting my day.  I must say, this was a pivotal moment in my journey because I started to retain more of the information I was learning and that ultimately helped me move forward with more projects/material.&lt;/p&gt;

&lt;p&gt;Also, this is the time when I started to buy up every resource I could find (&lt;a href="https://udemy.com" rel="noopener noreferrer"&gt;Udemy&lt;/a&gt; courses and books mostly) dealing with any aspect of web development.  I can tell you that this isn't a wise (or financially sound) choice to make.  If you find a resource you like and that you're learning from then stick with that resource until it's exhausted.  The last thing you want to be doing is jumping to the new resource each time you find one like I did.&lt;/p&gt;

&lt;h2&gt; Grow With Google &amp;amp; Udacity Scholarship &lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2FGrowWithGoogleDeveloperChallengeScholarship.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2FGrowWithGoogleDeveloperChallengeScholarship.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In January 2018 I applied for and was awarded a scholarship to Udacity's Front-End Nanodegree program.  This was not only an awesome opportunity to help propel me towards my goal but a humbling experience as well.  &lt;/p&gt;

&lt;p&gt;I came into this program with a basic knowledge of HTML, CSS, and a small portion of JavaScript in the vanilla flavor.  In this course I was introduced to &lt;a href="https://jquery.com/" rel="noopener noreferrer"&gt;jQuery&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Functional_programming" rel="noopener noreferrer"&gt;functional programming&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Object-oriented_programming" rel="noopener noreferrer"&gt;object-oriented programming&lt;/a&gt; (OOP), &lt;a href="https://en.wikipedia.org/wiki/Test-driven_development" rel="noopener noreferrer"&gt;test driven development&lt;/a&gt; (TDD), &lt;a href="https://en.wikipedia.org/wiki/Accessibility" rel="noopener noreferrer"&gt;accessibility&lt;/a&gt;, servers, &lt;a href="https://en.wikipedia.org/wiki/Application_programming_interface" rel="noopener noreferrer"&gt;API's&lt;/a&gt;, basic networking, &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noopener noreferrer"&gt;AJAX&lt;/a&gt;, and so many more facets of web development that I hadn't previously been exposed to.&lt;/p&gt;

&lt;p&gt;I'll be honest, it wasn't always easy or fun and there were times I seriously considered dropping out.  I felt like I would never learn these concepts and that I was in over my head.&lt;/p&gt;

&lt;p&gt;I'm happy that I didn't quit because no one ever accomplished their goals by quitting - first and only cliche statement I promise :D&lt;/p&gt;

&lt;p&gt;I had the chance to build many awesome projects like the &lt;a href="https://github.com/JS-goose/card-matching-game" rel="noopener noreferrer"&gt;Card Matching Game&lt;/a&gt;, &lt;a href="https://github.com/JS-goose/frontend-nanodegree-arcade-game" rel="noopener noreferrer"&gt;Arcade Game Replica&lt;/a&gt;, &lt;a href="https://github.com/JS-goose/mws-restaurant-stage-1" rel="noopener noreferrer"&gt;Restaurant Review App&lt;/a&gt;, and the &lt;a href="https://github.com/JS-goose/neighborhood-map-react" rel="noopener noreferrer"&gt;Neighborhood Map App&lt;/a&gt;.  More than the projects though, I got to meet many great people and valuable experience collaborating with other developers in the course.&lt;/p&gt;

&lt;p&gt;Without this course, I can truly and honestly say that I would not be where I am today.  I gained many valuable experiences and lessons in this 9 month course.&lt;/p&gt;

&lt;h2&gt;Job Hunting...dun dun duuuuunnn!&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fsven-mieke-fteR0e2BzKo-unsplash-1024x683.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F07%2Fsven-mieke-fteR0e2BzKo-unsplash-1024x683.jpg" alt="a pencil on drafting plans" width="800" height="400"&gt;&lt;/a&gt; Photo by &lt;a href="https://unsplash.com/@sxoxm?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Sven Mieke&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/job-search?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;At this point I had been working diligently (sometimes slacking off as well) for about two years.  I did not feel as though I was job ready but a friend who became my mentor told me that I'll never feel ready.  He said that I should apply and if I get interviews then let them tell me I'm not ready if that's the case but to not exclude myself from an opportunity.&lt;/p&gt;

&lt;p&gt;So, with a metric ton of fear, anxiety, and doubt I decided to start applying for jobs.&lt;/p&gt;

&lt;p&gt;At first, I was only applying for jobs where I met the majority of the qualifications.  I can tell you now that this is not the way to do it, however, at the time I was terrified that someone would actually call me about an interview. (&lt;em&gt;Later down the road I was applying for anything that interested me.  Senior developer - sure, I applied for that.  Front-end ninja with React skills - yep, threw in an application for that as well.  API developer with SQL experience - oh yeah!  I applied for that one as well.  I did this because you never know what will come of your application.  Maybe you don't get hired for that senior role but maybe they like you and your personality so much that they ask you to interview for their junior role.&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;That's exactly what happened after I'd been applying for about 3 months.  I got a call for my first interview!  I was so happy and scared at the same time.  Now the pressure was really on.&lt;/p&gt;

&lt;p&gt;I read articles, brushed up on my interviewing skills, read books, asked my wife to quiz me on topics, and tried to run through different scenarios that I thought would come up in the interview.  I also prepared questions for interviewer because I wanted to know what it was like to work at this company.&lt;/p&gt;

&lt;p&gt;Ultimately, I did what I wasn't supposed to do; I convinced myself that this was the perfect job and I wanted it.  I wanted it more than anything I could ever remember wanting.  I built it up as something that I had to have.&lt;/p&gt;

&lt;p&gt;The day of the interview came and to say I was nervous is an understatement.  I was sweating bullets.  I answered all of the questions and when it was my turn I asked the questions I had prepared.  After it was over I left feeling like the interview went well.&lt;/p&gt;

&lt;p&gt;Ultimately, I didn't get the position and I was crushed.  I felt like everything went like it should have but for some reason the stars just didn't align.  Little did I know that this would be a common pattern among my interviews.&lt;/p&gt;

&lt;p&gt;I decided not to let these disappointments define or destroy my confidence.  I started working harder, learning more, using that disappointment I felt to fuel my passion.  I would do whatever it took to ensure that one of these interviews would end with a full time offer.&lt;/p&gt;

&lt;p&gt;Here are some metrics about my job search:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;span&gt;Applications submitted across all platforms&lt;/span&gt;: &lt;strong&gt;271&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Any form of contact from company after application&lt;/span&gt;: &lt;strong&gt;28&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Phone Interviews&lt;/span&gt;: &lt;strong&gt;7&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;In person interviews&lt;/span&gt;: &lt;strong&gt;8&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Job offers&lt;/span&gt;: &lt;strong&gt;3&lt;/strong&gt; (one was contract with the (small) possibility for full time, one a part time freelance gig, and the eventual offer that I took for a full time position&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Companies that ignored me after expressing interest&lt;/span&gt;: &lt;strong&gt;Too many to count&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are applying for jobs, in any field, don't let the numbers discourage you!  Yes it is disheartening, yes it can be daunting, yes it stinks to fill out an application and never hear anything back, but don't quit!  You can do this!  I'm proof!&lt;/p&gt;

&lt;h2&gt;My Advice on Your Job Search&lt;/h2&gt;

&lt;p&gt;This is by no means an exhaustive list of tips/tricks but below are some pieces of advice I've picked up along my journey to getting a job in development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Develop thick skin - it's a must!  Companies will disappoint you&lt;/li&gt;
&lt;li&gt;Apply for anything you're interested in&lt;/li&gt;
&lt;li&gt;Apply even if you don't meet all of the requirements (this is what I did and also how I landed my first developer job)&lt;/li&gt;
&lt;li&gt;Spend time perfecting your resume&lt;/li&gt;
&lt;li&gt;Just because one companies turn you down doesn't mean you're a failure&lt;/li&gt;
&lt;li&gt;Show companies you can do the work by building projects outside of tutorials&lt;/li&gt;
&lt;li&gt;Ask for help if you need it (this was a hard one for me to learn)&lt;/li&gt;
&lt;li&gt;Apply for jobs on all of the major platforms but don't forget that platforms like &lt;a href="https://jobs.github.com/" rel="noopener noreferrer"&gt;GitHub jobs&lt;/a&gt; also exist&lt;/li&gt;
&lt;li&gt;Ensure you take care of yourself - get enough sleep, exercise, eat healthy (it's important for overall health!)&lt;/li&gt;
&lt;li&gt;Don't be afraid to take breaks&lt;/li&gt;
&lt;li&gt;Don't compare yourself, your job search, your situation, or your skills to others&lt;/li&gt;
&lt;li&gt;If it takes you 3 months or 3 years (like me) remember, this is not a race&lt;/li&gt;
&lt;li&gt; Work hard, learn well, and never give up! &lt;/li&gt;
&lt;/ul&gt;








&lt;p&gt;As always, I wish you nothing but the best in all you do.  If you need advice or help I'd be glad to do what I can.  Connect with me on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or &lt;a href="https://www.linkedin.com/in/jj-goose/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;  

&lt;p&gt;You can also see more of my writing on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; where I post frequent articles related to web development.  I also cross post the majority of my work on &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; if you'd like to give me a follow!&lt;/p&gt;

&lt;p&gt;I'm always willing to help and I love meeting new people so don't be afraid to say hello!&lt;/p&gt;

&lt;p&gt;Have an amazing day and happy coding!&lt;/p&gt;

</description>
      <category>job</category>
      <category>tech</category>
      <category>interview</category>
      <category>firstdeveloperjob</category>
    </item>
    <item>
      <title>Conquering Job Interview Code Challenges v1.0</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Mon, 27 May 2019 17:22:42 +0000</pubDate>
      <link>https://dev.to/jsgoose/conquering-job-interview-code-challenges-v1-0-2mh</link>
      <guid>https://dev.to/jsgoose/conquering-job-interview-code-challenges-v1-0-2mh</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1521769405690-26523cbd7d2d%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1000%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1521769405690-26523cbd7d2d%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1000%26q%3D80" alt="person standing on brown and black mountain under blue sky during daytime" width="1000" height="667"&gt;&lt;/a&gt; Photo by &lt;a href="https://unsplash.com/photos/nsexDkLGC-c?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Lê Tân&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As many of you know, I have been applying for a job in web development for a few weeks and I thought it would be a good idea to share some of the coding challenges I've encountered.  (&lt;em&gt;Side note, if you know of or have any available web developer positions I would greatly appreciate if you'd share them with me either here in the comments or on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; :D &lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;Not only that but I'll share the ways I went about solving these challenges.  Granted, there are many ways to solve these challenges but these are the ways I went about it.  If you have different ways that's awesome and I'd love for you to share them with me!&lt;/p&gt;

&lt;p&gt;I will not share any identifiable information about the companies or specifics on the interview process of said company to preserve process integrity.&lt;/p&gt;

&lt;p&gt;Alright, let's get to it then.&lt;/p&gt;

&lt;h2&gt;The Challenge&lt;/h2&gt;

&lt;p&gt;This is a challenge I was given recently that I felt good about solving:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Task: Return a basic styled list of posts from an endpoint in reverse chronological order&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To protect the company and their information, I will not share the URL from which I returned the information but instead will have a generic link from &lt;a href="https://jsonplaceholder.typicode.com/" rel="noopener noreferrer"&gt;JSONPlaceholder&lt;/a&gt; (a great, free, open source API for developers when you need to get some generic outside data) in the code below.&lt;/p&gt;

&lt;p&gt;Here's the HTML I started with so we have something to display our results in:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-3.png" alt="a code example showing HTML" width="800" height="400"&gt;&lt;/a&gt;Basic HTML boilerplate&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;&amp;lt;ul&amp;gt;&lt;/em&gt; tag has an id so we can style it later in the process.&lt;/p&gt;

&lt;h2&gt;Fetching Data From the Endpoint&lt;/h2&gt;

&lt;p&gt;Alright, let's dig into the &lt;strong&gt;JavaScript&lt;/strong&gt; portion of this challenge.  First, I like to set my output and display variables: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-4.png" alt="JavaScript code showing two variables being declared" width="800" height="400"&gt;&lt;/a&gt;Our variables used when displaying the returned code&lt;/p&gt;

&lt;p&gt;I use &lt;em&gt;let&lt;/em&gt; for the &lt;em&gt;&lt;span&gt;output&lt;/span&gt;&lt;/em&gt; variable and set it to &lt;em&gt;null&lt;/em&gt; because we will change it's value later in the code.  The &lt;em&gt;&lt;span&gt;list&lt;/span&gt;&lt;/em&gt; variable is declared with &lt;em&gt;const&lt;/em&gt; because it's value will not be chan&lt;span&gt;&lt;/span&gt;ging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-12.png" alt="javascript code showing a fetch function" width="800" height="400"&gt;&lt;/a&gt;Fetching data from the endpoint&lt;/p&gt;

&lt;p&gt;In the above example, we're declaring an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions" rel="noopener noreferrer"&gt;arrow function&lt;/a&gt; named &lt;em&gt;&lt;span&gt;getData&lt;/span&gt;&lt;/em&gt; wrapped in a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch" rel="noopener noreferrer"&gt;try...catch&lt;/a&gt; block (This is a cleaner/easier to use/read syntax that uses &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises" rel="noopener noreferrer"&gt;Promises&lt;/a&gt;&lt;/em&gt; under the hood - you'll also see the &lt;em&gt;catch&lt;/em&gt; portion below).  Because we're getting data asynchronously we also need to make use of &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await" rel="noopener noreferrer"&gt;async/await&lt;/a&gt; &lt;/em&gt;to fetch data.  This is the method I'm most comfortable with but I know there are many other ways to get data from an endpoint so feel free to share yours :D&lt;/p&gt;

&lt;p&gt;Once we've declared our &lt;em&gt;data&lt;/em&gt; variable, the next thing is to set a variable to turn the returned data to a JSON object so we can get it in a usable form.  We do that with the &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Body/json" rel="noopener noreferrer"&gt;.json()&lt;/a&gt;&lt;/em&gt; method.  We're awaiting the data as well because if we were to omit the &lt;em&gt;await&lt;/em&gt; keyword, JavaScript would try to turn the &lt;em&gt;data&lt;/em&gt; variable into JSON but the data would not be there yet because it's coming from an asynchronous API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-9.png" alt="a console log of a javascript array " width="800" height="400"&gt;&lt;/a&gt;Our glorious data!&lt;/p&gt;

&lt;p&gt;As the very last line in the section, we &lt;em&gt;console.log&lt;/em&gt; our data that we get back from the API endpoint just to make sure we're getting everything we wanted.  We have an array full of objects.  You'll also notice that the key &lt;em&gt;published_at&lt;/em&gt; holds our dates and they are not in any type of order.  Their format is also not a simple four digit number representing the year which would make it easy to filter them into &lt;em&gt;&lt;strong&gt;reverse chronological order&lt;/strong&gt;&lt;/em&gt;.  We'll need to take care of that.&lt;/p&gt;

&lt;h2&gt;Manipulating Our Data&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-7.png" alt="javascript code that's copying a variable" width="800" height="400"&gt;&lt;/a&gt;Making a copy of our data variable&lt;/p&gt;

&lt;p&gt;Here we declare the variable &lt;em&gt;dataCopy&lt;/em&gt; which points to the &lt;em&gt;dataJSON &lt;/em&gt;variable mutated into an array via the &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax" rel="noopener noreferrer"&gt;spread operator(...)&lt;/a&gt;&lt;/em&gt;.  Essentially, we are copying our returned JSON data so we aren't manipulating the original (bad practice) while making it into an array so that we can iterate over it.&lt;/p&gt;

&lt;p&gt;After, we &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" rel="noopener noreferrer"&gt;sort&lt;/a&gt;&lt;/em&gt; the array.  Sort is an extremely useful array method that will put our array indices into the order of our choosing based on the function we pass into &lt;em&gt;sort.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;Typically, we might want to sort the data based on value (largest to smallest) so we subtract the parameter &lt;em&gt;&lt;strong&gt;a&lt;/strong&gt;&lt;/em&gt; from parameter &lt;em&gt;&lt;strong&gt;b&lt;/strong&gt;&lt;/em&gt;.  But because we need to display our results in &lt;em&gt;&lt;strong&gt;reverse chronological order&lt;/strong&gt;&lt;/em&gt; I decided to produce a new date (accomplished with the &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new" rel="noopener noreferrer"&gt;new&lt;/a&gt;&lt;/em&gt; operator and the JavaScript built in method &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" rel="noopener noreferrer"&gt;Date&lt;/a&gt;&lt;/em&gt; that creates a new platform independent formatted instance of a date.  Now, because &lt;em&gt;&lt;strong&gt;a &lt;/strong&gt;&lt;/em&gt;and &lt;em&gt;&lt;strong&gt;b&lt;/strong&gt;&lt;/em&gt; represent our objects sitting inside our array indices, we can access the key/value pairs held within said objects.  So, we subtract &lt;em&gt;b.published_at &lt;/em&gt;from &lt;em&gt;a.published_at&lt;/em&gt; and this should give us our dates in &lt;em&gt;&lt;strong&gt;reverse chronological order&lt;/strong&gt;&lt;/em&gt;. &lt;/p&gt;

&lt;h2&gt;Displaying the Fruits of Our Labor&lt;/h2&gt;

&lt;p&gt;Remember that &lt;em&gt;&lt;span&gt;output&lt;/span&gt; &lt;/em&gt;variable we set to &lt;em&gt;null&lt;/em&gt; at the very top of our program?  Well now is it's time to shine!&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-10.png" alt="javascript code showing an output variable being changed" width="800" height="400"&gt;&lt;/a&gt;That output variable is earning it's keep now!&lt;/p&gt;

&lt;p&gt;So, there's a few things going on here.  First, we're setting our &lt;em&gt;&lt;span&gt;output&lt;/span&gt;&lt;/em&gt; variable to a new value by mapping over our &lt;em&gt;&lt;span&gt;dataCopy&lt;/span&gt;&lt;/em&gt; variable using the &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;map&lt;/a&gt;&lt;/em&gt; method.  This method returns a new array with the results of calling the provided function once for each index.  The &lt;em&gt;item&lt;/em&gt; parameter represents our objects inside of our array that was returned from the endpoint and thus has access to all of their properties such as &lt;em&gt;title &lt;/em&gt;and &lt;em&gt;published_at&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We return two list elements with a &lt;em&gt;&amp;lt;span&amp;gt;&lt;/em&gt; inside each one (for styling purposes), as well as a string for the &lt;strong&gt;Title &lt;/strong&gt;and &lt;strong&gt;Date Published&lt;/strong&gt; headings.  Inside of those, we have our variables that use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" rel="noopener noreferrer"&gt;template literals&lt;/a&gt; to set the title and the date for each post.&lt;/p&gt;

&lt;p&gt;Then, we set our &lt;em&gt;&lt;span&gt;list&lt;/span&gt;&lt;/em&gt; variable's &lt;em&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML" rel="noopener noreferrer"&gt;innerHTML&lt;/a&gt;&lt;/em&gt; equal to that of our &lt;em&gt;&lt;span&gt;output&lt;/span&gt;&lt;/em&gt; variable.  &lt;/p&gt;

&lt;p&gt;Finally, we have the closing bracket and error handling of our &lt;em&gt;try...catch&lt;/em&gt; block as well as our function call:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-11.png" alt="javascript code showing error handling for a fetch request" width="800" height="400"&gt;&lt;/a&gt;This code will handle any errors and display them in the console&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;Final Code &lt;/h2&gt;

&lt;p&gt;Here is what our full code body looks like now: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-13.png" alt="javascript code " width="800" height="400"&gt;&lt;/a&gt;The entirety of our code base&lt;/p&gt;

&lt;p&gt;And here is our basic CSS styling: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-14.png" alt="css code showing basic styling of an element" width="800" height="400"&gt;&lt;/a&gt;Did I say basic styling?  I meant basic :D&lt;/p&gt;

&lt;p&gt;And here is the result of our work with it's very basic styling:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-15.png" alt="a list of posts in reverse chronological order" width="800" height="400"&gt;&lt;/a&gt;Isn't it beautiful?&lt;/p&gt;

&lt;p&gt;As you can see, we accomplished what we set out to do and in fact the list is in &lt;em&gt;&lt;strong&gt;reverse chronological order&lt;/strong&gt;&lt;/em&gt;. Yay!&lt;/p&gt;








&lt;p&gt;I hope you've enjoyed this walk through of my thought process and of how I solved this challenge.  Granted, there are many ways of completing this so feel free to share yours with me!  I'm excited to keep this series going and will post another after I've gone through another challenge!&lt;/p&gt;

&lt;p&gt;This post was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.  While you're there why not sign up for my monthly &lt;strong&gt;Newsletter&lt;/strong&gt; – I promise I’ll never 
spam your inbox and your information will not be shared with 
anyone/site.  I like to occasionally send out interesting resources I 
find, articles about web development, and a list of my newest posts.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Also, I cross post most of my articles on &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; so you can find my work there as well!&lt;/p&gt;

&lt;p&gt;Have an awesome day filled with love, joy, and coding!&lt;/p&gt;

</description>
      <category>jobhunt</category>
      <category>interview</category>
      <category>challenge</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Improve Your Workflow With These Tips For VS Code</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Thu, 23 May 2019 21:25:37 +0000</pubDate>
      <link>https://dev.to/jsgoose/improve-your-workflow-with-these-tips-for-vs-code-2nd5</link>
      <guid>https://dev.to/jsgoose/improve-your-workflow-with-these-tips-for-vs-code-2nd5</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fdenny-muller-1260091-unsplash-1024x683.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fdenny-muller-1260091-unsplash-1024x683.jpg" alt="" width="800" height="400"&gt;&lt;/a&gt; &lt;br&gt;Photo by &lt;a rel="noreferrer noopener" href="https://unsplash.com/@redaquamedia?utm_source=medium&amp;amp;utm_medium=referral"&gt;Denny Müller&lt;/a&gt; on &lt;a rel="noreferrer noopener" href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When I started the self-taught path of learning to code, one of the first things I needed to do was decide which text editor I was going to use.&lt;/p&gt;

&lt;p&gt;Without getting into too much detail, after some exhaustive testing I went with Microsoft's &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VS Code&lt;/a&gt;.  (Side note -  This isn't a post about my opinions on which text editor is 'the best',  so if that's what you're looking for you've come to the wrong place.   Frankly, the best one is the one that you like and the one that suits  your needs the most.).&lt;/p&gt;

&lt;p&gt;After a few years of using this text editor I've compiled a list of some tips that have really helped me streamline my workflow.  These range from cosmetic to small useful tips but also game changers that will take a little extra work.  &lt;/p&gt;

&lt;p&gt;Let's dig right in - with one small caveat: I work on a Windows machine so all following pertains to that operating system.  My apologies to the Mac users out there as I don't know that platform.&lt;/p&gt;

&lt;p&gt;Alright, now let's dig in!&lt;/p&gt;

&lt;h2&gt;Learn and Use Keyboard Shortcuts&lt;/h2&gt;

&lt;p&gt;This is by far one of the most effective time saving tips I give to anyone with almost all software.  The keyboard shortcuts are put in place to help 'power users' get the most out of their experience with a piece of software.  You'll find shortcuts in games, web applications, desktop application, etc and it's worth your time to learn and use them.&lt;/p&gt;

&lt;p&gt;It is one of the more difficult pieces of advice ti implement as it requires you to rewire your muscle memory.  If you've been using an application for a while you know what it feels like without having to think about it.  Learning to use keyboard shortcuts requires you to think about actions before performing them.  &lt;/p&gt;

&lt;p&gt;I'll be honest, it will feel a little foreign for the first week or so but once you get the hang of it you'll be flying through actions at a much faster pace.&lt;/p&gt;

&lt;p&gt;Some of the actions I use the most in VS Code are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;span&gt;Creating an HTML element with a class/id&lt;/span&gt; --&amp;gt; &lt;em&gt;&lt;strong&gt;div.container + tab&lt;/strong&gt; = &amp;lt;div class = 'container&amp;gt;&amp;lt;/div&amp;gt; or &lt;/em&gt;&lt;strong&gt;div#container + tab &lt;/strong&gt;= &amp;lt;div id = 'container'&amp;gt;&amp;lt;/div&amp;gt;&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + Shift + E&lt;/span&gt; --&amp;gt; Show the File Explorer&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + Shift + G&lt;/span&gt; --&amp;gt; Show Source Control (check out how to integrate Git into VS Code below)&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + B&lt;/span&gt; --&amp;gt; Show/toggle sidebar&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + ` (tilde)&lt;/span&gt; --&amp;gt; Show integrated terminal&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + PageDown&lt;/span&gt; --&amp;gt; Move page down&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + PageUp&lt;/span&gt; --&amp;gt; Move page up &lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + F&lt;/span&gt; --&amp;gt; Search current document&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + P&lt;/span&gt; --&amp;gt; Go to document&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Ctrl + , (comma)&lt;/span&gt; --&amp;gt; Preferences&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few of the shortcuts I use on a daily basis.  For a full list, check out the official PDF version of &lt;a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf" rel="noopener noreferrer"&gt;keyboard shortcuts&lt;/a&gt; from Microsoft.&lt;/p&gt;

&lt;h2&gt;Integrate Source Control &lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fimage-1.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've heard different arguments for both sides on this, but for me integrating source control into VS Code was one of the easiest and most effective changes I've made to my workflow.  Before integration, I was switching between windows about every 3-5 minutes with lost time in between.&lt;/p&gt;

&lt;p&gt;Now, that doesn't seem like a big deal (especially if you have multiple monitors and can leave the command line and VS Code up at the same time) but having it inside of VS Code has proven to be invaluable.  &lt;/p&gt;

&lt;p&gt;No longer do I need to &lt;strong&gt;&lt;em&gt;Alt + Tab&lt;/em&gt;&lt;/strong&gt; to my command line to type a commit message and then commit.  It's as simple as hitting &lt;strong&gt;&lt;em&gt;Ctrl + Shift + G&lt;/em&gt;&lt;/strong&gt;, typing my message, and hitting &lt;strong&gt;&lt;em&gt;Ctrl + Enter&lt;/em&gt;&lt;/strong&gt; and then I'm back to coding.&lt;/p&gt;

&lt;p&gt;Check out the official documentation on &lt;a href="https://code.visualstudio.com/docs/editor/versioncontrol" rel="noopener noreferrer"&gt;integrating source control&lt;/a&gt; into VS Code to get started.  There's also a handy video on &lt;a href="https://code.visualstudio.com/docs/introvideos/versioncontrol" rel="noopener noreferrer"&gt;using source control&lt;/a&gt; (Git specifically) once you've completed the integration.&lt;/p&gt;

&lt;p&gt;To make a long story short - integrating Git into my VS Code made my life easier and my workflow even better!&lt;/p&gt;

&lt;h2&gt;Use the Integrated Terminal&lt;/h2&gt;

&lt;p&gt;Speaking of integration, aside from version control we can also bring our terminal into VS Code.  It has built in support for &lt;a href="https://gitforwindows.org/" rel="noopener noreferrer"&gt;Git Bash&lt;/a&gt; but there are also extensions that allow you to use &lt;a href="https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode?view=powershell-6" rel="noopener noreferrer"&gt;PowerShell&lt;/a&gt; also.  &lt;/p&gt;

&lt;p&gt;Not only is it nice to have the terminal inside the same space where your code is, it allows you to have multiple terminal tabs as well.  I frequently have two or three terminal tabs open especially if I'm running a bunch of &lt;a href="https://gulpjs.com/" rel="noopener noreferrer"&gt;Gulp&lt;/a&gt; tasks that need to stay active but also I need to drop in some Git commands. &lt;em&gt;Side note - if you find yourself using multiple terminals consistently you can actually set up keybindings that allow you to switch between the tabs with keyboard shortcuts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Of course if you'd prefer to work with the external terminal that can easily be accomplished with the keyboard shortcut &lt;strong&gt;&lt;em&gt;Ctrl+Shift+C&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; (this is just another example where learning/using those keyboard shortcuts comes into play :D)&lt;/em&gt;.  Using this command opens your command line to the same directory that your integrated terminal was at.&lt;/p&gt;

&lt;p&gt;The last juicy bit that drew me into using the integrated terminal is the fact that you can split your terminal section into as many tabs as your screen size will allow. &lt;/p&gt;

&lt;p&gt;Below you can see I've split my terminal into 5 tabs and then an error pops up when I have no more room. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fterminal-split.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F05%2Fterminal-split.png" alt="" width="800" height="400"&gt;&lt;/a&gt;Splitting the integrated terminal into multiple tabs, each with it's own instance&lt;/p&gt;

&lt;h2&gt;Make Use of Extensions&lt;/h2&gt;

&lt;p&gt;VS Code has a vibrant and lively &lt;a href="https://marketplace.visualstudio.com/VSCode" rel="noopener noreferrer"&gt;extension community&lt;/a&gt; around it.  If you can think of a feature you'd like, chances are there's an extension for it or it's coming in a future build.  &lt;/p&gt;

&lt;p&gt;Extensions add extra functionality as well as some customization options that don't come with VS Code 'out of the box'.  This functionality ranges from code snippets or making your life as a developer easier with tools like linting.&lt;/p&gt;

&lt;p&gt;Many of these extensions make me more productive by adding features like giving me HTML boilerplate simply by typing &lt;strong&gt;html+tab&lt;/strong&gt; or by allowing me to highlight my comments with different flags/colors to draw attention to them.&lt;/p&gt;

&lt;p&gt;One of my favorite, and most used, extensions is &lt;a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt;.  It allows me to format my code in an easy-to-read format by fixing my indention or adding semi colons at the end of my JavaScript.  (It's important to note that I'm taking a 'syntax side' here and saying this is what I prefer.  If you prefer another way that's wonderful and it's not wrong - but for me this is the style that works the best.)&lt;/p&gt;

&lt;p&gt;Also, if you'd like to lose a few hours of your time just check out the &lt;a href="https://marketplace.visualstudio.com/search?target=VSCode&amp;amp;category=Themes&amp;amp;sortBy=Downloads" rel="noopener noreferrer"&gt;themes&lt;/a&gt; that are available for VS Code.  There are themes for the editor as well as file icon themes.  If you're like me then you'll install as many as you can and constantly switch between them :D&lt;/p&gt;








&lt;p&gt;I hope you've enjoyed this romp through the various aspects of increasing your productivity with VS Code.  If you have your own tips/tricks that I didn't cover I'd love if you shared them with me.&lt;/p&gt;

&lt;p&gt;This article was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.  While you’re there why not sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;?  I promise I’ll never spam your inbox and your information will not be shared with anyone/site.  I like to occasionally send out interesting resources I find, articles about web development, and a list of my newest posts.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;I also post articles on &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; so you can find my work there as well!&lt;/p&gt;

&lt;p&gt;Have an awesome day filled with love, joy, and coding!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>workflow</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>Key Takeaways From My First Technical Interview</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Thu, 04 Apr 2019 01:02:39 +0000</pubDate>
      <link>https://dev.to/jsgoose/key-takeaways-from-my-first-technical-interview-3ka0</link>
      <guid>https://dev.to/jsgoose/key-takeaways-from-my-first-technical-interview-3ka0</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2018%2F12%2Fkelly-sikkema-411622-unsplash-1024x678.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2018%2F12%2Fkelly-sikkema-411622-unsplash-1024x678.jpg" alt="" width="800" height="400"&gt;&lt;/a&gt;Image courtesy of Kelly Sikkema on &lt;a href="https://unsplash.com" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Some History&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;I have been teaching myself front-end web development for a little more than two years now.  It has been a wild and crazy ride but also a fun and challenging one. I, like many other self-taught coders, have had my ups and downs with this journey but ultimately it has been a rewarding one thus far.&lt;/p&gt;

&lt;p&gt;I started with resources like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org" rel="noopener noreferrer"&gt;freeCodeCamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.udemy.com" rel="noopener noreferrer"&gt;Udemy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.udacity.com" rel="noopener noreferrer"&gt;Udacity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.stackoverflow.com" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Books&lt;/li&gt;
&lt;li&gt;Podcasts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The list could go on and on but you get the point.  After completing my &lt;a href="https://medium.com/@joncsexton/my-udacity-journey-67af81f09863" rel="noopener noreferrer"&gt;Nanodegree&lt;/a&gt; through Udacity and a Responsive Web Design certificate from &lt;a href="https://www.freecodecamp.org" rel="noopener noreferrer"&gt;freeCodeCamp&lt;/a&gt; I have found a new confidence that I hadn’t felt before.&lt;/p&gt;

&lt;p&gt;I want to continue that journey and decided it would be a logical step to start applying for jobs in this field.  So that’s what I did and little did I know that people would be interested in me and my skills.&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;The Interview&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;I applied for a front-end web developer position through the Stack Overflow jobs section and thought if nothing else it’ll be great practice.&lt;/p&gt;

&lt;p&gt;Honestly, I didn’t expect to get a call and after I applied I nearly forgot about it.  Lo and behold a few days later I got an email asking me to take a &lt;a href="https://www.hackerrank.com/" rel="noopener noreferrer"&gt;HackerRank test&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was floored at the thought of someone wanting to interview me for a position in a field I don’t hold a degree in.  It was a huge validation of my skills and, if I’m being honest, was a giant ego boost.&lt;/p&gt;

&lt;p&gt;I was extremely nervous and I had heard previously that even the smallest task can stump you even if you have completed it a thousand times before.  I thought it was exaggeration at best but it turned out to be true.&lt;/p&gt;

&lt;p&gt;I was asked to complete a simple function that took in an array, copied the contents, and returned the new array….my brain blanked -- it was as if I had never coded in my life.  I eventually got the correct answer but it was a grueling process.&lt;/p&gt;

&lt;p&gt;For reference, here is the code I ended up writing for the challenge:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;let array1 = [1,2,3,4,5];

function duplicate(arr) {
    let arr2 = [...arr];
    return arr.concat(arr2);
}

duplicate(array1);&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Here are some takeaways and feelings from my first interview for a tech position.  Obviously, have your resume in order before applying to jobs...that's honestly step one but beyond this post.  Maybe in the future I'll write a post with some suggestions about how to prepare your resume.&lt;/p&gt;

&lt;p&gt;  Hopefully these will help you when your interview comes around :D&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Takeaways&lt;/b&gt;&lt;/h2&gt;

&lt;h3&gt;Be punctual!&lt;/h3&gt;

&lt;p&gt;I’ve always been of the mindset that if you arrive early then you’re on time and if you’re on time then you’re late.  If you’re interview is at 1 P.M. then you should arrive no later than 12:45 P.M.  This mindset has worked well for me through the years and I know it will help you.&lt;/p&gt;

&lt;p&gt;At best it’s rude and at worst it signals to your interviewer that you don’t respect their time with the added assumption that if you were to be hired you’ll be late on deadlines.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Never be late for an interview!&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;I arrived 20 minutes early for my interview today and had a few precious moments to gather myself in the car before heading in.  I was thankful that I had time to “center” myself and calm my stress levels a bit.&lt;/p&gt;

&lt;h3&gt;Prepare prepare prepare&lt;/h3&gt;

&lt;p&gt;This is a broad strokes piece of advice in that it can mean anything from searching through &lt;a href="https://www.linkedin.com" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; for information on the company to reaching out to current employees for an informational interview.&lt;/p&gt;

&lt;p&gt;At the very least read through the company’s website to gather some basic knowledge.&lt;/p&gt;

&lt;p&gt;You should know some facts about the company you are applying to.  It signals to the interviewer that you care about the company and the position you’re applying for.&lt;/p&gt;

&lt;p&gt;I had very little time to prepare for this interview (the turnaround was 2 days between applying and interviewing) but I still read through their entire website, a few articles from a local magazine that featured the company, and read through employee profiles on LinkedIn.&lt;/p&gt;

&lt;p&gt;Also, there are literally hundreds if not thousands of websites that will help you prepare for a technical interview with practice questions.  I read through a few and felt much better about some of my knowledge.&lt;/p&gt;

&lt;p&gt;Of course, you may know some info and just forget it or draw a blank in the interview - it happens.  It happened to me today. I was honest and open about it and felt like the interviewer could relate because he dropped a few hints to guide me to the right path after my stumbles.&lt;/p&gt;

&lt;p&gt;Going into my interview today I would have liked to have some more information about the company but I felt confident enough in what I knew to answer some topical questions if I were to be asked.  I don’t think I’ll ever feel fully prepared but something is better than nothing.&lt;/p&gt;

&lt;h3&gt;Ask Questions&lt;/h3&gt;

&lt;p&gt;The importance of asking questions during the interview was stressed to me over and over again by several colleagues who have coding experiences/positions.  I was reminded, more times than I care to count, that asking the interviewer questions could make or break my chances of getting an offer.&lt;/p&gt;

&lt;p&gt;It’s not only helpful in the sense of getting an idea of what the job is like but it signals to the interviewer that you’re interested in the position.&lt;/p&gt;

&lt;p&gt;Here are a few questions I asked during my interview:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why do you like to work here?&lt;/li&gt;
&lt;li&gt;What’s a typical day of work look like here?&lt;/li&gt;
&lt;li&gt;What stack do you currently work in?&lt;/li&gt;
&lt;li&gt;What operating system do you use for work machines?&lt;/li&gt;
&lt;li&gt;How flexible are the hours?&lt;/li&gt;
&lt;li&gt;What’s something you would change about working here?&lt;/li&gt;
&lt;li&gt;What’s the growth/promotion path look like here?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This isn’t the entire list but I think you get the point.  Show interest in the job you are applying for and gather some helpful/useful information at the same time.  Again, if possible &lt;em&gt;avoid talking about salary&lt;/em&gt;. Unless otherwise stated, you should view this as an informational interview.&lt;/p&gt;

&lt;h3&gt;Practice Writing Code by Hand&lt;/h3&gt;

&lt;p&gt;I know it sounds like an odd piece of advice but this was the part of the interview that really “threw me for a loop”.&lt;/p&gt;

&lt;p&gt;I’ve written tens of thousands of lines of code in my text editor.  I’ve learned some snazzy keyboard shortcuts and feel like I’ve gotten far more productive with my setup than I used to be.&lt;/p&gt;

&lt;p&gt;None of this prepared me for handwriting code on a whiteboard.&lt;/p&gt;

&lt;p&gt;It was a very strange feeling thinking about closing my brackets and writing a semicolon.  My editor typically handles these actions for me.&lt;/p&gt;

&lt;p&gt;I found myself thinking more about writing the correct syntax and closing my brackets than thinking about the solution I was being asked to implement.&lt;/p&gt;

&lt;p&gt;Grab yourself a small whiteboard from any general store or a big box store along with some dry erase markers.  Practice writing out your code along with some sample questions from any of the interview prep websites I referred to earlier.&lt;/p&gt;

&lt;p&gt;I feel like this is one part of the interview I would go back and change if I could.  I will definitely be practicing physically writing my code before my next interview and I hope you do as well!&lt;/p&gt;

&lt;h3&gt;Have Confidence&lt;/h3&gt;

&lt;p&gt;This one is extremely tough for me and I am certain that other developers can relate.  I did not start out in the technology sector  when I entered the workforce.&lt;/p&gt;

&lt;p&gt;I've always had an interest in technology but it never steered my professional career (unfortunately) until now.  Add to that being a self taught developer and there you have a potent platform for doubt and fear to creep in.&lt;/p&gt;

&lt;p&gt;Knowing what I have built and accomplished is one thing but letting those actions influence my confidence is another.  This is something I work on daily.&lt;/p&gt;

&lt;p&gt;If you learn anything from my posts, learn to have confidence in yourself.  &lt;strong&gt;We can do this.&lt;/strong&gt;  We can teach ourselves to code, build awesome projects, and get hired with a company and get paid for our skills.&lt;/p&gt;

&lt;p&gt;Anytime you walk into an interview be confident.  I know that nerves and emotions run rampant during the interview process when your brain blanks (like mine did) but fight through it and crush that interview.  Keep that confidence no matter the challenge.  But also remember that life is about balance -- stay confident not cocky.&lt;/p&gt;

&lt;h3&gt;Don’t Get Discouraged&lt;/h3&gt;

&lt;p&gt;This is also something that every developer no matter the language you code in, the discipline you follow, or how long you've been at it can relate to.&lt;/p&gt;

&lt;p&gt;Some days I get out of bed before my alarm goes off, grab a coffee, and knock out projects all day.  There was a day in November where I was &lt;a href="https://twitter.com/jj_goose/status/1064853895032250368" rel="noopener noreferrer"&gt;getting so much work done&lt;/a&gt; that I didn't want the day to end.&lt;/p&gt;

&lt;p&gt;There are also days where getting out of the bed feels like an insurmountable task in itself.&lt;/p&gt;

&lt;p&gt;But through it all I have always kept my love for coding.  I've managed to stay motivated enough to get some great things accomplished.  It hasn't been easy and there are times where I'll work for an hour and then relax the rest of the day.&lt;/p&gt;

&lt;p&gt;There are times where my PlayStation4 gets much more of my attention than it should but that's how I decompress and have some down time so that when I come back to what I'm working on I'm ready to completely annihilate it.&lt;/p&gt;

&lt;p&gt;Find your motivation - whether that's a new job, providing for your family, earning more money or just loving your craft.  Find your motivation and hold on to it tightly!&lt;/p&gt;








&lt;p&gt;I hope this article has been helpful for you and provided some tips for you when you're next interview rolls around.&lt;/p&gt;

&lt;p&gt;Drop a comment or shout at me on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; — I’m always happy to connect with friendly faces and fellow developers!  All of my social medias are to the right of this article, just under the "&lt;em&gt;Recent Posts&lt;/em&gt;" section.&lt;/p&gt;

&lt;p&gt;I also cross post some articles on &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; so make sure to follow me there as well!&lt;/p&gt;

&lt;p&gt;This post was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.  I'd love for you to come poke around there and see some of my other works.&lt;/p&gt;

&lt;p&gt;While you're there don't forget to sign up for my newsletter at the top right corner of the page.  I send out monthly e-mails with great articles curated from across the web along with some of my own articles.  I promise not to waste your time or spam your inbox and you can unsubscribe anytime.&lt;/p&gt;

&lt;p&gt;As always, have a fantastic day full of coding, love, family, and happiness!&lt;/p&gt;

&lt;p&gt;&lt;a href="" class="article-body-image-wrapper"&gt;&lt;img alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>techjobs</category>
      <category>jobsearch</category>
      <category>jobhunt</category>
      <category>interview</category>
    </item>
    <item>
      <title>Adding Dark Mode to My Website</title>
      <dc:creator>Jonathan Sexton</dc:creator>
      <pubDate>Sat, 16 Mar 2019 23:24:18 +0000</pubDate>
      <link>https://dev.to/jsgoose/adding-dark-mode-to-my-website-20be</link>
      <guid>https://dev.to/jsgoose/adding-dark-mode-to-my-website-20be</guid>
      <description>&lt;p&gt;Last year I made it a point to redesign my website from scratch.  I wanted something simple and minimalist looking that clearly stated what this was - a portfolio website.&lt;/p&gt;

&lt;p&gt;After I rebuilt my website from the ground up it seemed like everywhere I turned there was another article about adding a dark mode to your website.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;At first I didn't think it would make that big of a difference because, while I am partial to darker colors, I felt like my website was a good balance between bright, fun colors and darker fonts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-light-1024x588.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-light-1024x588.png" alt="the home screen of jonathan sexton . me" width="800" height="400"&gt;&lt;/a&gt;My website before adding the light / dark mode toggle option&lt;/p&gt;

&lt;p&gt;I read some of the articles I mentioned earlier and the more I thought about it the more I decided to go for it. &lt;/p&gt;

&lt;p&gt;I took some inspiration from Flavio Copes who wrote a &lt;a href="https://flaviocopes.com/dark-mode/" rel="noopener noreferrer"&gt;terrific article&lt;/a&gt; on this very subject.  Unlike what Flavio decided to do with his site, I didn't add the user's choice to local storage.  &lt;/p&gt;

&lt;p&gt;This is due, in part, to the differences between our sites.  I have a static site and there are no redirects/separate pages aside from the blog which is on a different platform so users generally won't be refreshing the page.  It is a cool option and one that I may add in later on.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark1-1024x588.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark1-1024x588.png" alt="jonathan sexton . me with dark mode endabled" width="800" height="400"&gt;&lt;/a&gt;Dark mode enabled on my website&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark2-1024x648.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark2-1024x648.png" alt="jonathan sexton . me with dark mode enabled" width="800" height="400"&gt;&lt;/a&gt;Dark mode enabled - 2&lt;/p&gt;

&lt;h2&gt;The Code&lt;/h2&gt;

&lt;p&gt;The code to achieve this was fairly simple.  I took the same approach as Flavio did and added the style changes through CSS.  I had to take a few more steps because I have an image on my landing page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark-code-1024x300.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark-code-1024x300.png" alt="css code showing a class called dark" width="800" height="400"&gt;&lt;/a&gt;The class I applied to the website to make it dark mode&lt;/p&gt;

&lt;p&gt;I had to use the &lt;strong&gt;!important&lt;/strong&gt; flag on some of the rules because they were not being applied properly.  This was the easiest approach to implement and I know it's not advised to use this flag so I'll be looking for an alternative in the near future.&lt;/p&gt;

&lt;p&gt;Here is the JavaScript I used to get my toggle switch working correctly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark-code2-1024x373.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjonathansexton.me%2Fblog%2Fwp-content%2Fuploads%2F2019%2F03%2Fwebsite-dark-code2-1024x373.png" alt="lines of javascript code " width="800" height="400"&gt;&lt;/a&gt;The JavaScript for adding functionality to my toggle swtich&lt;/p&gt;

&lt;p&gt;I start by selecting my &lt;code&gt;div&lt;/code&gt; with an id of &lt;code&gt;light-dark-mode-container&lt;/code&gt; and adding an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener" rel="noopener noreferrer"&gt;event listener&lt;/a&gt; to it.&lt;/p&gt;

&lt;p&gt;Next, I set my variables of &lt;code&gt;everything&lt;/code&gt;, which selects all content on the page, and &lt;code&gt;projectTiles&lt;/code&gt; because this class belongs to a particular set of overlays I do not want to have a background of a solid color.&lt;/p&gt;

&lt;p&gt;Next, since I'm using &lt;code&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll" rel="noopener noreferrer"&gt;querySelectorAll&lt;/a&gt;&lt;/code&gt; which returns a static &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/NodeList" rel="noopener noreferrer"&gt;NodeList&lt;/a&gt;, I loop over all of the elements within both NodeLists and either toggle the class &lt;code&gt;dark&lt;/code&gt; or completely remove it from the elements returned by the variable &lt;code&gt;projectTiles&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What I'm left with is a container at the top of my website with a toggle switch that allows the user to toggle between light and dark mode.&lt;/p&gt;








&lt;p&gt;I hope you enjoyed this post and maybe you learned something too!  If you decide to implement this on your own website or your next project please share it with me (leave me a comment or shout at me on &lt;a href="https://twitter.com/jj_goose" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;).  I'm always happy to see the work that others create.&lt;/p&gt;

&lt;p&gt;This post was originally posted on my &lt;a href="https://jonathansexton.me/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; where I write articles related to front end web development.  I also cross post my articles on &lt;a href="https://medium.com/@joncsexton" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;, so you can find my work on that platform as well!&lt;br&gt;&lt;/p&gt;

&lt;p&gt;While you're there why not sign up for my &lt;strong&gt;Newsletter&lt;/strong&gt;?  I promise I'll never spam your inbox and your information will not be shared with anyone else.  &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Have an awesome day filled with love, joy, and coding!&lt;/p&gt;

</description>
      <category>darkmode</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
