<?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: Jose Campos</title>
    <description>The latest articles on DEV Community by Jose Campos (@josec1997).</description>
    <link>https://dev.to/josec1997</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%2F961547%2Ffd477064-4cf0-44ff-82e8-643136e15542.png</url>
      <title>DEV Community: Jose Campos</title>
      <link>https://dev.to/josec1997</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/josec1997"/>
    <language>en</language>
    <item>
      <title>React: Components &amp; Props</title>
      <dc:creator>Jose Campos</dc:creator>
      <pubDate>Wed, 05 Apr 2023 01:12:37 +0000</pubDate>
      <link>https://dev.to/josec1997/react-components-props-3h9e</link>
      <guid>https://dev.to/josec1997/react-components-props-3h9e</guid>
      <description>&lt;h2&gt;
  
  
  The Basics of React Components
&lt;/h2&gt;

&lt;p&gt;The main puzzle piece of React is &lt;strong&gt;components&lt;/strong&gt;, they compartmentalize our code into parts, which include the presentation and how the code executes. If the concept is a bit difficult to grasp, think of little baskets of code, keeping everything organized. Components contain all sorts of code but they still have the same objective. Which is to describe what should be rendered to the DOM (Document Object Model).&lt;br&gt;
&lt;strong&gt;Component Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lovc--aZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kqezw99ql8xl69a912bq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lovc--aZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kqezw99ql8xl69a912bq.png" alt="Comp example" width="880" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The function &lt;strong&gt;BasketofCode&lt;/strong&gt; is declared and then &lt;strong&gt;JSX&lt;/strong&gt; is returned.JSX is Javascript XML, which allows us to write HTML in React and makes it easier to write and add HTML in React (for more in-depth on the matter, see provided links below). React creates said element and it will display like so (Note: is important that all elements have to be wrapped in a &lt;/p&gt; for React to work)&lt;br&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JsKdkM-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fuegrem41bg36xbkc9xo.png" alt="div ex" width="808" height="54"&gt;&lt;br&gt;
React will take this JavaScript code, translate the JSX syntax within the return() statement, and produce HTML that the browsers will know how to show to the user.
&lt;h2&gt;
  
  
  How to put Components to Use
&lt;/h2&gt;

&lt;p&gt;It is the norm to set the topmost level component to &lt;strong&gt;App()&lt;/strong&gt; and have it return other components (this is where the compartments show). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vB1R107E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bu89h0j8ppv7dax1xdwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vB1R107E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bu89h0j8ppv7dax1xdwh.png" alt="app comp example" width="820" height="328"&gt;&lt;/a&gt;&lt;br&gt;
The code inside the &lt;strong&gt;return()&lt;/strong&gt; is seeing what JSX can do. This does somewhat look like HTML with that &lt;strong&gt; but it's more intricate than that. We are also rendering two elements, and we set it to where it will render the component &lt;em&gt;BasketofCode&lt;/em&gt; before &lt;em&gt;Items&lt;/em&gt;. resulting to look something like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ybOjeyaP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yd756oscccsbmuzzhnw9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ybOjeyaP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yd756oscccsbmuzzhnw9.png" alt="2 comp example&amp;lt;br&amp;gt;
" width="797" height="137"&gt;&lt;/a&gt;&lt;br&gt;
Naturally the &lt;strong&gt;App()&lt;/strong&gt; Component is the parent to the children components &lt;em&gt;BasketofCode&lt;/em&gt; and &lt;em&gt;Items&lt;/em&gt;, so we can reference the App as both of them combined. 
&lt;h2&gt;
  
  
  Component Names
&lt;/h2&gt;

&lt;p&gt;It is crucial to name a component with a capital letter. App(), BasketofCode(), Items(),etc. It is a React rule to render our components correctly, also helps other React developers interpret what are Javascript functions and what is React Components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NlpViIzK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcwthncc3amv85b45bzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NlpViIzK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcwthncc3amv85b45bzy.png" alt="element" width="880" height="131"&gt;&lt;/a&gt;&lt;br&gt;
The code would run as a regular 'codeeaxmple' HTML element versus an actual component. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iY-rZa8J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hrxtrot5rs6ytq3qyxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iY-rZa8J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hrxtrot5rs6ytq3qyxs.png" alt="improper react" width="594" height="199"&gt;&lt;/a&gt;&lt;br&gt;
Proper syntax and letter placement will give us the desired output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3UjC-8aP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zp63gwcwh0zzeychbqm6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3UjC-8aP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zp63gwcwh0zzeychbqm6.png" alt="proper comp ex" width="623" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Class Components
&lt;/h2&gt;

&lt;p&gt;There are multiple ways to write out components. the regular function Component you have seen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3HZlTSti--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2274vzvfm7gjs74il1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3HZlTSti--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2274vzvfm7gjs74il1u.png" alt="function comp" width="670" height="220"&gt;&lt;/a&gt;&lt;br&gt;
can also use in an arrow syntax method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wo8OofZU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lufaod0vijgh2wzk5fcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wo8OofZU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lufaod0vijgh2wzk5fcg.png" alt="arrow comp" width="785" height="66"&gt;&lt;/a&gt;&lt;br&gt;
Components are the base and heart of React when structuring your front end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Organization
&lt;/h2&gt;

&lt;p&gt;To show multiple Javascript across multiple files we'll need to &lt;strong&gt;Import&lt;/strong&gt; and &lt;strong&gt;Export&lt;/strong&gt; them accordingly.&lt;br&gt;
Developers like to separate their code into different parts/segments to make it more modular, hence modular code.&lt;br&gt;
Stricter variable scope: Variables declared in modules are private unless explicitly exported, you don't have to worry about harming the global variable scope by using modules.&lt;br&gt;
Single-responsibility principle: Each module is in charge of accomplishing a certain piece of functionality, or adding a specific feature to the application. Easier to navigate: Modules that are separated and clearly named make code more readable for other developers. Easier to debug: Bugs have less room to hide in isolated, contained code. Produce clean and DRY code: Modules can be reused and repurposed throughout applications.&lt;br&gt;
Therefore it isn't uncommon to see a React Tree look like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qhym4mBu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gy3ebhzw3zbtt4xqb9jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qhym4mBu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gy3ebhzw3zbtt4xqb9jp.png" alt="react tree" width="443" height="240"&gt;&lt;/a&gt;&lt;br&gt;
To define variables in one file and use those variables in other files throughout the code project, we'll need to import and export accordingly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nwLMxHbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32ki0yd0l29aox86mifv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nwLMxHbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32ki0yd0l29aox86mifv.png" alt="import" width="589" height="306"&gt;&lt;/a&gt;&lt;br&gt;
Here we imported React to use in the code, and at the very end we exported it so that we could import it into the App() to use all the JSX from that component.&lt;br&gt;
Example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ytc4kPbW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub2b7anqylwrcvmdiv59.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ytc4kPbW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub2b7anqylwrcvmdiv59.png" alt="imports" width="880" height="266"&gt;&lt;/a&gt;&lt;br&gt;
Here is a more complex set of files being imported into the App() Component, so it could all be complied together and rendered to the DOM. (More in-depth on the matter is in the MDN links provided)&lt;/p&gt;

&lt;h2&gt;
  
  
  Props
&lt;/h2&gt;

&lt;p&gt;To know what props are, we have to go back to components. Components are functions that can take props as arguments as an argument and return JSX. &lt;strong&gt;Props&lt;/strong&gt; allow us to pass information from a Parent Component to a Child Component &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--whB5z1iJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n593q2xykwxvw4ocesjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--whB5z1iJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n593q2xykwxvw4ocesjn.png" alt="prop" width="788" height="318"&gt;&lt;/a&gt;&lt;br&gt;
As shown, we can see the App() component has information on a variable called "propName", this propName is passed to the child &lt;em&gt;Items&lt;/em&gt;. In order to the prop "propName" we have to accept it in the Items Component as well. (Quick tip props are camel-cased and we wrap them in { }  )For props that are strings, we don't need to place curly braces around the values; for other data types (numbers, booleans, objects, etc), we need curly braces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZbAHCuAQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpyozqx0u3gpttyufdg0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZbAHCuAQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpyozqx0u3gpttyufdg0.png" alt="take in prop" width="728" height="310"&gt;&lt;/a&gt;&lt;br&gt;
Props can be accessed in the child components via an object that is passed into our component function as an argument.&lt;br&gt;
The purpose of props helps share data from parent-to child components, making them incredibly versatile. Giving us the opportunity to make our components more dynamic, more reusable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links for more depth:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://legacy.reactjs.org/docs/react-api.html"&gt;https://legacy.reactjs.org/docs/react-api.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://legacy.reactjs.org/docs/introducing-jsx.html"&gt;https://legacy.reactjs.org/docs/introducing-jsx.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import"&gt;https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export"&gt;https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;https://reactjs.org/docs/components-and-props.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>components</category>
      <category>props</category>
    </item>
    <item>
      <title>JavaScript Functions</title>
      <dc:creator>Jose Campos</dc:creator>
      <pubDate>Mon, 23 Jan 2023 17:35:29 +0000</pubDate>
      <link>https://dev.to/josec1997/javascript-functions-2opc</link>
      <guid>https://dev.to/josec1997/javascript-functions-2opc</guid>
      <description>&lt;h2&gt;
  
  
  What is a &lt;em&gt;function&lt;/em&gt;, how to &lt;strong&gt;define&lt;/strong&gt; it?
&lt;/h2&gt;

&lt;p&gt;A function is an object that contains a sequence of JavaScript statements. We can execute or call it multiple times. A function's purpose is to group bits of JavaScript code and help improve, read, and debug. This is used on non-abstract code, single tasks if you will. (Remember ' ; ' is optional)&lt;br&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%2F8efzto4xgh923vnlwc02.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%2F8efzto4xgh923vnlwc02.png" alt="non-Abstract Code" width="491" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we 'abstract' the code and create a collective name for it.&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%2Fxp6oumnyh9abhujemupg.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%2Fxp6oumnyh9abhujemupg.png" alt="Abstract Code" width="494" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to &lt;strong&gt;Call&lt;/strong&gt; a function?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, to execute the code of a function you simply add a set '( )' after its name. Note this only works for a function we defined or nothing will be called and receive an error. The '( )' tells JavaScript to invoke a function because of this, it is an invocation operator.&lt;br&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%2Fwsstk06srovtjwy0bfg9.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%2Fwsstk06srovtjwy0bfg9.png" alt="call function" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Generalize a function
&lt;/h2&gt;

&lt;p&gt;In coding, we want to make everything easier and generalizing functions is the way to accomplish that. Let's say we had some code about a vet clinic giving employee-specific instructions to care for each different cat and breed. Rather than hard-coding each cat/ breed in multiple objects, refer to them as variables in the function using string interpolation in one single function. That would be simpler and easier, only the variables would need to define.&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%2Fhnfpujgv4i91pd575a7g.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%2Fhnfpujgv4i91pd575a7g.png" alt="generalize parameters and arguments" width="800" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  what we learned so far
&lt;/h2&gt;

&lt;p&gt;how to grab a list of operations and gather them into abstract code to create a function, then generalize that function to simplify code and its execution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Return Values
&lt;/h2&gt;

&lt;p&gt;When we call a function, it is sometimes helpful to return something. Some may call them a description/summary of what is going on in the code. We would like the function to 'make a purchase' to return 'product(purchased)'. Javascript functions can return things as well.&lt;br&gt;
Example:&lt;br&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%2Fpibrm38dcjr5fmo9dw9g.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%2Fpibrm38dcjr5fmo9dw9g.png" alt="return value" width="800" height="396"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;em&gt;return&lt;/em&gt; statement tells Javascript to return whatever value to the right of it, the value can be an expression/string/ or a number. In the code when the return is reached, the return will be executed despite any code afterward. The code following after will not be executed(returned). From the example code if &lt;em&gt;hoursOfOperation === 'Closed'&lt;/em&gt; returns true. Hence the only code returned was &lt;code&gt;${catName} the ${catBreed} cat didn't get anything done today&lt;/code&gt;. These return values can also be used as inputs in other functions or saved as variables. The basic syntax of the Function is like so: &lt;br&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%2F5hfycfgpl2blo2vzmzbe.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%2F5hfycfgpl2blo2vzmzbe.png" alt="basic function syntax" width="800" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Expression
&lt;/h2&gt;

&lt;p&gt;We gathered how to declare a function or function declaration but there are more ways to write out the function. There's another expression called arrow functions.&lt;br&gt;
Example of a function declaration:&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%2F8xdav04tdpb21ozrdgl6.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%2F8xdav04tdpb21ozrdgl6.png" alt="function expression " width="800" height="85"&gt;&lt;/a&gt;&lt;br&gt;
Can also be written so&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%2Fiz499kpo846xaecdf4x3.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%2Fiz499kpo846xaecdf4x3.png" alt="other function ex" width="615" height="80"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;em&gt;function expression&lt;/em&gt; is everything to the right of the assignment operator (&lt;em&gt;=&lt;/em&gt;) of the function() {..}.&lt;br&gt;
If it is not making any sense yet, a good analogy can help understand.&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%2Fwb07991o9cetddw110qy.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%2Fwb07991o9cetddw110qy.png" alt="funxtion expression" width="522" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The  &lt;em&gt;expression&lt;/em&gt;  would be that  &lt;em&gt;9 - 2&lt;/em&gt;  returning  &lt;em&gt;7&lt;/em&gt;  and assign a variable to  &lt;em&gt;expressionDiff&lt;/em&gt;, the same would go for    &lt;em&gt;2 + 5&lt;/em&gt; returning 7.The variable would also be assigned to &lt;em&gt;expressionSum&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Back to our expression  &lt;em&gt;function() { return 'burgers, fries, pizza, wings' }&lt;/em&gt; assigning a variable to  &lt;em&gt;food&lt;/em&gt; by returning a thing that can be called.&lt;br&gt;
The function expression (everything after the =) is known as an  &lt;em&gt;anonymous function&lt;/em&gt;. Unlike a function expression, an anonymous function doesn't have a name. You can however assign it to a variable that refers to a callable thing. Invoking &lt;em&gt;food()&lt;/em&gt; will call this anonymous function. &lt;em&gt;Food()&lt;/em&gt; is now the name for that anonymous function. Function declarations and function expressions have some differences but give the same output. It is up to the user to use either or, in JavaScript the user will learn over time when to use which method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrow Functions
&lt;/h2&gt;

&lt;p&gt;Arrow Functions allow function declarations to use the arrow syntax of the function expression, ultimately not utilizing the keyword  &lt;em&gt;function&lt;/em&gt;. It is best to get used to using this method, not only does it clean up the code for the user but also makes it simpler to follow along for other users. Debugging code would especially be easier to complete.&lt;br&gt;
Example:&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%2Fts5rxpecufjjphflj8t0.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%2Fts5rxpecufjjphflj8t0.png" alt="Arrow Function Ex" width="800" height="60"&gt;&lt;/a&gt;&lt;br&gt;
Back to saying Arrow functions make code look a lot better, they do not need any curly braces '{ }', making them &lt;strong&gt;implicit returns&lt;/strong&gt;. Only returning the result of the last expression, Can also see the body of the function is in a single expression. No  &lt;em&gt;return&lt;/em&gt; keyword is required since it's not an explicit return, &lt;strong&gt;only instance in JavaScript&lt;/strong&gt; where this occurs.&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%2F28humpsc5738bwqqj7tw.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%2F28humpsc5738bwqqj7tw.png" alt="noting arr function" width="619" height="67"&gt;&lt;/a&gt;&lt;br&gt;
The parameters are to the left of the  &lt;em&gt;=&amp;gt;&lt;/em&gt;, like a function declaration listed parameters are separated by commas inside a set of '( )'.&lt;/p&gt;

&lt;p&gt;Arrow functions do not necessarily always use 2 parameters, they can use one. If that is the case the set of '( )' is not mandatory. Most coders won't use it.&lt;br&gt;
Example:&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%2Fz77x4stnk1g1z9yh93eo.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%2Fz77x4stnk1g1z9yh93eo.png" alt="( ) arrow function" width="459" height="90"&gt;&lt;/a&gt;&lt;br&gt;
With multiple lines of code in arrow functions, a  &lt;em&gt;return&lt;/em&gt; keyword is needed along with a set of &lt;em&gt;{ }&lt;/em&gt; after the  &lt;em&gt;=&amp;gt;&lt;/em&gt; &lt;br&gt;
Example:&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%2F5i0tva6hoyjyek0bo73n.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%2F5i0tva6hoyjyek0bo73n.png" alt="ArrFunc with {}" width="591" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Know when to utilize Arrow Functions
&lt;/h2&gt;

&lt;p&gt;It's best to utilize Arrow Functions when you have to deal with a group of data one at a time, AKA  JavaScript &lt;em&gt;iterator&lt;/em&gt;  methods.&lt;br&gt;
For example, you had a set of projects submitted but the Teacher has to grade them separately.&lt;/p&gt;

&lt;p&gt;Many methods utilize Arrow Functions, .map()/.filter().forEach(). For now, let's see an example of .map():&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%2F0y6amhh299n4f4nq1lhl.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%2F0y6amhh299n4f4nq1lhl.png" alt=".map() arr Func" width="648" height="117"&gt;&lt;/a&gt;&lt;br&gt;
In each iteration through the &lt;em&gt;sqaureNums&lt;/em&gt; array, &lt;em&gt;map&lt;/em&gt; passes the value of the element to the arrow function, which is the argument being passed and assigned to parameter x. A new array is stored &lt;br&gt;
of squared values. That new array is then returned when &lt;em&gt;map&lt;/em&gt; iterated through all the elements. (link for .map at the bottom)&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The above material should give you a better grasp on functions, functions expressions, function declarations, and arrow functions.&lt;br&gt;
To know what they are, what they are used for, and when is the best time to utilize them in JavaScript. Did I already mention functions? &lt;/p&gt;

&lt;h2&gt;
  
  
  Study Links on Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;(MDN) &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Functions" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;(MDN) &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Return_values" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Return_values&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;(MDN)&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;(MDN)&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;(MDN)&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>I just changed my life for the better?</title>
      <dc:creator>Jose Campos</dc:creator>
      <pubDate>Sun, 06 Nov 2022 19:05:45 +0000</pubDate>
      <link>https://dev.to/josec1997/i-just-changed-my-life-for-the-better-d3j</link>
      <guid>https://dev.to/josec1997/i-just-changed-my-life-for-the-better-d3j</guid>
      <description>&lt;p&gt;I just began my journey into Flatiron School for software engineering. I chose to pursue a different career path due to the flexibility and honestly the interest coding will bring me. I have been in my current job around 6 years and though it is a government job with great benefits I don't find happiness in it nor see myself here for 10+ years.&lt;br&gt;
Day 1 was a little overwhelming but struck luck joining a discord with other flatiron students in the same situation as I. Me being very social, I had no issue making friends quickly. :)  We all hype and push each other to press on.&lt;br&gt;
1 week down, 39 to go!&lt;/p&gt;

</description>
      <category>newjourney</category>
      <category>flatironschool</category>
      <category>coding</category>
      <category>firstblog</category>
    </item>
  </channel>
</rss>
