<?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 Lawson Hung on Medium]]></title>
        <description><![CDATA[Stories by Lawson Hung on Medium]]></description>
        <link>https://medium.com/@lawsonhung?source=rss-270b75b9c59f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1yb3HT2Om_O_QaM8</url>
            <title>Stories by Lawson Hung on Medium</title>
            <link>https://medium.com/@lawsonhung?source=rss-270b75b9c59f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:51:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lawsonhung/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[Swift: Class vs Struct]]></title>
            <link>https://lawsonhung.medium.com/swift-class-vs-struct-dfdf5a7bf691?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfdf5a7bf691</guid>
            <category><![CDATA[class]]></category>
            <category><![CDATA[struct]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sat, 16 Jan 2021 21:37:41 GMT</pubDate>
            <atom:updated>2021-01-16T21:37:41.569Z</atom:updated>
            <content:encoded><![CDATA[<p>Classes and Structs are very similar to one another. They both store data and model behavior.</p><h3>Similarities</h3><ul><li>They both define properties to store values. Much like a key-value pair in Hash Maps.</li><li>They both have initializers to create instances with initial values. Objects can be created with initialized values to start with.</li><li>They can both conform to protocols. Some protocols are specific to classes, so only classes can conform to that specific protocol, but otherwise both can conform to it.</li><li>They can be extended via extensions for inheritance from other classes/structs.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FXdDBcVRzNKbsxy4sQe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FXdDBcVRzNKbsxy4sQe%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FXdDBcVRzNKbsxy4sQe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3374d3a9cd79ef093614a9ea63fa5c4/href">https://medium.com/media/c3374d3a9cd79ef093614a9ea63fa5c4/href</a></iframe><h3>Class Specific Capabilities</h3><ul><li>Classes can inherit other classes characteristics.</li></ul><h3>The Difference</h3><p>The main difference between classes and structs is that classes are a <em>reference type,</em> and structs are <em>value type</em> objects. Let’s look at what this means in terms of code.</p><h4>Class</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TiS9Rn7aOn3zchSp.png" /></figure><p>Struct:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Bz1mhE98WjWvj1Dg.png" /></figure><p>The last line of code is what is the most important.</p><p>In <strong>class</strong>, cat.name prints “hound”, because the reference dog.name and cat.name both point to the same instance. So when dog is changed, cat is changed along with it. They both refer to the same object or instance that is created in RAM memory space, and refer to the same memory address.</p><p>In <strong>struct</strong> however, cat.name prints “dog”, even though dog.name has been reassigned to “hound”, because structs point to separate instances. A value type means that the value is copied at the time of assignment to a variable or constant, or when it’s passed to a function. They refer to separate instances however, which is the most important part to remember.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FtaqGYfOKH8Bbi%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FtaqGYfOKH8Bbi%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FtaqGYfOKH8Bbi%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e37606957c283186ba5a0c85c59396c/href">https://medium.com/media/1e37606957c283186ba5a0c85c59396c/href</a></iframe><h3>When to Use What</h3><h4>Classes</h4><p>Use a class when you want to control identity, or keep the reference to the same object. This ensures that the identity of the object will not change throughout the app. Sort of like a constant when comparing variables and constants.</p><h4>Structs</h4><p>You can use structs almost any time. Think of them as the variable when comparing variables and constants.</p><p>Some examples of structs: strings, arrays, numbers, dictionaries</p><p>We use structs when we don’t control identity. For instance, when you fetch data form servers, there may be times where the objects are the same, but since you’re not controlling identity, it’s best to use structs.</p><p>Reference:</p><p><a href="https://medium.com/quick-code/class-vs-struct-in-swift-f8c48eaacdba">Class vs Struct in Swift</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfdf5a7bf691" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Confusing LeetCode]]></title>
            <link>https://lawsonhung.medium.com/confusing-leetcode-c160b99f36f4?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c160b99f36f4</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sun, 11 Oct 2020 01:45:31 GMT</pubDate>
            <atom:updated>2020-10-11T01:45:31.981Z</atom:updated>
            <content:encoded><![CDATA[<p>For the record, I was not able to solve this LeetCode problem.</p><p>682. Baseball Game</p><p>You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds’ scores.</p><p>At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following:</p><ol><li>An integer x - Record a new score of x.</li><li>&quot;+&quot; - Record a new score that is the sum of the previous two scores. It is guaranteed there will always be two previous scores.</li><li>&quot;D&quot; - Record a new score that is double the previous score. It is guaranteed there will always be a previous score.</li><li>&quot;C&quot; - Invalidate the previous score, removing it from the record. It is guaranteed there will always be a previous score.</li></ol><p>Return <em>the sum of all the scores on the record</em>.</p><p><strong>Example 1:</strong></p><pre><strong>Input:</strong> ops = [&quot;5&quot;,&quot;2&quot;,&quot;C&quot;,&quot;D&quot;,&quot;+&quot;]<br><strong>Output:</strong> 30<br><strong>Explanation:</strong><br>&quot;5&quot; - Add 5 to the record, record is now [5].<br>&quot;2&quot; - Add 2 to the record, record is now [5, 2].<br>&quot;C&quot; - Invalidate and remove the previous score, record is now [5].<br>&quot;D&quot; - Add 2 * 5 = 10 to the record, record is now [5, 10].<br>&quot;+&quot; - Add 5 + 10 = 15 to the record, record is now [5, 10, 15].<br>The total sum is 5 + 10 + 15 = 30.</pre><p>This is the code I came up with:</p><pre>/**<br> * <a href="http://twitter.com/param">@param</a> {string[]} ops<br> * <a href="http://twitter.com/return">@return</a> {number}<br> */<br>var calPoints = function(ops) {<br>    let score = [];<br>    for(let i = 0; i &lt; ops.length; i++){<br>        if(ops[i] === &quot;+&quot;)<br>            score.push(ops[i-2] + ops[i-1]);<br>        else if (ops[i] === &quot;D&quot;)<br>            score.push(ops[i-1] * 2);<br>        else if (ops[i] === &quot;C&quot;)<br>            ops.splice(i-1, 2);<br>        else<br>            score.push(ops[i]);<br>    }<br>    <br>    console.log(score);<br>    <br>    return score;<br>};</pre><p>The instructions itself were very confusing. I tried to solve it to the best of my ability though by seeing if this solution worked. I compared each item in ops to + D or C to see if it should be added, doubled or canceled. Then I push it into ops according to the rules of this very weird baseball game.</p><p>There were comments that this solution did not warrant the best examples, since there were errors in the examples. I hope I don’t run into more Leetcode problems like this!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl1J9ymG81PZybeNeo%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl1J9ymG81PZybeNeo%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl1J9ymG81PZybeNeo%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="377" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdc287ba68f02f9c3b931cd338f6cbb7/href">https://medium.com/media/cdc287ba68f02f9c3b931cd338f6cbb7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c160b99f36f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Component Lifecycle]]></title>
            <link>https://lawsonhung.medium.com/react-component-lifecycle-72c16b96bbcb?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c16b96bbcb</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Fri, 02 Oct 2020 19:05:32 GMT</pubDate>
            <atom:updated>2020-10-02T19:05:32.917Z</atom:updated>
            <content:encoded><![CDATA[<p>This was something I had learned before, but was struggling to really memorize so I thought I’d blog about it.</p><p><a href="https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/">React Lifecycle Methods diagram</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nr7VvsZVzMOl73H6.png" /></figure><p>I was just confused about when render would fire. As you can tell from the diagram, render fires before componentDidUpdate and componentDidMount.</p><p>Render also fires when passed new props or the state is set again. This diagram is pretty helpful for me to understand when render is fired, so I know what to put in there. forceUpdate is something I heard I should not use unless absolutely necessary, which is basically almost never.</p><p>That’s all for this week! Stay safe, maintain social distancing, wear a mask and wash your hands often!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F2h8BdeXxhGGB2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F2h8BdeXxhGGB2%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F2h8BdeXxhGGB2%2F200.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="301" frameborder="0" scrolling="no"><a href="https://medium.com/media/efcfaa7a3467263d328de4bb8c7eaba4/href">https://medium.com/media/efcfaa7a3467263d328de4bb8c7eaba4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c16b96bbcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript 30–30 Day Challenge]]></title>
            <link>https://lawsonhung.medium.com/javascript-30-30-day-challenge-13914adf48f8?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/13914adf48f8</guid>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 01:06:01 GMT</pubDate>
            <atom:updated>2020-09-27T01:06:01.275Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://javascript30.com/">JavaScript 30</a></p><p>JavaScript 30 is a 30 day challenge that pushes you to write code, perfect for beginners. I came upon this from my career coach, and found it super helpful. It teaches you how to write JavaScript and gives you a template to follow along with, along with a 1-to-1 solution of what’s in the video to follow along to. This is perfect for bootcamp grads who want to boost up their JavaScript.</p><p>This was just a quick post about this awesome resource!</p><p>Gear up, stay safe, you’re going back in! Stay safe everyone!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1hoNF06qLj0AehQrUE%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1hoNF06qLj0AehQrUE%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F1hoNF06qLj0AehQrUE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="414" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e35b950dc89616feb5d7129d768e971/href">https://medium.com/media/9e35b950dc89616feb5d7129d768e971/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13914adf48f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Components Rendering Twice in Development]]></title>
            <link>https://lawsonhung.medium.com/react-components-rendering-twice-in-development-7d2308c13b2b?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d2308c13b2b</guid>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[render]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sat, 19 Sep 2020 01:27:53 GMT</pubDate>
            <atom:updated>2020-09-19T01:27:53.773Z</atom:updated>
            <content:encoded><![CDATA[<p>This drove me nuts! I could not for the life of me figure out why my components were rendering twice. Marios however summed it up pretty well.</p><p><a href="https://mariosfakiolas.com/blog/my-react-components-render-twice-and-drive-me-crazy/">My React components render twice and drive me crazy</a></p><p>He talks about why it renders twice, and the main reason is that React.StrictMode is trying to help you debug.</p><p>Rest assured, this only happens in development and doesn’t happen in production. Still, this bug drove me nuts for a while because I could not for the life of me figure out why everything was rendering twice!!! A real hair-puller for sure.</p><p>I highly recommend giving his blog a quick read because it definitely helped me understand why my components were rendering twice in development. rest assured though, this is not a bug and is intended for debugging purposes with React.StrictMode.</p><p>Cheers! Now you can sleep well.</p><p>Stay safe y’all!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FKENUND3gyffxvoi2wH%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FKENUND3gyffxvoi2wH%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FKENUND3gyffxvoi2wH%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="318" frameborder="0" scrolling="no"><a href="https://medium.com/media/29f6cd32735dfad7559f1bbc8577d8b1/href">https://medium.com/media/29f6cd32735dfad7559f1bbc8577d8b1/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d2308c13b2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Redux: Removing From an Array]]></title>
            <link>https://lawsonhung.medium.com/react-redux-removing-from-an-array-a440647d9f4b?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a440647d9f4b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 22:00:06 GMT</pubDate>
            <atom:updated>2020-09-12T22:00:06.017Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, I talked about how to add to an array in Redux. This week, to build upon and complement that, I’ll be talking about how to remove an item from an array. It’s not as easy as it may sound. It took me some Googling to find the answer to this question.</p><p>This is our initial state:</p><pre>state={</pre><pre>title: &#39;&#39;,</pre><pre>resultCt: 0,</pre><pre>searchResults: {},</pre><pre>nominations: []</pre><pre>}</pre><p>And we’re trying to change nominations . Given the nomination index in the array, this is how we would remove an item in nominations:</p><pre>case &#39;REMOVE_NOMINATION&#39;:</pre><pre>return {</pre><pre>...state,</pre><pre>nominations: [</pre><pre>...state.nominations.slice(0, action.nominationIndex),</pre><pre>...state.nominations.slice(action.nominationIndex + 1)</pre><pre>]</pre><pre>}</pre><p>We have to spread ... the state, then slice it up to the nomination index, and concatenate it with the other half of nominations, sliced 1 more from the nomination index up until the end.</p><p>Usually, removing an item is pretty easy to do. For redux though, this was not the case. It was quite difficult to understand how to remove an item, but at least I now know how to do it.</p><p>That’s it. Stay safe everyone!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FWP2MUeauAM3sLbOQyQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FWP2MUeauAM3sLbOQyQ%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FWP2MUeauAM3sLbOQyQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/4767beb7da597123e890f9b5850944d9/href">https://medium.com/media/4767beb7da597123e890f9b5850944d9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a440647d9f4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Redux: Adding to Arrays]]></title>
            <link>https://lawsonhung.medium.com/react-redux-adding-to-arrays-631a3983a497?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/631a3983a497</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 00:45:25 GMT</pubDate>
            <atom:updated>2020-09-06T00:45:25.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey all! Another week for me as I complete a coding challenge sent by Shopify. This is my initial state:</p><pre>state={</pre><pre>title: &#39;&#39;,</pre><pre>resultCt: 0,</pre><pre>searchResults: {},</pre><pre>nominations: []</pre><pre>}</pre><p>Here, I want to add to nominations which is initiated as an empty array.</p><p>I tried state.nominations.push(action.nominations) which was my first thought that came to mind, but that didn’t work. Instead, I have to do the following:</p><pre>case &#39;STORE_NOMINATION&#39;:</pre><pre>return {</pre><pre>...state,</pre><pre>nominations: [...state.nominations, action.nominations]</pre><pre>}</pre><p>I have to spread the state first with ...state and then I have to set nominations to a new array, spreading the original state with ...state.nominations and then appending action.nominations to the end.</p><p>This worked wonders and it took me a while (as in maybe a day or so… haha) to get to work properly.</p><p>That’s all for this week, folks! I look forward to our next talk.</p><p>Stay safe everyone!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FT9LE9yLuTqmAFdxkbG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FT9LE9yLuTqmAFdxkbG%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FT9LE9yLuTqmAFdxkbG%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="250" frameborder="0" scrolling="no"><a href="https://medium.com/media/17787c4ab627cf26355f1560996c8209/href">https://medium.com/media/17787c4ab627cf26355f1560996c8209/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=631a3983a497" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode: Jewels and Stones]]></title>
            <link>https://lawsonhung.medium.com/leetcode-jewels-and-stones-12295b10c591?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/12295b10c591</guid>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sun, 30 Aug 2020 01:59:38 GMT</pubDate>
            <atom:updated>2020-08-30T01:59:38.993Z</atom:updated>
            <content:encoded><![CDATA[<p>This week is just a rundown on a Leetcode problem I went through.</p><p><a href="https://leetcode.com/problems/jewels-and-stones/">Jewels and Stones - LeetCode</a></p><p>Here’s the solution:</p><pre>/**<br> * <a href="http://twitter.com/param">@param</a> {string} J<br> * <a href="http://twitter.com/param">@param</a> {string} S<br> * <a href="http://twitter.com/return">@return</a> {number}<br> */<br>var numJewelsInStones = function(J, S) {<br>    let jewels = J.split(&quot;&quot;);<br>    let stones = S.split(&quot;&quot;);<br>    let ans = 0;<br>    <br>    for(let i = 0; i &lt; jewels.length; i++){<br>        for(let j = 0; j &lt; stones.length; j++){<br>            // if (jewels[i] === stones[j]){<br>            //     ans++;<br>            // }<br>            (jewels[i] === stones[j]) ? ans++ : null;<br>        }<br>    }<br>    <br>    return ans;<br>    <br>//     let ans = 0;<br>    <br>//     for(let char of S){<br>//         // J contains char stone<br>//         // Chars is J are distinct from one another<br>//         if (J.lastIndexOf(char) &gt; -1){<br>//             ans++;<br>//         }<br>//     }<br>    <br>//     return ans;<br>};</pre><p>It’s a fairly simple bit. The question at hand was:</p><p>You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.</p><p>The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so &quot;a&quot; is considered a different type of stone from &quot;A&quot;.</p><p><strong>Example 1:</strong></p><pre><strong>Input:</strong> J = &quot;aA&quot;, S = &quot;aAAbbbb&quot;<br><strong>Output:</strong> 3</pre><p><strong>Example 2:</strong></p><pre><strong>Input:</strong> J = &quot;z&quot;, S = &quot;ZZ&quot;<br><strong>Output:</strong> 0</pre><p>I first split jewels and stones into an array so I could work with them. I then have 2 for loops to see if jewels were in stones and vice versa. If they were, I add 1 to the answer.</p><p>This is a fairly simple question, one that’s easy to talk about in a pair programming interview. I may use this same question in an upcoming practice interview with some fellow job searchers.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl3vRawYAnO8dUf1ra%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3vRawYAnO8dUf1ra%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl3vRawYAnO8dUf1ra%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/60c65f40e24d52c17c28847a1af8a877/href">https://medium.com/media/60c65f40e24d52c17c28847a1af8a877/href</a></iframe><p>Stay safe and stay cool everyone! Practice good social distancing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12295b10c591" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Github Featured Readme]]></title>
            <link>https://lawsonhung.medium.com/github-featured-readme-9f4c8a07dc9f?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f4c8a07dc9f</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[readme]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sat, 22 Aug 2020 01:30:11 GMT</pubDate>
            <atom:updated>2020-08-22T01:30:11.913Z</atom:updated>
            <content:encoded><![CDATA[<p>I found out recently that you can have a featured section in your Github.</p><p><a href="https://www.aboutmonica.com/blog/how-to-create-a-github-profile-readme">https://www.aboutmonica.com/blog/how-to-create-a-github-profile-readme</a></p><p>For example, from Monica:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z1vyyuwdtOy93k15.gif" /></figure><p>To do this, it’s pretty simple. Just make a repository and make sure you name it exactly as your Github username, case sensitive. Github will tell you that this is a secret repository just for you!</p><p>They’ll even give you some recommendations to start you off on the right foot.</p><p>Here’s mine for reference:</p><p><a href="https://github.com/lawsonhung">lawsonhung - Overview</a></p><p>Remember that a Readme is in .md, or markdown format, meaning you can put GIFs in there as well as emojis.</p><p>That is all folks! Have a good one and see you all next time! Stay safe, take care, we’re going back in!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLr4MuiBF2QPx2E0foV%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLr4MuiBF2QPx2E0foV%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FLr4MuiBF2QPx2E0foV%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="562" frameborder="0" scrolling="no"><a href="https://medium.com/media/68c526d6fa0d7ecdcebe21f5bf292f76/href">https://medium.com/media/68c526d6fa0d7ecdcebe21f5bf292f76/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f4c8a07dc9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Challenge]]></title>
            <link>https://lawsonhung.medium.com/code-challenge-9779de07b3e2?source=rss-270b75b9c59f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9779de07b3e2</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[clean-code-challenge]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[code-challenge]]></category>
            <dc:creator><![CDATA[Lawson Hung]]></dc:creator>
            <pubDate>Sun, 16 Aug 2020 02:00:46 GMT</pubDate>
            <atom:updated>2020-08-16T02:00:46.544Z</atom:updated>
            <content:encoded><![CDATA[<p>I had my first code challenge in a while from Codecademy. I’m pretty excited about this opportunity. I quickly opened the email from Codecademy, anticipating the chance to get to write some valuable code. They said that the code challenge should take a recommended 2–3 hours. Little did I know… I’d be spending about an entire week on it. Good thing I started early though.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7TKRwpns23QMNNiE%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7TKRwpns23QMNNiE%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3o7TKRwpns23QMNNiE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="299" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b55bbb2e8eb1e0343541066c72eab23/href">https://medium.com/media/8b55bbb2e8eb1e0343541066c72eab23/href</a></iframe><p>I definitely was stressed out during parts of it. Overall though, I had quite a bit of fun. We just had to make a quiz using data that they prepared for us.</p><p>This was a toughie but I managed to pull through. I ran into a bug getting React to render properly, but I wasn’t able to solve it and I’ll just have to submit my code and really hope for the best.</p><p>I looked at the grading requirements and I should have a 3 on most of the requirements.</p><p>This post is a bit less technical and more of me ranting a bit about the code challenge. Hope y’all stay safe and sound!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9779de07b3e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>