<?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: Karin</title>
    <description>The latest articles on DEV Community by Karin (@karin1986).</description>
    <link>https://dev.to/karin1986</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%2F368844%2Fef7cc2e5-4cc4-4db1-a7d9-51d0c92683a7.jpg</url>
      <title>DEV Community: Karin</title>
      <link>https://dev.to/karin1986</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karin1986"/>
    <language>en</language>
    <item>
      <title>Step-by-Step Guide to installing Terraform on Windows on a subsystem Linux/Ubuntu server</title>
      <dc:creator>Karin</dc:creator>
      <pubDate>Thu, 26 Dec 2024 16:41:30 +0000</pubDate>
      <link>https://dev.to/karin1986/step-by-step-guide-to-installing-terraform-on-windows-on-a-subsystem-linuxubuntu-server-4n1i</link>
      <guid>https://dev.to/karin1986/step-by-step-guide-to-installing-terraform-on-windows-on-a-subsystem-linuxubuntu-server-4n1i</guid>
      <description>&lt;p&gt;Sometimes it's way easier to use Linux on a Windows OS. For those who love Ubuntu/Linux and want to work comfortably with Terraform, this post is for you!&lt;/p&gt;

&lt;p&gt;One of the reasons I love working with Ubuntu/Linux is because installing software is far easier than on Windows. You only need one line command: sudo apt install, or sudo snap install...&lt;/p&gt;

&lt;p&gt;No fuss, no hassle!&lt;/p&gt;

&lt;p&gt;Another reason is that Ubuntu Linux is an open-source OS with plenty of capabilities to work with lots of tools, programming languages, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Step 1: Head to the Terraform website
&lt;/h2&gt;

&lt;p&gt;Visit Terraform's website and click on 'Download Terraform'.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekzgbxgxtjmd7pvv0jjx.PNG" class="article-body-image-wrapper"&gt;&lt;img alt="Image description" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekzgbxgxtjmd7pvv0jjx.PNG" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Go to the Linux Tab option
&lt;/h2&gt;

&lt;p&gt;By default, we see Mac OS first on the left-hand side, so choose 'Linux' and copy the first command option with wget -O on your Ubuntu terminal. I assume you have previously installed Ubuntu with wsl --install.&lt;/p&gt;

&lt;p&gt;If that does not work, then use: sudo snap install terraform&lt;/p&gt;

&lt;p&gt;The reason for using snap is because if you use sudo apt, it will likely print an error such as:&lt;/p&gt;

&lt;p&gt;This is because Terraform is available via the snap package manager.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Check Terraform installation
&lt;/h2&gt;

&lt;p&gt;Type in your Ubuntu terminal the command: terraform --version&lt;/p&gt;

&lt;p&gt;If you successfully get a message with the version of Terraform, then we can be certain that Terraform has been installed.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31ujhhk7az3gakg0h0x5.PNG" class="article-body-image-wrapper"&gt;&lt;img alt="Image description" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31ujhhk7az3gakg0h0x5.PNG" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Important to know: because we are installing Terraform on WSL (Windows Subsystem for Linux), it is not necessary to add its path to the environment system variables which makes sense because we are using wsl. &lt;/p&gt;

&lt;p&gt;If you want to install it directly on Windows, then I advise you to use this article from another fellow dev creator: &lt;a href="https://dev.to/annysah/step-by-step-guide-to-installing-terraform-on-windows-m2e"&gt;Step by Step guide to installing Terraform on windows&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Terraforming!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>terraform</category>
      <category>installterraform</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to build an object with 'Class Constructors' in Javascript</title>
      <dc:creator>Karin</dc:creator>
      <pubDate>Thu, 28 May 2020 09:35:23 +0000</pubDate>
      <link>https://dev.to/karin1986/how-to-build-an-object-with-class-constructors-in-javascript-4b9g</link>
      <guid>https://dev.to/karin1986/how-to-build-an-object-with-class-constructors-in-javascript-4b9g</guid>
      <description>&lt;p&gt;Whilst I was creating a weather app with Javascript, I was confused about what a class constructor does.&lt;/p&gt;

&lt;p&gt;Therefore, I decided to research about it and help others to understand how to work with them.&lt;/p&gt;

&lt;p&gt;A class constructor is nothing more than a way to create an object in ES6 so is a new way but incredibly useful to create and build applications. &lt;/p&gt;

&lt;p&gt;For example, you can create a 'user search application' using an API, a Weather app or any application that requires the use of APIs.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You need to create a class with a name: follow the UpperCaseCamel rule, which means that every word starts with a capital letter.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;class Cat {}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the constructor: the constructor is simply a way to create our object and the syntax is:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;class Cat {&lt;br&gt;
   constructor() {&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the constructor&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The keyword this is very important because it points out 'which' object we want to create. &lt;br&gt;
Don't forget to give it an intuitive name everyone will be able to recognize (developer team, clients)&lt;/p&gt;

&lt;p&gt;class Cat {&lt;br&gt;
   constructor() {&lt;br&gt;
    this.treat = 'catnip'&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Call or invoke the object &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;class Cat {&lt;br&gt;
   constructor() {&lt;br&gt;
    this.treat = 'catnip'&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const catnip = new Cat('catnip')&lt;br&gt;
console.log(catnip.treat) //'catnip' &lt;/p&gt;

&lt;p&gt;I created an easy step by step infographic that you can download here:&lt;br&gt;
&lt;a href="https://karemortiz.nl/class-constructor-javascript/" rel="noopener noreferrer"&gt;https://karemortiz.nl/class-constructor-javascript/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Manipulating complex JSON in Javascript</title>
      <dc:creator>Karin</dc:creator>
      <pubDate>Sat, 18 Apr 2020 09:33:53 +0000</pubDate>
      <link>https://dev.to/karin1986/manipulating-complex-json-in-javascript-1mck</link>
      <guid>https://dev.to/karin1986/manipulating-complex-json-in-javascript-1mck</guid>
      <description>&lt;p&gt;I have been doing the Freecodecamp Javascript curriculum for the last 10 days to learn Javascript fundamentals. &lt;/p&gt;

&lt;p&gt;Well, as most people who have learned to code I have to solve challenges that involve the concepts learned previously. And I was stuck with the "Record challenge" for two days. &lt;/p&gt;

&lt;p&gt;I did a post on Twitter and researched on Google about JSON but could not find out still how to write the steps correctly. &lt;/p&gt;

&lt;p&gt;Nothing I tried worked, probably because in my head I am still figuring out how to write instructions to a computer in JS.&lt;/p&gt;

&lt;p&gt;But, fortunately, Andre, saw my post on Twitter came to my rescue! &lt;/p&gt;

&lt;p&gt;We looked together through the challenge and I could learn that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To access a JSON object I need to use the correct syntax, to tell the computer to access a particular object, using [] bracket notation was the way to go:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if:  value !== "" {&lt;br&gt;
collection[id[prop] //which is the album// // then create an empty array// = []&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The album was noted by collection. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When you read a challenge, each of the steps is a condition that must be met and decoded in JS language. In this particular challenge (Record collection) the conditions are not all an if statements.
I was writing 3 main "if" statements. In other words, having all of them with if statements tells the computer I only want to run one of them if one complies the condition. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That was a mistake. &lt;/p&gt;

&lt;p&gt;Not all steps have the same importance to achieve the end goal of the challenge.&lt;/p&gt;

&lt;p&gt;Conditions below:&lt;br&gt;
***If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.&lt;/p&gt;

&lt;p&gt;***If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.&lt;/p&gt;

&lt;p&gt;***If value is empty (""), delete the given prop property from the album.&lt;/p&gt;

&lt;p&gt;What is the main condition?&lt;/p&gt;

&lt;p&gt;Well, if we don't have any values, then delete the object. &lt;/p&gt;

&lt;p&gt;I was confused, so I wrote all these conditions following the order stated. But instead, I should have written them considering what is the most logical thing to evaluate first. &lt;/p&gt;

&lt;p&gt;My old code was:&lt;/p&gt;

&lt;p&gt;function updateRecords(id, prop, value)&lt;br&gt;
 { if (prop === "tracks" &amp;amp;&amp;amp; collection[id]["tracks"] === undefined) {&lt;br&gt;
    collection[id]["tracks"] = []&lt;br&gt;
  } //If prop is "tracks" and value isn't empty (""), &lt;br&gt;
  //push the value onto the end of the album's existing tracks array.//&lt;br&gt;
  if (prop === "tracks" &amp;amp;&amp;amp; value !== "") {&lt;br&gt;
    collection[id]["tracks"].push(value)&lt;br&gt;
  } //If value is empty (""), delete the given prop property from the album.//&lt;br&gt;
   if (value === "") {&lt;br&gt;
     delete collection[id][prop]&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;else { collection[id][prop] = value; }&lt;/p&gt;

&lt;p&gt;console.log(collection[id])&lt;/p&gt;

&lt;p&gt;return collection &lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;It did not pass the challenge, because there are main conditions all in the same level of the hierarchy. &lt;/p&gt;

&lt;p&gt;The first "if" will execute as is one of the main conditions.&lt;br&gt;
The second "if" will not be executed by the computer. As I am saying "if you encounter the first "if" them, do not execute the other instructions. &lt;/p&gt;

&lt;p&gt;So I re-ordered and added an else if statement in the second condition. &lt;br&gt;
New code:&lt;/p&gt;

&lt;p&gt;function updateRecords(id, prop, value) {&lt;br&gt;
  if (value === "") {&lt;br&gt;
    delete collection[id][prop];&lt;br&gt;
  } else if (prop === "tracks") {&lt;br&gt;
    collection[id][prop] = collection[id][prop] || [];&lt;br&gt;
    collection[id]["tracks"].push(value);&lt;br&gt;
  } else {collection[id][prop] = value }&lt;/p&gt;

&lt;p&gt;return collection;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;console.log(updateRecords(5439, "artist", "ABBA"));&lt;/p&gt;

&lt;p&gt;The else statement was overwriting the second condition with if.&lt;br&gt;
After changing the second if to an else if statement it worked!&lt;/p&gt;

&lt;p&gt;Other useful things to know when manipulating JSON Objects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access the objects with [] and specify what property you want to access:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example: &lt;/p&gt;

&lt;p&gt;let household {&lt;/p&gt;

&lt;p&gt;Object 1=&amp;gt;  household1: { &lt;br&gt;
              Name: Sunflower;&lt;br&gt;
              N of people: 5;&lt;br&gt;
              Status: medium class; &lt;br&gt;
              Children: [&lt;br&gt;
                  "Charles",&lt;br&gt;
                   "Brigitt", &lt;br&gt;
                       ]&lt;br&gt;
              Working: yes; &lt;br&gt;
},&lt;/p&gt;

&lt;p&gt;Object 2=&amp;gt;  household2: { &lt;br&gt;
              Name: Tulips;&lt;br&gt;
              N of people: 8;&lt;br&gt;
              Status: high class; &lt;br&gt;
              Children: [&lt;br&gt;
                  "Victoria",&lt;br&gt;
                   "Shalston", &lt;br&gt;
                       ]&lt;br&gt;
             working: "", &lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;//Access household when the property has an empty "" value// &lt;/p&gt;

&lt;p&gt;function registryCity(id, prop, value)    {&lt;br&gt;
if (household[id][prop] === "") {&lt;br&gt;
 household[id[prop] = household[id][prop] || []  }&lt;/p&gt;

&lt;p&gt;return household; &lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Note: I am accessing the prop after indicating the id, as there are two properties, is needed to specify the ID first (imagine is like a "door").&lt;br&gt;
Without the [id], the computer cannot enter any of the [prop]. &lt;/p&gt;

&lt;p&gt;These are the main takeaways from this challenge with JSON objects, quite a long way still to go but persevering is key to learn to code. &lt;/p&gt;

&lt;p&gt;If you are a beginner like myself, I do strongly recommend to review fundamentals at least 3 times, write code that proves these concepts. Then come back to it and speak out loud about these concepts. &lt;/p&gt;

&lt;p&gt;Consider writing a blog post about it too!&lt;/p&gt;

&lt;p&gt;A massive thanks to Andre and all people that assisted me to understand how to solve this challenge! &lt;/p&gt;

&lt;p&gt;Now onto reviewing Freecodecamp Javascript from lesson 1 again!&lt;/p&gt;

&lt;p&gt;Keep up!&lt;/p&gt;

&lt;p&gt;Karem &lt;/p&gt;

</description>
      <category>json</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>computersciencev</category>
    </item>
  </channel>
</rss>
