<?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: Jin Wu</title>
    <description>The latest articles on DEV Community by Jin Wu (@jinwu).</description>
    <link>https://dev.to/jinwu</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%2F332017%2F8660e90b-eda4-426a-b58c-824ef436cf48.png</url>
      <title>DEV Community: Jin Wu</title>
      <link>https://dev.to/jinwu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jinwu"/>
    <language>en</language>
    <item>
      <title>React Components</title>
      <dc:creator>Jin Wu</dc:creator>
      <pubDate>Thu, 19 Mar 2020 16:49:42 +0000</pubDate>
      <link>https://dev.to/jinwu/react-components-ldc</link>
      <guid>https://dev.to/jinwu/react-components-ldc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VSNXUB1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hbymabdlfcb07md34sr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VSNXUB1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hbymabdlfcb07md34sr1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we begin, it's important to know that the parent components are able to send down properties to it's children component(s).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x9PyfJJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j3cyx8pddbl2c6xm06b4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x9PyfJJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j3cyx8pddbl2c6xm06b4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The simplest way to create a component of React is to use &lt;strong&gt;&lt;em&gt;functional components&lt;/em&gt;&lt;/strong&gt;. Functional components are just regular functions in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c9m477eK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lra8tv3slvph0ji9cukz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c9m477eK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lra8tv3slvph0ji9cukz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above are examples of writing a functional component. One is a regular function and the other is an arrow function. When using a functional component, you have to pass in an argument in order to get access to the properties you want to receive from the parent. In my examples, I used &lt;strong&gt;&lt;em&gt;props&lt;/em&gt;&lt;/strong&gt; as the argument.&lt;/p&gt;

&lt;p&gt;Now lets move onto a slightly more complex way of creating a React component via the &lt;strong&gt;&lt;em&gt;class component&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F-sTdgOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/46u5j6u52yyvr67v70fc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F-sTdgOz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/46u5j6u52yyvr67v70fc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The example shown above will return the same results as the functional component examples. Some of the differences between the two is that class components are more complex under the hood and you don't need to pass in an argument to gain access to the parents properties. You can just call &lt;code&gt;this.props.name&lt;/code&gt; to get the return value.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In functional components, the argument can be anything. But in class components, you have to use &lt;em&gt;props&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSlBZTkp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cv17z4em3xv19227h0g0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSlBZTkp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cv17z4em3xv19227h0g0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One very important difference between functional and class components is the ability to use &lt;strong&gt;&lt;em&gt;state&lt;/em&gt;&lt;/strong&gt;. Functional components are just basic functions of JavaScript and doesn't have it's own state. Class components on the other hand does. State will be very important when you want to update something in your React app.&lt;/p&gt;

&lt;p&gt;Props are read-only. If you want to be able to update information on your component, I suggest you use a class component. Of course, there are ways around it by lifting the state up to the parent component and then pass it down to the functional component via props. The parent component will most likely be a class component to gain access to state.&lt;/p&gt;

&lt;p&gt;The React docs are a great resource if you want to learn more about state, lifting state, and inverse data flow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;React Documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Events in JavaScript</title>
      <dc:creator>Jin Wu</dc:creator>
      <pubDate>Sun, 23 Feb 2020 21:12:12 +0000</pubDate>
      <link>https://dev.to/jinwu/events-in-javascript-mf1</link>
      <guid>https://dev.to/jinwu/events-in-javascript-mf1</guid>
      <description>&lt;p&gt;An &lt;strong&gt;&lt;em&gt;event&lt;/em&gt;&lt;/strong&gt; in JavaScript is when something triggers an action on the web page. An example of that "something" can be clicking on a word and then the "action" can be changing the color of the word.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LSNUfdy7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8vvukaytb7ldyevne5u0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LSNUfdy7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8vvukaytb7ldyevne5u0.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NOMbkN1i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g59v4z05g01aph9da9rg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NOMbkN1i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g59v4z05g01aph9da9rg.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Events can occur when a user loads up a page, clicks on a button, press a key, etc. These are all examples of user-generated events. In order for the web page to know you want to create an event, you need to let JavaScript know what trigger to "listen" for. Luckily for us, JavaScript have a function that is created for the purpose of listening for those triggers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;strong&gt;&lt;em&gt;addEventListener()&lt;/em&gt;&lt;/strong&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This function takes in &lt;strong&gt;&lt;em&gt;two&lt;/em&gt;&lt;/strong&gt; arguments, the event to listen for and the second argument being the what action(s) to take once that event is triggered.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K7_n_Coa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhudjk978xj4evvu8kuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K7_n_Coa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhudjk978xj4evvu8kuo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the code above, the event is triggered when you &lt;strong&gt;&lt;em&gt;click&lt;/em&gt;&lt;/strong&gt; on something and then it will display the "&lt;em&gt;Don't click on me&lt;/em&gt;" message each time it is clicked on.&lt;/p&gt;

&lt;p&gt;But wait, how does it know when or where to run this function?&lt;/p&gt;

&lt;p&gt;It's simple! You just need to do a little bit of &lt;strong&gt;&lt;em&gt;DOM Manipulation&lt;/em&gt;&lt;/strong&gt;. If you want to learn more about basic &lt;strong&gt;&lt;em&gt;DOM Manipulation&lt;/em&gt;&lt;/strong&gt; or get a quick refresh, see link below for more information. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/iqramqra/a-beginners-guide-to-dom-manipulation-45bk"&gt;A Beginners Guide To DOM Manipulation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's use this page as an example to show how it works. I will be using the built-in console of Google Chrome to demonstrate this example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developers.google.com/web/tools/chrome-devtools"&gt;Chrome DevTools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, find the object you want to manipulate. We can do that by opening the web browser console.&lt;/p&gt;

&lt;p&gt;Windows: &lt;code&gt; Control + Shift + J &lt;/code&gt;&lt;br&gt;
Mac: &lt;code&gt; Command + Option + J &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v0dC43Tb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnaufuhcz5hx4z5nwm8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v0dC43Tb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnaufuhcz5hx4z5nwm8.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the DevTools is opened up, click on the arrow button circled above and then click on the title of this blog to inspect the element. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NPpPrHfl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uftxw7ylr0qwmtjqjxix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NPpPrHfl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uftxw7ylr0qwmtjqjxix.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should get something similar to the image above back. That will be the object we'll be manipulating and adding an event to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B5NYJf0M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/391ybbokqu1rr8e4d7io.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B5NYJf0M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/391ybbokqu1rr8e4d7io.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we move onto the console tab and start writing code to find the title. One way of finding the title is with &lt;code&gt;querySelector()&lt;/code&gt;. To use this function, you need to pass in the class name of the &lt;em&gt;HTML tag&lt;/em&gt; that the title is in and then &lt;code&gt;querySelector()&lt;/code&gt; will return the first &lt;em&gt;HTML tag&lt;/em&gt; that matches the search. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you can also pass in an id name when using &lt;code&gt;querySelector()&lt;/code&gt; but for this example, it's under a class name so we passed in the class name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getElementByClass()&lt;/code&gt; is another way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once that's all done, we can finally start adding event(s) to make the web page more interactive. In my example, I saved my search to a variable &lt;code&gt;&lt;em&gt;findTitle&lt;/em&gt;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B-684ZX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijazhwenas1sf2s6tb9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B-684ZX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijazhwenas1sf2s6tb9r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, all I have to do is call the &lt;code&gt;addEventListener()&lt;/code&gt; that I created earlier to the &lt;code&gt;&lt;em&gt;findTitle&lt;/em&gt;&lt;/code&gt; variable. Every time you click the title, it will return the message "&lt;em&gt;Don't click on me&lt;/em&gt;". &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if you're really bored, just click it 50 times like I did.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okay, let's do something more interesting than clicking it and seeing increment of the same message. Let's change the color of the title to a different color when you click on it. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OJy9Fr7e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1upw5qkq6iou0uds6109.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OJy9Fr7e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1upw5qkq6iou0uds6109.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of having it &lt;code&gt;console.log()&lt;/code&gt; a message, we can change it to changing the color of the style.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R1GQlOxQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/prbjuskkgisn3s6q0qjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R1GQlOxQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/prbjuskkgisn3s6q0qjd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click on the title now, you should see the title with red font now. You can add more actions to it such as changing the style of the font, size, etc.&lt;/p&gt;

&lt;p&gt;Event triggers aren't limited to just a click of the mouse. There are many others such as key press, scrolling, and etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://data-flair.training/blogs/javascript-event-types/"&gt;Other Event Triggers&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing to note is that these changes are client-sided and won't affect how this web page is saved on the server. Once you refresh this page, the color of the font will revert back to its default color.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Intro to Enumerables</title>
      <dc:creator>Jin Wu</dc:creator>
      <pubDate>Sun, 09 Feb 2020 20:38:59 +0000</pubDate>
      <link>https://dev.to/jinwu/intro-to-enumerables-3gph</link>
      <guid>https://dev.to/jinwu/intro-to-enumerables-3gph</guid>
      <description>&lt;p&gt;When it comes to looping through arrays or hashes, Ruby provides the users with many different methods or options to work with. As you may see later in this blog, there are methods that are named differently but does the same thing.&lt;/p&gt;

&lt;p&gt;1) Each&lt;/p&gt;

&lt;p&gt;The .each method allows you to iterate over each element in that array. To do something with that array, you need to pass in a block. A block is basically the line of code that you want to execute on each element of the array. For the case below, it would be the code between the "do" and "end".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xZHA4CPr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fpwwxr73yie4b627eumj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xZHA4CPr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fpwwxr73yie4b627eumj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KxQwTKyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/giuk88fqvz133esvtead.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KxQwTKyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/giuk88fqvz133esvtead.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.each method will return the original array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want it to return a modified array, you would need to add a few more lines of codes such as setting a new variable equal to an empty array and then in each iteration, add the modified element into that empty array. At the very end, you have to call the variable you've made previously in order to return the array with the modified elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wdeDluAF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6ujser67rhs0zz0v0u8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wdeDluAF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6ujser67rhs0zz0v0u8g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EoIEgn9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8vtfhuf6owr2qqzbozk6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EoIEgn9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8vtfhuf6owr2qqzbozk6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One thing to note is that .each is a very primitive method. There are methods that can allow you to do the same thing but in less lines of codes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Map / Collect&lt;/p&gt;

&lt;p&gt;.map allows you to do the same thing as .each but instead of returning the original array, it returns the modified array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W2e0UykW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ayyc8mzw7m4rrsw53ylb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W2e0UykW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ayyc8mzw7m4rrsw53ylb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ybSk46Lq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y80xk6zf7ngwysxnokm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ybSk46Lq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y80xk6zf7ngwysxnokm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Got the same result as .each but without the additional lines to set up the empty array and adding the modified elements into the empty array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don't want to .map for some reason such as not liking the word "map", you can use .collect instead. It does the exact same thing as .map but is just named differently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gXIp2oEG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0e0bmx82goc5ue573o6p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gXIp2oEG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0e0bmx82goc5ue573o6p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ybSk46Lq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y80xk6zf7ngwysxnokm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ybSk46Lq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y80xk6zf7ngwysxnokm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Reduce / Inject&lt;/p&gt;

&lt;p&gt;A simple way of looking at .inject or .reduce is that they will sum up the numbers in a given array. What it actually does is that it takes an accumulator, in this case "sum" and iterates over each element "num" and return the sum of the two. At the end, it returns the value of the final iteration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_9fKRYvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kg3eo4egmhy7kou0p0zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_9fKRYvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kg3eo4egmhy7kou0p0zx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zr7foNTR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xtv1g77s2fn0h9jd2cnt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zr7foNTR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xtv1g77s2fn0h9jd2cnt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---n2WWkak--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nbifor0nyo3fjonhf8cd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---n2WWkak--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nbifor0nyo3fjonhf8cd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you call .inject or .reduce by itself, the default value is 0.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oEXUnVJB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hoyne5cp7m0bu8f4be7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oEXUnVJB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hoyne5cp7m0bu8f4be7u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HyckQGCD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4fuf81k90isl3dtbme1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HyckQGCD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4fuf81k90isl3dtbme1y.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_G4nr8LU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gkvo8d9rj3twezso66d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_G4nr8LU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9gkvo8d9rj3twezso66d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4) Find / Detect&lt;/p&gt;

&lt;p&gt;When you want to find a SINGLE element in an array, .find is the method to go. The .find method will return the FIRST element that matches the argument in the block.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c7Lc-6I3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xm31wsaykqgymf8ry57w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c7Lc-6I3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xm31wsaykqgymf8ry57w.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_LpocD2K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/atl7ehyg0pf8il3ruqxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_LpocD2K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/atl7ehyg0pf8il3ruqxd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also use .detect to get the same results. Same method, different names.&lt;/p&gt;

&lt;p&gt;5) Select&lt;/p&gt;

&lt;p&gt;.select in Ruby is known as filter in other languages. It's similar to .find in terms of looking for elements in an array that matches the argument in the block. The difference is .select, returns ALL of the elements that matches the argument and not just the first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--odFNQrmr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4ni8bkzhy0tldbs4h2ni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--odFNQrmr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4ni8bkzhy0tldbs4h2ni.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S95Qhd_c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ssu06o2728yb9759x50c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S95Qhd_c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ssu06o2728yb9759x50c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6) Reject&lt;/p&gt;

&lt;p&gt;A filter method that is the opposite of the .select method. This method returns the an array of the elements that does NOT match the arguments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--631n9q0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17swej15ehzpqyovquye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--631n9q0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17swej15ehzpqyovquye.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oBrVWhlG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hzhr5j43i91g5m1wasf3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oBrVWhlG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hzhr5j43i91g5m1wasf3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.reject is a nice method to know if you're too lazy to change the argument in .select&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mUOgFhPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zwnf44sf6snm07ogi99j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mUOgFhPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zwnf44sf6snm07ogi99j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H2Rglp-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zx8ytvmvk2vspfosq6dc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H2Rglp-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zx8ytvmvk2vspfosq6dc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It all comes down to personal preference of how you like to get things done.&lt;/p&gt;

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