<?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: April Craig</title>
    <description>The latest articles on DEV Community by April Craig (@april_craig).</description>
    <link>https://dev.to/april_craig</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%2F279914%2F3f3cbd04-f942-44f8-9691-0a2e3f5c3b34.jpeg</url>
      <title>DEV Community: April Craig</title>
      <link>https://dev.to/april_craig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/april_craig"/>
    <language>en</language>
    <item>
      <title>Conditional Ternary Operators for Beginners</title>
      <dc:creator>April Craig</dc:creator>
      <pubDate>Sat, 18 Apr 2020 19:29:30 +0000</pubDate>
      <link>https://dev.to/april_craig/conditional-ternary-operators-for-beginners-1lke</link>
      <guid>https://dev.to/april_craig/conditional-ternary-operators-for-beginners-1lke</guid>
      <description>&lt;p&gt;I’ve been hard at work exploring React.  I’ve been following a React tutorial on &lt;a href="https://youtu.be/DLX62G4lc44"&gt;FCC’s Youtube channel&lt;/a&gt;.  While following along with the tutorial, the instructor used conditional ternary operators and that’s when I realized I have never really used them.  I’ve seen the conditional ternary operator in use on several tutorials, but I’ve never really used them in my own code.  So far I’ve learned the following.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator"&gt;MDN&lt;/a&gt; the Conditional Ternary Operator is a shortcut of an if statement and should be written using this syntax:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Condition? If true do this : If false do that&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here are some examples to clarify...&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You are old enough&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;you are too young&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;getAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//output: "You are old enough"&lt;/span&gt;

&lt;span class="nx"&gt;getAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//output: "you are too young"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The function &lt;strong&gt;getAge&lt;/strong&gt; has a parameter of &lt;em&gt;age&lt;/em&gt;.  If the &lt;em&gt;age&lt;/em&gt; is equal to or less than 18, the string 'You are old enough' is returned. If the &lt;em&gt;age&lt;/em&gt; is under 18, the string 'you are too young' is returned. &lt;/p&gt;

&lt;h3&gt;
  
  
  Example 2
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;isHungry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ateDinner&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ateDinner&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Eat dinner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Drink some water&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;isHungry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//output: "Eat dinner"&lt;/span&gt;

&lt;span class="nx"&gt;isHungry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//output: "Drink some water"&lt;/span&gt;

&lt;span class="nx"&gt;isHungry&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;//output: "Drink some water"  null and undefined are considered falsy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The function &lt;strong&gt;isHungry&lt;/strong&gt; has a parameter called &lt;em&gt;ateDinner&lt;/em&gt;.  When using &lt;em&gt;ateDinner&lt;/em&gt; as a condition, if it is truthy ‘Eat Dinner’ will be returned.  If &lt;em&gt;ateDinner&lt;/em&gt; is falsy, ‘Drink some water’ will be returned instead. Take note of the last line.  If the &lt;strong&gt;isHungry&lt;/strong&gt; function is called without an argument it is falsy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 3
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;carPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;account&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You can buy the car&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This car is too expensive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;carPrice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//output: 'You can buy the car'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, I am using the variable &lt;em&gt;account&lt;/em&gt; as the condition for my conditional ternary operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep working...Keep striving...Keep coding!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Programming Guilt During COVID-19</title>
      <dc:creator>April Craig</dc:creator>
      <pubDate>Mon, 13 Apr 2020 22:53:36 +0000</pubDate>
      <link>https://dev.to/april_craig/programming-guilt-during-covid-19-2mhd</link>
      <guid>https://dev.to/april_craig/programming-guilt-during-covid-19-2mhd</guid>
      <description>&lt;p&gt;Across the country and around the world, people are stuck at home due to the COVID-19 pandemic.  Many people are spending their time working from home, helping their kids navigate online learning and or watching their thousandth hour of Netflix.  No matter what part of the world you live in, I’m sure you feel the anxiety that I am feeling while living through this pandemic.&lt;/p&gt;

&lt;p&gt;Amid the rising number of Coronavirus cases there is this pressure to keep grinding away at code in hopes of becoming a programming superstar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code faster! Learn more! Be better!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This has been the general messaging that I’ve seen across the internet, particularly on social media.  During these past few weeks I’ve felt like if I haven’t learned how to speak 3 languages, become a master chef and cure cancer all while creating a new full-stack application everyday, then I am not good enough. That I've been wasting my time.&lt;/p&gt;

&lt;p&gt;If this sounds familiar to you then &lt;strong&gt;STOP!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are unprecedented times.  We are literally living through a pandemic.  We are being told to stay at home with no end date in sight.  Going outside is scary.  Breathing outside is horrifying.&lt;/p&gt;

&lt;p&gt;As for myself, there are days that I am able to concentrate and I am able to study as much as I want.  On other days, I barely open my computer for an hour.&lt;/p&gt;

&lt;p&gt;It seems the world of tech changes every 5 minutes and if you can use this time to study and build projects, then more power to you.  &lt;/p&gt;

&lt;p&gt;But for those of us who are struggling to study due to living with the anxiety brought by the COVID-19 pandemic, I want you to know that you’re not alone.  Whether you are a computer science student who is struggling with attending classes online, a working developer, or a self taught developer like myself, it is ok to not be ok right now.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is ok to feel anxious.&lt;br&gt;
It is ok to be unproductive.&lt;br&gt;
It is ok that you aren’t motivated to finish your latest project.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s ok.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdeveloper</category>
      <category>softwaredeveloper</category>
      <category>career</category>
    </item>
  </channel>
</rss>
