<?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: Matt Ericsson</title>
    <description>The latest articles on DEV Community by Matt Ericsson (@mjericsson).</description>
    <link>https://dev.to/mjericsson</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%2F132284%2F47588206-b9d9-49c7-ad0e-eefa55c01f55.jpg</url>
      <title>DEV Community: Matt Ericsson</title>
      <link>https://dev.to/mjericsson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mjericsson"/>
    <language>en</language>
    <item>
      <title>Looking for JavaScript/jQuery Resources to Write Cleaner, Concise Code (Code Examples Provided)</title>
      <dc:creator>Matt Ericsson</dc:creator>
      <pubDate>Mon, 25 Mar 2019 15:35:24 +0000</pubDate>
      <link>https://dev.to/mjericsson/looking-for-javascriptjquery-resources-to-write-cleaner-concise-code-code-examples-provided-kna</link>
      <guid>https://dev.to/mjericsson/looking-for-javascriptjquery-resources-to-write-cleaner-concise-code-code-examples-provided-kna</guid>
      <description>&lt;p&gt;As an individual in a more frontend design-driven role with the need to sometimes create custom JavaScript, I find myself always wanting to write cleaner and more concise code.&lt;/p&gt;

&lt;p&gt;To preface, I'm not looking for you to debug the code below, but to provide your insight. What are some good resources to reference when you were looking for the best approach to writing simpler code?&lt;/p&gt;




&lt;p&gt;I was working on a project recently that involved writing some custom functions for a step-by-step form (first two steps included in this post). This will evolve into steps 3 and 4, but they are on the back burner for now.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select a membership level based on the amount you're willing to give over the course of the year. This will provide membership details based on the level you chose before continuing to step 2.
&lt;ul&gt;
&lt;li&gt;The membership values will change by 50% if you're a recent grad.&lt;/li&gt;
&lt;li&gt;You can't be a current student and a recent grad, so the current student option will be disabled if recent grad is checked.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Give a few minor details like first and last name as well as your email. The form will submit what the user also chose in step 1 and then redirect the user to another site where they can then follow steps 3 and 4.&lt;/li&gt;
&lt;li&gt;Create your membership account.&lt;/li&gt;
&lt;li&gt;Register your account by providing additional details.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;b&gt;How I set this up had &lt;u&gt;four main functions&lt;/u&gt; with room for smaller tasks:&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;i&gt;changeAmount();&lt;/i&gt;
&lt;ul&gt;
&lt;li&gt;Main top-level function that would change the membership values based on whether or not 50% off was checked along with various underlying conditional functions.&lt;/li&gt;
&lt;/ul&gt;




&lt;/li&gt;

&lt;li&gt;
&lt;i&gt;changeDiv();&lt;/i&gt;

&lt;ul&gt;
&lt;li&gt;If a membership level is checked, then its respective membership listed benefits will show and all others will be hidden.&lt;/li&gt;
&lt;/ul&gt;




&lt;/li&gt;

&lt;li&gt;
&lt;i&gt;showLevel();&lt;/i&gt;

&lt;ul&gt;
&lt;li&gt;If a membership level is selected, then the values based on whether or not they are 50% off will populate within step 2.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;i&gt;revealSteps();&lt;/i&gt;

&lt;ul&gt;
&lt;li&gt;Show steps individually (1-4). This basically hides all other views based on the step you're currently on.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Given the nature of jQuery, it just seemed like a lot and the code was repetitive. &lt;b&gt;I feel like the cleaner approach would be to try and cut down on repetition by keeping it as generic as possible.&lt;/b&gt; I've included a short walkthrough below so you can gain a better understanding. Apologies in advance for it not being highlighted in correct syntax!&lt;/p&gt;




&lt;p&gt;If Recent UNC Grad (50% Any Level) IS checked, then all membership annual and monthly values will change by 50%.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if($('input[name=halfoff]').is(':checked')) {
    $("#recentUNCGradLevel2 label").removeClass('bg-white').addClass('bg-secondary  text-white');

    var radioTarHeelAnnualValue = (100 / 2);
    var radioTarHeelMonthlyValue = (8.34 / 2);
    $("#tarHeelLevel3").html("&amp;lt;span class='membership-name'&amp;gt;Tar Heel&amp;lt;/span&amp;gt;" + "\n" + "&amp;lt;span class='d-block'&amp;gt;$" + radioTarHeelAnnualValue + " Annually&amp;lt;/span&amp;gt;" + "\n" + "&amp;lt;span class='d-block'&amp;gt;$" + radioTarHeelMonthlyValue + "/month&amp;lt;/span&amp;gt;");
    $(".display-annual-amount.tarHeelAnnualAmount").html('$' + radioTarHeelAnnualValue);

    $("#currentUNCStudentLevel2").html("&amp;lt;label id='currentUNCStudentLevel4' class='btn btn-primary  rounded  disabled'&amp;gt;&amp;lt;input id='currentUNCStudentLevel' type='radio' name='what' value='Current UNC Student' data-divid='B' disabled&amp;gt;Current UNC Student" + "\n" + "&amp;lt;span class='d-block'&amp;gt;$25/Annually&amp;lt;/span&amp;gt;" + "\n" + "&amp;lt;span class='d-block'&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;/label&amp;gt;");

    var radioRamAnnualValue = (200 / 2);
    var numRamMonthlyValue = Number(16.67 / 2);
    var roundedRamMonthlyString = numRamMonthlyValue.toFixed(2);
    var roundedRamMonthlyValue = Number(roundedRamMonthlyString);
    $("#ramLevel3").html("&amp;lt;span class='membership-name'&amp;gt;Ram&amp;lt;/span&amp;gt;" + "\n" + "&amp;lt;span class='d-block'&amp;gt;$" + radioRamAnnualValue + " Annually&amp;lt;/span&amp;gt;" + "\n" + "&amp;lt;span class='d-block'&amp;gt;$" + roundedRamMonthlyValue + "/month&amp;lt;/span&amp;gt;");
    $(".display-annual-amount.ramAnnualAmount").html('$' + radioRamAnnualValue);

    ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If a membership level is selected, then the values based on whether or not they are 50% off will populate within Step 2.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;showLevel: function() {
    $(document).ready(function(){
        $("input[type=radio]").change(function(){
            if($("input[type=radio][name=what][value='Tar Heel']").is(':checked')) {
                $(".display-level.tarHeel").addClass('d-inline-block');
            } else {
                $(".display-level.tarHeel").removeClass('d-inline-block').addClass('d-none');
            }

            if($("input[type=radio][name=what][value='Current UNC Student']").is(':checked')) {
                $(".display-level.currentUNCStudent").removeClass('d-none').addClass('d-inline-block');
            } else {
                $(".display-level.currentUNCStudent").removeClass('d-inline-block').addClass('d-none');
            }

            ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Based on which membership level is selected when Recent UNC Grad (50% Any Level) IS CLICKED, this will make sure that the membership level and annual amount are displayed within Step 2.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$(document).ready(function(){
    $("input[type=radio]").change(function(){
        if($("input[type=radio][name=what][value='Tar Heel']").is(':checked')) {
            $(".display-level.tarHeel").addClass('d-inline-block');
        } else {
            $(".display-level.tarHeel").removeClass('d-inline-block').addClass('d-none');
        }

        if($("input[type=radio][name=what][value='Current UNC Student']").is(':checked')) {
            $(".display-level.currentUNCStudent").removeClass('d-none').addClass('d-inline-block');
        } else {
            $(".display-level.currentUNCStudent").removeClass('d-inline-block').addClass('d-none');
        }

        ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see from all of the code above, this is &lt;b&gt;a lot&lt;/b&gt; if you have 10 options to choose from; this would be daunting if you had way more. Maybe for this case my approach was ok, but I'd just like to go about refining my code moving forward.&lt;/p&gt;

&lt;p&gt;Thanks and greatly appreciated!&lt;/p&gt;

</description>
      <category>help</category>
      <category>javascript</category>
      <category>jquery</category>
    </item>
    <item>
      <title>Finding Freelance Web Design/Development Work</title>
      <dc:creator>Matt Ericsson</dc:creator>
      <pubDate>Sun, 24 Mar 2019 19:11:27 +0000</pubDate>
      <link>https://dev.to/mjericsson/finding-freelance-web-designdevelopment-work-4l0</link>
      <guid>https://dev.to/mjericsson/finding-freelance-web-designdevelopment-work-4l0</guid>
      <description>&lt;p&gt;Over the past couple of years, I've had a handful of opportunities to take on work outside of my day-to-day job. In my case, it's been inconsistent as I'd like to do more. I've tried reaching out to local businesses that could use a website redesign and have asked questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What do you like about your current site?&lt;/li&gt;
&lt;li&gt;What would you do differently with your current site?&lt;/li&gt;
&lt;li&gt;How is your relationship with your current developer?&lt;/li&gt;
&lt;li&gt;How are you handling changes?&lt;/li&gt;
&lt;li&gt;Would you like to make more changes yourself or send them directly to the developer?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many times, the business hasn't responded and I feel like the best approach isn't asking them directly in person since the individual isn't likely present or isn't even a part of on-site operations.&lt;/p&gt;

&lt;p&gt;What's some verbiage you've used that you've found to be successful? Are there any tips you can share in your approach to garnering work? I've got work to show for, but feel it hasn't helped progress the freelancer aspect.&lt;/p&gt;

&lt;p&gt;I'm not sure if this is the place for this, but If you're looking to collaborate or have a position on your team, I'd be stoked to learn more. Check out some of my work on my portfolio website linked below.&lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts and recommendations moving forward.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>freelance</category>
      <category>freelancer</category>
      <category>help</category>
    </item>
  </channel>
</rss>
