<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jaime Montes de Oca on Medium]]></title>
        <description><![CDATA[Stories by Jaime Montes de Oca on Medium]]></description>
        <link>https://medium.com/@jaimemontesdeoca?source=rss-1beb00b971bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qEC-X3DaZKdrP9Xxt1h5Dg.jpeg</url>
            <title>Stories by Jaime Montes de Oca on Medium</title>
            <link>https://medium.com/@jaimemontesdeoca?source=rss-1beb00b971bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:44:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaimemontesdeoca/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create a controlled Form in React]]></title>
            <link>https://medium.com/@jaimemontesdeoca/create-a-controlled-form-in-react-dff837a46bcb?source=rss-1beb00b971bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff837a46bcb</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[controlled-component]]></category>
            <dc:creator><![CDATA[Jaime Montes de Oca]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 00:13:04 GMT</pubDate>
            <atom:updated>2022-07-04T00:13:04.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Controlled forms" src="https://cdn-images-1.medium.com/max/1024/1*_VRRFneXeRy7icZGM95n6w.png" /></figure><p>First, what is a <strong>controlled form</strong>? It is a form that derives its input values from state.</p><p>Let’s create a simple login form.</p><p>The first step to create a controlled form is to import the <strong>state hook </strong>from React.</p><pre>import React, { useState } from &#39;react&#39;</pre><p>In the component props, get the onSubmit function from the parent component.</p><pre>function Login({onSubmit}) {</pre><p>Next, define states for each input.</p><pre>const [email, setEmail] = useState(&quot;&quot;);<br>const [password, setPassword] = useState(&quot;&quot;);</pre><p>After that, create a function for submit.</p><pre>function handleSubmit(e) {<br>   e.preventDefault() ;<br>   <br>   const credentials = {<br>      email,<br>      password,<br>   };<br>   // Reset credentials to be empty in case they are incorrect<br>   setEmail(&quot;&quot;);<br>   setPassword(&quot;&quot;);<br>   // Check that user input is good by sending<br>   // request to the backend and **authenticating user**<br>   onSubmit(credentials)<br>}</pre><p>And last, use the state as the value of the inputs and in the onChange event.</p><pre>return (<br>  &lt;div&gt;<br>    &lt;h1&gt;Login&lt;/h1&gt;<br>      &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;label htmlFor=&quot;email&quot;&gt;Email:&lt;/label&gt;<br>    <br>      &lt;input<br>        autoFocus<br>        type=&quot;text&quot;<br>        id=&quot;email&quot;<br>        name=&quot;email&quot;<br>        <strong>value={email}<br>        onChange={(e) =&gt; setEmail(e.target.value)}</strong><br>        placeholder=&quot;Email&quot;<br>        required<br>      /&gt;<br>      &lt;label htmlFor=&quot;password&quot;&gt;Password:&lt;/label&gt;<br>      &lt;input<br>        type=&quot;password&quot;<br>        id=&quot;password&quot;<br>        name=&quot;password&quot;<br>        <strong>value={password}<br>        onChange={(e) =&gt; setPassword(e.target.value)}</strong><br>        placeholder=&quot;Password&quot;<br>        required<br>      /&gt;<br>      &lt;input className=&quot;submitButton&quot; type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;<br>    &lt;/form&gt;<br>  &lt;/div&gt;<br>)</pre><p>Every time the user types a character, we are updating the state causing a re-render for the input whose value/state has changed. This is a very important step because if not, the input is not going to reflect any character the user is typing.</p><p>Optional, add some basic CSS for displaying purposes…</p><pre>form {<br>    display: grid;<br>    gap: .5rem;<br>    grid-template-columns: auto 1fr;<br>    max-width: 300px;<br>    margin: 0 auto;<br>}</pre><pre>.submitButton {<br>    grid-column: span 2;<br>    background: #1f1c32;<br>    color: white;<br>}</pre><p>And this is the end result:</p><figure><img alt="Login component" src="https://cdn-images-1.medium.com/max/533/1*HMag5kTB_7FZSWx8mEur7w.png" /></figure><p>In conclusion, to setup a controlled form you need to follow this basic steps:</p><ol><li>Import the state hook.</li><li>Declare a state for each controlled component you need.</li><li>Use the state in the value and OnChange properties of the inputs.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff837a46bcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript: How to write your own Map method]]></title>
            <link>https://medium.com/@jaimemontesdeoca/javascript-how-to-write-your-own-map-method-999d17b4ec62?source=rss-1beb00b971bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/999d17b4ec62</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[objects]]></category>
            <dc:creator><![CDATA[Jaime Montes de Oca]]></dc:creator>
            <pubDate>Sun, 22 May 2022 03:06:30 GMT</pubDate>
            <atom:updated>2022-05-22T03:06:30.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Graphic image of the map method" src="https://cdn-images-1.medium.com/max/400/1*-gxePWHxqFX1iFfi0_nMtw.jpeg" /></figure><p>In JavaScript, arrays are used everywhere.</p><p>Fortunately for us, there are already a lot of functions that let us work with arrays in many useful ways and some of them are known as collection-processing methods, some of them are: map, reduce, find, filter, etc.</p><p>These are functions that allow us to process each and every element of the array and do something with it, it might be printing it, comparing it, summarizing it, you name it.</p><p>So, why would someone like to write their own function if they are already available in JavaScript “for free”? Well, and this is more relevant for novice programmers, there are two main advantages for practicing writing these functions by yourself.</p><ol><li>You will gain a deeper understanding of JavaScript’s built in collection-processing methods.</li><li>You will end this practice with a greater understanding of callback functions.</li></ol><p>Even though this article was written mostly for novice programmers, everyone can benefit of some extra practice if you try to do it.</p><p>We are going to write the <strong><em>map</em></strong> method and after that you can try to do the rest of the methods following a similar approach. According to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">MDN</a>,</p><p><em>“the map() method </em><strong><em>creates a new array</em></strong><em> populated with the results of </em><strong><em>calling a provided function on every element of the calling array</em></strong><em>”</em></p><p>There are two important items in this definition:</p><ol><li>Creates a new array</li><li>Calls a provided function</li></ol><p>That means our function needs to receive two parameters: an <strong>array</strong> and a <strong>function</strong>.</p><p>Let’s start defining our function:</p><p>function myMap(array, callback) {</p><p>}</p><p>First step accomplished! We are receiving the array in the parameter of the same name and the function we need to call for every element in the array in the variable named <em>callback</em>.</p><p>Now, after the function creates the new array, this array will be the return value of the function. Let’s add this:</p><pre>function myMap(array, callback) {<br>    const newArray = [];</pre><pre>    return newArray;<br>}</pre><p>And the last step should be <em>calling the provided function on every element of the calling array</em>.</p><pre>for (let i = 0; i &lt; array.length; i++) {</pre><pre>    newArray[i] = callback(array[i]);</pre><pre>}</pre><p>This way, we are taking each element of the array, calling the callback function sending this element as its argument and storing the result of that process, whatever it does, in the same position but in the newly created array. At the end of this for loop will have another array with same number of elements but having been processed by the callback function. This completes our own map method.</p><p>But because arrays and objects can use the same map method how can we modify our function to accept objects as well?</p><p>Before we do that, let’s change the declaration of our function to be more general and accept either an array or an object:</p><pre>function myMap(collection, callback) {</pre><p>This way, we now are making clear we are receiving a collection of elements, they can be an array or an object that is why we are changing the name of the first parameter. Now we can add this piece of code before processing the array.</p><pre>let array;</pre><pre>if (Array.isArray(collection)) {</pre><pre>    array = collection;</pre><pre>} else {</pre><pre>    array = Object.values(collection);</pre><pre>}</pre><p>Here, we are checking if the collection of elements is already an array there is nothing else to do except to assign the collection to our general variable array. If it is not an array, that means it is an object so we need to convert the values in the object to an array, we do that using the <em>values </em>method, it will return all the values in the object.</p><p>Note: As you can see, we are declaring the variable <em>array</em> outside the if statement; this is important because if we declare it inside, we are not going to be able to use it outside because its scope will be limited to the if statement.</p><p>Finally, our function is completed and it looks like this:</p><pre>function myMap(collection, callback) {</pre><pre>    let array;</pre><pre>    if (Array.isArray(collection)) {</pre><pre>        array = collection;</pre><pre>    } else {</pre><pre>        array = Object.values(collection);</pre><pre>    }</pre><pre>    const newArray = [];</pre><pre>    for (let i = 0; i &lt; array.length; i++) {</pre><pre>        newArray[i] = callback(array[i]);</pre><pre>    }</pre><pre>    return newArray;</pre><pre>}</pre><p>If we try our function sending an array as the first parameter:</p><pre>myMap([1, 2, 3], function(num){ return num * 3; });</pre><p>the output will be:</p><pre>[3, 6, 9]</pre><p>And if we can try it with an object:</p><pre>myMap({one: 1, two: 2, three: 3}, <br>      function(num, key){ return num * 3; });</pre><p>the output will be the same:</p><pre>[3, 6, 9]</pre><p>Now, you can go and try to write the rest of the collection-processing methods in a similar manner. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=999d17b4ec62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Software Development?]]></title>
            <link>https://medium.com/@jaimemontesdeoca/why-software-development-42385ac6f752?source=rss-1beb00b971bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/42385ac6f752</guid>
            <dc:creator><![CDATA[Jaime Montes de Oca]]></dc:creator>
            <pubDate>Mon, 11 Apr 2022 00:46:15 GMT</pubDate>
            <atom:updated>2022-04-11T00:46:15.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-MiWJPxpA7Rews1h0BMAHA.jpeg" /></figure><p><strong>Why Software Development?</strong></p><p>— -</p><p>It’s April 2022 and now I am here, living in the U.S. after moving from <strong>Mexico</strong> in 2009. After working at several jobs, I started working for <strong>Amazon</strong> just when the pandemic started. I heard that Amazon is a good company to work for and also offers a path to develop our careers beyond the company.</p><p>And I see it is true that Amazon offers opportunities to develop different skills through a program called <strong>Amazon Career Choice</strong>. Something caught my attention, they were offering training courses in technology fields and I have a special preference for that field. Therefore, I applied and got accepted in the program at a school called <strong>Flatiron School</strong> that offers a variety of programs. The programs available for us through Amazon Career Choice were <strong>Software Development</strong>, <strong>Cybersecurity</strong> and <strong>Data Science</strong>.</p><p>— -</p><p><strong>Why did I choose Software Development?</strong> Well, I am not really new to this field. Back to my life in Mexico, I went to college from 1988 to 1992, graduated with a degree in <strong>Computer Science</strong> and worked for a few companies including the <strong>State Government of Jalisco</strong>, my hometown state, until moved to the U. S. Consequently, I am not new to coding but instead I consider myself as as a learner of these current technologies that did not exist at that time while I was working in Mexico.</p><p>— -</p><p>As a consequence, I am taking this course to update my skills with the new technology we are using today, become more valuable for Amazon and the marketplace and probably get a position in the IT team or elsewhere outside Amazon, even though I will always be grateful to this company for the opportunities they have given me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42385ac6f752" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>