<?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: Desiree Ann Zarco</title>
    <description>The latest articles on DEV Community by Desiree Ann Zarco (@desireezarco).</description>
    <link>https://dev.to/desireezarco</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%2F1102116%2F23f716d3-5afb-478c-a837-ec94acb0dba6.jpeg</url>
      <title>DEV Community: Desiree Ann Zarco</title>
      <link>https://dev.to/desireezarco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/desireezarco"/>
    <language>en</language>
    <item>
      <title>How to organize your code using Import and Export in React</title>
      <dc:creator>Desiree Ann Zarco</dc:creator>
      <pubDate>Mon, 09 Oct 2023 02:03:56 +0000</pubDate>
      <link>https://dev.to/desireezarco/how-to-organize-your-code-using-import-and-export-in-react-ih</link>
      <guid>https://dev.to/desireezarco/how-to-organize-your-code-using-import-and-export-in-react-ih</guid>
      <description>&lt;p&gt;As a developer, it is important to keep your code clean and well organized, especially when you're working with long blocks of code. Learning import and export was a little challenging for me when I first started to learn React, but it is actually pretty straightforward. We basically give "access" to the codes within files that will be using it. Sounds confusing, but let's go with this simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NavBar.js file

import React from "react";

function NavBar() {
  return (
    &amp;lt;nav&amp;gt;
      &amp;lt;a href="#home"&amp;gt;I'm a link!&amp;lt;/a&amp;gt;
    &amp;lt;/nav&amp;gt;
  );
}

export default NavBar

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

&lt;/div&gt;



&lt;p&gt;When you want to use your code in another component, you share it by writing &lt;em&gt;export default&lt;/em&gt; at the bottom of your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.js file

import React from "react";
import NavBar from './NavBar'

function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;NavBar /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you need to use a component, you need to import it at the top of the file, like the example above.&lt;br&gt;
&lt;code&gt;import NavBar from './NavBar'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you noticed at the top of the file, it usually starts with &lt;code&gt;import React from "React";&lt;/code&gt; and that is because in React, we are writing in JSX. JSX is JavaScript XML. JSX allows us to write HTML and React Components in React.&lt;br&gt;
Let's import another component to our App.js file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;About.js file 

import React from "react";

function About() {
  return (
    &amp;lt;div id="about"&amp;gt;
      &amp;lt;h2&amp;gt;About Me&amp;lt;/h2&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default About
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.js file

import React from "react";
import NavBar from './NavBar';
import About from './About';

function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;NavBar /&amp;gt;
      &amp;lt;About /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to practice, try adding another component to the App.js file. Make a new file, name it Home.js, and inside the Home.js file, you can write a basic function, then you would export the name of your file that you want to share and use in your other files &lt;br&gt;
&lt;code&gt;export default Home;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Move to the App.js file and import that file at the top, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.js file

import React from "react";
import NavBar from './NavBar';
import About from './About';
import Home from "./Home';

function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;NavBar /&amp;gt;
      &amp;lt;About /&amp;gt;
      &amp;lt;Home /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to add the component itself, inside your function. &lt;/p&gt;

&lt;p&gt;Test this out on your own and see that it works! This is just the basics on how to import and export in between your files and work with usable components.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What's a function in JavaScript?</title>
      <dc:creator>Desiree Ann Zarco</dc:creator>
      <pubDate>Sat, 22 Jul 2023 22:57:05 +0000</pubDate>
      <link>https://dev.to/desireezarco/whats-a-function-in-javascript-5b9</link>
      <guid>https://dev.to/desireezarco/whats-a-function-in-javascript-5b9</guid>
      <description>&lt;p&gt;Hello everyone, this is my very first technical blog post ever, so I will do my best to explain this topic the best I could. I am currently a student in a front-end web development bootcamp. I wanted to dedicate my first blog post to the basic and fundamental concept that I struggled with as a coding newbie: Functions.&lt;/p&gt;

&lt;p&gt;First, let's define what a function is in Javascript. According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#defining_functions"&gt;Mozilla.org&lt;/a&gt;, a function is, "a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output."&lt;/p&gt;

&lt;p&gt;In simpler terms, a function is a block of code that executes a task. It takes in arguments, and passes bits of code into the function (inside the curly braces) to execute whatever is inside the function.&lt;/p&gt;

&lt;p&gt;Are you still confused? Let's take a closer look at the &lt;em&gt;syntax&lt;/em&gt; of a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function variableName(parameter){
     //written code to be executed when function is called
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a function, you start by typing in the keyword function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you are going to need to declare a variable name after the function keyword. If it's more than one word, make sure to camel case it (e.g., camelCase, first word is lowercased with no space, and first letter of second word is uppercased)! Then after you name the variable, there needs to be a set a parenthesis and curly braces. Inside the parenthesis are what you'd call values. Then after parenthesis comes a set of curly braces. Whatever lies in between the curly braces are the written code to be executed. For example, let's start with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greetHello(){
     //code to execute when function is called.
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable name is &lt;code&gt;greetHello&lt;/code&gt;. Currently, there is nothing inside the curly braces, so the function isn't going to do anything. There are no values or arguments inside the parenthesis, but that is totally okay. You could even have more than one values, and you'll see in another example. &lt;br&gt;
If I want a function to work, we need to have bits of code to work with. For example, I want to use &lt;code&gt;console.log&lt;/code&gt; to print out a message, and insert it in between the curly braces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greetHello(){
     console.log("Hello")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To execute the function, I need to &lt;em&gt;call&lt;/em&gt; the function outside of the curly braces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greetHello(){
     console.log("Hello")
}

greetHello()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you've called the function &lt;code&gt;greetHello()&lt;/code&gt;, if you look at the web console, you will see &lt;code&gt;"Hello"&lt;/code&gt; being outputted due to what is written inside the braces. &lt;/p&gt;

&lt;p&gt;Let's take a look at another example:&lt;/p&gt;

&lt;p&gt;This time, we'll work with numbers and have &lt;em&gt;two&lt;/em&gt; values in our parameters.&lt;/p&gt;

&lt;p&gt;Remember, we first need to write the function keyword and a variable. Since we'll have two values, they need to be separated by commas, &lt;code&gt;(a, b)&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a, b)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable is &lt;code&gt;sum&lt;/code&gt; followed by the parameters. After you have the function, variable and parameters, you then need to add curly braces for the bits of code that you want the function to execute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a, b){

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

&lt;/div&gt;



&lt;p&gt;Currently, there's nothing in between the curly braces for the function to work, so in order for us to determine if the function is working, we can use &lt;code&gt;console.log()&lt;/code&gt;. If you did not know already, &lt;code&gt;console.log()&lt;/code&gt; is also a function, and it print out any message or information into the web console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a, b){
     console.log()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find the sum of the two values inside our parameters, you would need to write it as &lt;code&gt;console.log(a + b)&lt;/code&gt;, like a simple addition equation, but what is &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;? In this example, we can assign any number to those values. First, to find the sum, we have to "call" the function itself, but remember important to write it &lt;em&gt;outside&lt;/em&gt; of the function, or outside of the curly braces. For this example, we will assign &lt;code&gt;a = 1&lt;/code&gt; and &lt;code&gt;b = 2&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a, b){
     console.log(a + b)
}

sum(1, 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you have assigned values to the variables, the next thing is to check the value of the sum in the console. It will print out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You've successfully called the function sum, and received 3 is your output. This is just a couple of easy examples of how functions work, and it can get really complex, especially when you're working with other data types. I hope this made sense and is helpful! &lt;/p&gt;

&lt;p&gt;Resources:&lt;br&gt;
MDN contributors, "Functions." , Developer.mozilla.org, Jul 22, 2023, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#predefined_functions"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#predefined_functions&lt;/a&gt;, &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
