<?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: Zhona</title>
    <description>The latest articles on DEV Community by Zhona (@teanaz).</description>
    <link>https://dev.to/teanaz</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%2F928085%2Fd31c8645-eea9-495f-8b97-3bba91e38487.png</url>
      <title>DEV Community: Zhona</title>
      <link>https://dev.to/teanaz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/teanaz"/>
    <language>en</language>
    <item>
      <title>MVC</title>
      <dc:creator>Zhona</dc:creator>
      <pubDate>Mon, 12 Dec 2022 15:51:30 +0000</pubDate>
      <link>https://dev.to/teanaz/mvc-2mjn</link>
      <guid>https://dev.to/teanaz/mvc-2mjn</guid>
      <description>&lt;p&gt;I made it to Phase 4! The second to last Phase at Flatiron School! In this Phase we learned Ruby on Rails which is an open source web framework written in the Ruby language. It is a full stack framework allowing developers to build on the front and back end. At Flatiron we were taught JavaScript and React during the first 2 phases so we will only be using Ruby on Rails as a backend language. &lt;/p&gt;

&lt;p&gt;Starting this phase made me realize how fast time flies, it feels like I just started Phase 1 a few weeks ago. At the moment I'm writing this blog I have already completed Phase 4 and I'm preparing to start Phase 5. I would say Phase 4 was definitely one of the phases where I learned the most. For project week my group and I decided to make a fake NFT marketplace. Fake meaning we just rendered the jpegs and had a fake cart page. Our main goal for the project was to meet the MVP requirements. While we did do that, we had tremendous trouble connecting the front end to the back and doing authentications. One moment full crud on the project table was working perfectly... then we started working on the front end and errors everywhere! We moved onto doing the login and bam! More bugs! While the project was stressful to do, I'm glad my group and I were able to complete it on time (5 minutes before it was due to be exact!). Now I feel pretty confident moving onto Phase 5 and I'm excited to see what I'll be able to create within the next 4 weeks. &lt;/p&gt;

&lt;p&gt;One thing I like about Ruby on Rails was that it wasn't difficult to learn. The syntax was pretty simple and the errors messages were extremely helpful, and less in your face like React. Ruby on Rails has 3 main subdirectories, the model, view and controllers also known as the MVC. These three are the main components that makes up the architectural pattern for this specific software 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwadqd66yxr2qsh3ja7ba.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwadqd66yxr2qsh3ja7ba.png" alt="Image description" width="333" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apeksha Sighn does a great job at explaining how each of these 3 components differ. &lt;/p&gt;

&lt;p&gt;"The browser sends a request for a page to the controller on the server&lt;br&gt;
The controller retrieves the data it needs from the model in order to respond to the request&lt;br&gt;
The controller gives the retrieved data to the view&lt;br&gt;
The view is rendered and sent back to the client for the browser to display"&lt;/p&gt;

&lt;p&gt;The model, view and controller component all work together to create a functioning back end.&lt;/p&gt;

&lt;p&gt;For example, let’s say you’re on a website and we want to add an item to cart. To do that we’ll click on the "add to cart" button and we’ll get redirected to the carts page with our items in the cart. How does one click make all this happen in a matter of seconds? &lt;/p&gt;

&lt;p&gt;When we click “add to cart” the browser sends a request to the controller file on the server. The controller files “read” the request and return the appropriate output from the model files. The data retrieved from the controller and model is then passed on to the view. The view renders the data which is what the user sees on the front end. &lt;/p&gt;

&lt;p&gt;The view should contain code relating to displaying the data only. The data in this file may be html or a combination of html and ruby code. Everything Ruby sends to the web browser is handled by the view. &lt;/p&gt;

&lt;p&gt;The controller holds the functions that defines the routes in the routes file. In the routes file we set back end routes that redirect us every time we make a call. In order for ruby to direct us to the route we have to define a function in the controllers file. The controllers file tells us what information to display when we get to a certain route. This is all then rendered by views. &lt;/p&gt;

&lt;p&gt;When we click “add to cart” the browser sends a request to the controller file on the server. The controller files “read” the request and return the appropriate output from the model files. The data retrieved from the controller and model is then passed on to the view. The view renders the data which is what the user sees on the front end. &lt;/p&gt;

&lt;p&gt;The view should contain code relating to displaying the data only. The data in this file may be html or a combination of html and ruby code. Everything Ruby sends to the web browser is handled by the view. &lt;/p&gt;

&lt;p&gt;The models file holds all our table relationships and the validations. The relationships determines how tables can interact with each other and the validations determines if certain functions in the controller will be valid when we run it.&lt;/p&gt;

&lt;p&gt;The controller holds the functions that you define in your models file. In the routes file we set back end routes that redirects us every time we make a call. In order for ruby to direct us to the route we have to define a function in the controllers file. The controllers file tells us what information to display when we get to a certain route. This is all then rendered by the views. &lt;/p&gt;

&lt;p&gt;Reference - &lt;br&gt;
&lt;a href="https://blog1.westagilelabs.com/m-v-c-architecture-of-ruby-on-rails-9712719a69ed" rel="noopener noreferrer"&gt;https://blog1.westagilelabs.com/m-v-c-architecture-of-ruby-on-rails-9712719a69ed&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>.map like a function?</title>
      <dc:creator>Zhona</dc:creator>
      <pubDate>Wed, 26 Oct 2022 23:39:06 +0000</pubDate>
      <link>https://dev.to/teanaz/map-like-a-function-3lc1</link>
      <guid>https://dev.to/teanaz/map-like-a-function-3lc1</guid>
      <description>&lt;p&gt;Before beginning Phase 2 I would go around the school asking the students in the phases above how I should prepare for phase 2, they all replied the same, “study .map and filter”. Did I do as they suggested? NOPE. Should I have done as they suggested? YES! During Phase 1 I did use .map once in my project(with the aid of a student in the upper class) but that was it, I didn’t have a clear idea of what its functionality was, therefore I came into the second phase pretty much clueless. &lt;/p&gt;

&lt;p&gt;I knew React was based on Javascript and that was about it. Learning React was tough… very tough. After learning vanilla Javascript for 3 weeks I was finally getting to a point where I was comfortable using it but that moment didn’t last very long, phase 2 came around and I was back to the beginning. All the syntax I learned in Phase 1 wasn’t relevant anymore and I had to start over from scratch.&lt;/p&gt;

&lt;p&gt;So what is .map? &lt;/p&gt;

&lt;p&gt;Here is Geekforgeeks.com’s definition of .map(), &lt;br&gt;
“Map is a collection of elements where each element is stored as a Key, value pair. Map objects can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, value pair in the same order as inserted.” &lt;/p&gt;

&lt;p&gt;.map takes the original array and returns a new array with items added to it. When mapping we need to give each element its own unique key which helps identify it. Before we get to the more complex stuff, let’s get a basic idea of what .map is. &lt;/p&gt;

&lt;p&gt;Here is an example &lt;br&gt;
//the array&lt;br&gt;
const array1 = [1, 4, 9, 16]; =&amp;gt; &lt;/p&gt;

&lt;p&gt;// pass a function to map&lt;br&gt;
const map1 = array1.map(x =&amp;gt; x * 2);&lt;/p&gt;

&lt;p&gt;console.log(map1);&lt;br&gt;
// expected output: Array [2, 8, 18, 32]&lt;br&gt;
As we can see we have an array, passed through .map which takes the original array, multiplies it by 2 and returns a new array with a new value. &lt;/p&gt;

&lt;p&gt;Here is another example. &lt;/p&gt;

&lt;p&gt;Const numbers = [10, 20, 30, 40 , 50 ]&lt;/p&gt;

&lt;p&gt;Const addTwo = numbers.map((number)=&amp;gt; (&lt;br&gt;
number + 2 ))&lt;br&gt;
What would the function return?? Take a guess. &lt;/p&gt;

&lt;p&gt;A)12, 22, 32, 42, 52&lt;br&gt;
B)8, 18, 28, 38, 48&lt;br&gt;
C)20, 40, 60, 80, 100&lt;/p&gt;

&lt;p&gt;To get the value of the variable addTwo we will have to console.log it. &lt;br&gt;
console.log(addTwo)&lt;br&gt;
12, 22, 32, 42, 52. &lt;/p&gt;

&lt;p&gt;The answer was A! What exactly did the code above do? First we have an array called numbers with the values of 10, 20, 30, 40 and 50. We made a new variable called addTwo where we applied .map on the numbers variable and got a return value of 12, 22, 32, 42, 52. To put it simply, .map is a function. It takes an array, applies a function to each value in the array and returns a new value. In our case we are passing numbers as the value and telling .map the function to add 2 to each of the values. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0n3uaaoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdmpekk1fxx6wdyffh9x.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0n3uaaoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdmpekk1fxx6wdyffh9x.jpeg" alt="Image description" width="880" height="789"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another way to look at it is the image below. We start off with four cups of coffee but after applying the .map function to all four of the coffee we get a latte. In this example the coffee is the array, the barista pouring in the milk acts as the .map function and latte is the result of the coffee and the barista. &lt;/p&gt;

&lt;p&gt;If we were to turn this into code, it would be something like this.&lt;/p&gt;

&lt;p&gt;//array&lt;br&gt;
Const cafes =[coffee, coffee, coffee, coffee]&lt;/p&gt;

&lt;p&gt;We pass the coffee(the array) to the barista(the function) who will then pour milk into each cup of coffee.&lt;/p&gt;

&lt;p&gt;Const addMilk = cafes.map((coffee)=&amp;gt; ( //THIS IS NOT A VALID FUNCTION&lt;br&gt;
Coffee + milk ))&lt;/p&gt;

&lt;p&gt;The final product is a latte! &lt;br&gt;
console.log(addMilk)&lt;br&gt;
Latte&lt;/p&gt;

&lt;p&gt;Another example would be decorating cupcakes. Let's say we start off with five plain cupcakes but we want them to all have chocolate icing. A simple to do list would be this- &lt;/p&gt;

&lt;p&gt;How to “make” five iced chocolate cupcakes. &lt;br&gt;
Ingredients - &lt;br&gt;
Five plain cupcakes, &lt;br&gt;
Chocolate icing, &lt;br&gt;
Human, &lt;br&gt;
Spatula &lt;/p&gt;

&lt;p&gt;Step 1 - Get five plain cupcakes. &lt;br&gt;
Step 2- The human needs to get a dollop of chocolate icing using the spatula.&lt;br&gt;
Step 3- Apply the chocolate icing on the cupcakes using the spatula.&lt;br&gt;
Step 4- finish! &lt;/p&gt;

&lt;p&gt;In this example the 5 plain cupcakes represent the array. The function is the person and the chocolate icing is the expression we’re applying to each cupcake. The final result is a chocolate iced cupcake. &lt;/p&gt;

&lt;p&gt;At first I was confused on what .map’s purpose was but after practicing and practicing I am finally comfortable using it. My definition of .map is that we use when we want to add more information to every object in an array. Instead of hard coding and manually typing a new array we can just call a function that will iterate through each value for us.&lt;/p&gt;

&lt;p&gt;References &lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/map-in-javascript/"&gt;https://www.geeksforgeeks.org/map-in-javascript/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Phase 1 blog</title>
      <dc:creator>Zhona</dc:creator>
      <pubDate>Mon, 19 Sep 2022 01:19:50 +0000</pubDate>
      <link>https://dev.to/teanaz/phase-1-blog-2j84</link>
      <guid>https://dev.to/teanaz/phase-1-blog-2j84</guid>
      <description>&lt;p&gt;I completed phase one at Flatiron School! This was definitely a challenge but I'm so proud I completed it. These past 3 weeks went by so quickly and I can for sure say I learned a lot. I enjoyed getting to know my cohort and learning along with them. &lt;/p&gt;

&lt;p&gt;During phase one we learned about the basics of JavaScript. After spending 2 weeks learning about the DOM, event listeners and fetch requests, the class was able to use their skills to make a functioning website. For my website, my partner and I created a movie review website where people can read descriptions of top rated and new releases movies. A part of my project required me to fetch the json file and display the information from it on the dom. To do that I had to use either innerText, innerHTML or innerTEXT. While I could’ve used either 3 of those to complete my task, I was still confused about which one to use. So here’s a breakdown of the three make your life easier!&lt;/p&gt;

&lt;p&gt;This will be out sample code. &lt;br&gt;
We used a div element and set the id to exampleCode. We have a bold and code tag. The bold tag will make the content inside it bold and the code tag will display the content inside it as monospace font.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id=‘exampleCode&amp;gt;

  This world is &amp;lt;bold&amp;gt;bold&amp;lt;/bold&amp;gt;. There is a space       &amp;lt;code&amp;gt;here&amp;lt;/code&amp;gt;
  &amp;lt;/div&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get the text to display we can declare an element to it and then call it using innerHTML, innerText and textContent.&lt;/p&gt;

&lt;p&gt;const exampleCode = document.getElementById('blog-test');&lt;br&gt;
  exampleCode.innerHTML&lt;br&gt;
  exampleCode.innerText&lt;br&gt;
  exampleCode.textContent&lt;/p&gt;

&lt;p&gt;When we call the code using .innerHTML, it will return this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"This world is &amp;lt;bold&amp;gt;bold&amp;lt;/bold&amp;gt;. There is a space       &amp;lt;code&amp;gt;here&amp;lt;/code&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.innerHTML will return the html markup within the code as we can see with  and &lt;code&gt;. Use this when you want to see the html content of a code. &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When we call the code using .textContent, it will return this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "This world is bold. There is a space       here"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.textContent will return this code with the html markups applied to it. We can see the extra spacing added between “space” and “&lt;code&gt;here&lt;/code&gt;” have been applied. Use this when you want to see the value of an element with the formatting applied. &lt;/p&gt;

&lt;p&gt;When we call the code using .innerText, it will return this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"This world is bold. There is a space here"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.innerText will return the code with the html markups applied to it but the extra spacing in the code will be ignored. Use this when you want to see the value of an element but with the formatting ignored.&lt;/p&gt;

&lt;p&gt;Reference list &lt;br&gt;
&lt;a href="https://betterprogramming.pub/whats-best-innertext-vs-innerhtml-vs-textcontent-903ebc43a3fc"&gt;https://betterprogramming.pub/whats-best-innertext-vs-innerhtml-vs-textcontent-903ebc43a3fc&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/"&gt;https://www.w3schools.com/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
