<?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 Yura Choi on Medium]]></title>
        <description><![CDATA[Stories by Yura Choi on Medium]]></description>
        <link>https://medium.com/@yurachoi?source=rss-728f28e71b04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*attKE_MtogJBHA2o.</url>
            <title>Stories by Yura Choi on Medium</title>
            <link>https://medium.com/@yurachoi?source=rss-728f28e71b04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:42:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yurachoi/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[[JavaScript] Wandering through the fuzziness of a fuzzy search library, Fuse.js]]></title>
            <link>https://medium.com/@yurachoi/javascript-wandering-through-the-fuzziness-of-a-fuzzy-search-library-fuse-js-dd8be246dd0e?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd8be246dd0e</guid>
            <category><![CDATA[fuzzy-matching]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[js-libraries]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 00:35:42 GMT</pubDate>
            <atom:updated>2019-01-27T00:38:38.112Z</atom:updated>
            <content:encoded><![CDATA[<p>I admit it’s been ages since I wrote something on Medium. Firstly, I was thrilled to find out that Medium now supports magic link as a mode of signing in since the company I work at has also recently adopted that process. Speaking of which, during the times I haven’t been writing (a.k.a. year 2018) and have been working full time, I learned a ton and doubtlessly grew as a developer. Inevitably I’ve had my impostor moments, which also must have contributed to the expansion of my knowledge and gratification. I am still learning every day and am thankful that I have the resources to do so.</p><p>To cut to the chase: although I’ve been on hiatus from writing, I could not hold back from sharing what I am about to share today. I recently worked with <a href="http://fusejs.io/">Fuse.js</a>, a fuzzy search library that filters out typos, unclear input, etc. as you type in, and returns the closest matches from your data set. When reading and implementing the document, everything seemed intuitive and the options described were all useful; however there was a blocker, very specific to a piece of my data set, and Google didn’t have a solution. So here I am.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*ir2GxDxW44J8YsRp4vwSoQ.gif" /></figure><p>I lied! Of course Google offered me some clues that led to my solution. But first and foremost, <a href="https://stackoverflow.com/questions/46423387/fuse-js-with-nested-data-returns-wrong-id">here</a> is a post from StackOverflow of the problem I was experiencing, written by David Lamm. I was half excited that the OP was having the exact same issue as mine, and half frustrated that the fix was nowhere to be found.</p><p>So Fuse.js allows you to set options. ID is one of its options, and basically whatever ID you give, it becomes the key to the value of the result you want. The document reads:</p><blockquote>“[ID is] the name of the identifier property. If specified, the returned result will be a list of the items’ identifiers, otherwise it will be a list of the items. See <a href="http://fusejs.io/#searching-by-id">example</a>.”</blockquote><p><strong>Dilemma:</strong> examples provided in the document don’t take nested hashes with multiple keys into account. Let me use the data shared by the OP as an example as it closely mirrors my data (indented for my convenience):</p><pre>[{&quot;cabinets&quot;:[<br>  {&quot;cabinet&quot;:&quot;A4&quot;,<br>      &quot;items&quot;:[{<br>       &quot;title&quot;:&quot;Toys&quot;,<br>       &quot;keywords&quot;:&quot;leksaker, pingpong, kendama, pingis&quot;,<br>       &quot;id&quot;:&quot;98&quot;<br>     }, {<br>       &quot;title&quot;:&quot;Skisch Grand Prix&quot;,<br>       &quot;keywords&quot;:&quot;Pokal, cup, pris, skisch&quot;,<br>       &quot;id&quot;:&quot;99&quot;<br>     }, {<br>       &quot;title&quot;:&quot;Lamp prototype&quot;,<br>       &quot;keywords&quot;:&quot;lamp-prototyp&quot;,<br>       &quot;id&quot;:&quot;100&quot;<br>     }<br>   ]},<br>  {&quot;cabinet&quot;:&quot;B4&quot;,<br>      &quot;items&quot;:[{<br>       &quot;title&quot;:&quot;Screens (LCD)&quot;,<br>       &quot;keywords&quot;:&quot;skärm display&quot;,<br>       &quot;id&quot;:&quot;30&quot;<br>      }, {<br>       &quot;title&quot;:&quot;Displays&quot;,<br>       &quot;keywords&quot;:&quot;screen skärm&quot;,<br>       &quot;id&quot;:&quot;31&quot;<br>      }, {<br>       &quot;title&quot;:&quot;Lampor&quot;,<br>       &quot;keywords&quot;:&quot;&quot;,<br>       &quot;id&quot;:&quot;32&quot;<br>      }<br>   ]}<br>]}]</pre><p><strong>Goal:</strong> typing in “Displays” returns all id’s (including “31”), whose title and keywords values contain some or all parts of the string “Displays”, assuming that the options id is set to “item.id” and keys are set to [“items.title”, items.keywords”] as described by the OP</p><p><strong>Error</strong>: when “Displays” is typed in, it returns “30” which is the id of the first item</p><p><strong>What I think I know</strong>: The filtering function seems to work properly as it is accessing the correct array index where the desired result lies (cabinet B4). When I played around with this by adding more cabinet data to it (say C4, D4, E4, and so on…) the pattern persists where only the id of the first item is returned despite multiple instances of the word “display.”</p><p><strong>Next step: dissect the library.</strong></p><p>Take a look at <em>fuse.js</em> and <em>fuse.map.js</em> files. In your project directory,</p><blockquote>$ npm install fuse.js</blockquote><blockquote>$ cd node_modules</blockquote><blockquote><em>$ cd fuse.js</em></blockquote><blockquote><em>$ cd dist</em></blockquote><p>Open the folder in your text editor, and scan the files mentioned above for yourself. It certainly took me some time, but towards the end of both files I spotted this:</p><pre>if (this.options.id) {<br>  result.item = this.options.getFn(result.item, this.options.id)[0];<br>}</pre><p>All this time, if I had given an id in my options hash, whatever this.options.getFn grabs, only the item at index 0 was being stored as result.item. A few lines down, result.item gets stored in a data hash like this:</p><pre>var data = {<br>  item: result.item<br>};</pre><p>and eventually this happens:</p><pre>finalOutput.push(data);<br>return finalOutput;</pre><p>As you could have guessed, finalOutput is the outcome of fuse.search(input); .</p><p>If you’ve been stuck on the same problem and have read this far, now is your chance to make the world’s best lemonade out of this javascript flavored lemon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*oiPY5uODh1ZRLV9sdF0ZPA.gif" /></figure><p>Depending on one’s goals, one can rearrange the chunk of code above in various ways. To best suit my needs, I only altered this part where I substituted the result item at index 0 with “results”:</p><pre>if (this.options.id) {<br>  result.item = results;<br>}</pre><p>Then, I wrote additional javascript functions that took in some properties as a parameter, and looped through the results until my desired outcome is returned. If you’d like, console.log() the results and see what it returns. I mostly utilized values that were nested inside the “output” key, which you also might find useful.</p><p>One of the mysterious strengths I’ll never get over about programming is that **cliché warning** just when I think it’s impossible, I find a way. You know what I mean.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd8be246dd0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[React.JS] <> Fragments? </>]]></title>
            <link>https://medium.com/@yurachoi/react-js-fragments-175290da6435?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/175290da6435</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[fragments]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Wed, 29 Nov 2017 19:30:28 GMT</pubDate>
            <atom:updated>2017-11-29T19:30:28.345Z</atom:updated>
            <content:encoded><![CDATA[<p>The newest version of React, React v.16.2.0, has been launched this week. The most prominent feature of this version is Fragments. For those of you who have been working on projects using React, you may be familiar with wrapping your child components using &lt;div&gt; or &lt;span&gt; in your render():</p><pre>render(){<br>   return(<br>      &lt;div&gt;<br>        &lt;Navbar/&gt;<br>        &lt;h2&gt; Heading &lt;/h2&gt;<br>      &lt;/div&gt;<br>   );<br>}</pre><p>If you don’t wrap your child components using those tags, then you’d face a syntax error message reminding you that adjacent JSX elements must be wrapped in an enclosing tag. Essentially, you can’t return more than once at a time in a method call, and you can’t return nothing either, so using &lt;div&gt; or &lt;span&gt; tags has been necessary when working with React.</p><p>At the end of the day, however, we’re all trying to avoid expensive DOM operations and make our code as efficient as possible. With this updated version of React, you can return your child components without adding extra nodes to the DOM using Fragments.</p><p>Fragment is a first-class component that you can use to wrap your child components and elements in place of &lt;div&gt; or &lt;span&gt; tags:</p><pre>render(){<br>   return(<br>      &lt;Fragment&gt; <br>        &lt;Navbar/&gt;<br>        &lt;h2&gt; Heading &lt;/h2&gt;<br>      &lt;/Fragment&gt;<br>   );<br>}</pre><p>or</p><pre>render(){<br>   return(<br>      &lt;React.Fragment&gt;<br>        &lt;Navbar/&gt;<br>        &lt;h2&gt; Heading &lt;/h2&gt;<br>      &lt;/React.Fragment&gt;<br>   );<br>}</pre><p>If your child in an array or iterator asks for key props, you can use that attribute, and only that attribute, by passing it directly to &lt;Fragment /&gt; :</p><pre>render(){<br>   return(<br>      &lt;dl&gt;<br>        {props.list.map(item =&gt;(<br>           &lt;Fragment key={item.id}&gt;<br>             &lt;dt&gt;{item.name}&lt;/dt&gt;<br>             &lt;dd&gt;{item.description}&lt;/dd&gt;<br>           &lt;/Fragment&gt;<br>         )<br>      )}<br>      &lt;/dl&gt;<br>   );<br>}</pre><p>If you don’t need to pass any attributes / keys, you can also use empty tags &lt;&gt;&lt;/&gt; to indicate a fragment:</p><pre>render(){<br>   return(<br>      &lt;&gt;<br>        &lt;Navbar/&gt;<br>        &lt;h2&gt; Heading &lt;/h2&gt;<br>      &lt;/&gt;<br>   );<br>}</pre><p>Ready for this update / want to find out more about other supporting ingredients? Visit <a href="https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html">here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=175290da6435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[JavaScript] ‘this’ part 1]]></title>
            <link>https://medium.com/@yurachoi/javascript-this-part-1-2264f2c6ea97?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/2264f2c6ea97</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[this]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Mon, 27 Nov 2017 04:33:52 GMT</pubDate>
            <atom:updated>2018-01-09T17:02:14.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Another concept of JavaScript that I often brush up on is <strong>this</strong>. Because <strong>this is not </strong>defined at assignment, it sometimes gets tricky to figure out exactly which scope <strong>this</strong> is referring to. Let’s dive into an example:</p><pre>this.holiday = &quot;Thanksgiving&quot;;</pre><pre>console.log(window.holiday) // &quot;Thanksgiving&quot;<br>console.log(holiday) // &quot;Thanksgiving&quot;</pre><p>In order to dissect the usage of <strong>this</strong> , it’s important to know which context it is used in. There may be two cases: global context and function context. In the example above, <strong>this</strong> is used in a global or window context. When the scope of the execution is global, not inside of any function, <strong>this</strong> refers to the global object like the above example.</p><p>In the example below, however, the context of <strong>this</strong> varies. For any usage of <strong>this</strong> within a function, the value gets defined at execution. In other words, implication of <strong>this</strong> might change depending on how a function is called.</p><pre>var length = 7;</pre><pre>function printLength(){</pre><pre>console.log(this.length);</pre><pre>}</pre><pre>var myObj = {</pre><pre>   length: 3,<br>   method: function(anyFunction){<br>      printLength();<br>      arguments[0]();<br>   }</pre><pre>}</pre><pre>myObj.method(printLength, 1) // 7, 1</pre><p>At first, when function printLength is passed as a parameter to the function method, the scope of <strong>this</strong>of the function printLength is window. Variable length has been declared and assigned to number 7at the window level, which also can be accessed as window.length or length or this.length (when this === window).</p><p>Method is bound to object myObj, and myObj.method is called with parameters printLength and 1. Though method function is accepting only one argument, while invoking it has passed two arguments, a callback function and a number. Remember in JavaScript multiple arguments can be passed!</p><p>When printLength() is called inside method, which passed the function as a parameter at the global level, this.length will have access to var length = 7 (declared globally), not length with the value of 3 as defined in Object myObj scope.</p><p>Now, in JavaScript functions, we have access to any number of arguments using the arguments[] array. Argument at index 0 is nothing but calling the first function that was passed in, which was printLength(). Inside printLength now, the scope of this function becomes the arguments array. Therefore executing myObj.method(printLength, 1) will log, after 7, the length of arguments which is 2.</p><p>There are several ways to bind the context of <strong>this</strong>, such as the .call and .apply methods, .bind method, and using arrow functions. I will save that for another blog post :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2264f2c6ea97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[JavaScript] All About Hoisting]]></title>
            <link>https://medium.com/@yurachoi/javascript-all-about-hoisting-3a101a098b6d?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a101a098b6d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Sun, 19 Nov 2017 17:24:19 GMT</pubDate>
            <atom:updated>2017-11-19T17:24:19.787Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether you are just starting to learn JavaScript or have been an expert for a while, hoisting is a tricky (and one of my favorite) concept that’s worth mastering. As an active job seeker at the moment, I have been focusing on solidifying my JavaScript knowledge in preparation for technical interviews. Read on if you would like to get a sense of hoisting in JavaScript!</p><p>First and foremost, let’s briefly go over how scoping works in JavaScript. Refreshing this concept beforehand may help understanding hoisting in the later part of this article.</p><p>Remember the difference between var and let?</p><pre>// SCOPE STARTS HERE</pre><pre>var x = &quot;hey&quot;</pre><pre>console.log(x) // &quot;hey&quot;</pre><pre>{<br>   var x = &quot;nay&quot;<br>   <br>   console.log(x) // &quot;nay&quot;</pre><pre>}</pre><pre>console.log(x) // &quot;nay&quot;<br>// SCOPE ENDS HERE</pre><p>When using var, block statements such as above do not generate a scope. Since the second assignment isn’t happening in a new scope, both variables are still lying in the same scope. In other words, when assigning “nay” to var x, the value of x is getting re-assigned from “hey” to “nay”.</p><pre>// THIS IS THE FIRST SCOPE</pre><pre>let x = &quot;hey&quot;</pre><pre>console.log(x) // &quot;hey&quot;</pre><pre>{<br>// SECOND SCOPE STARTS</pre><pre>    let x = &quot;nay&quot;</pre><pre>    console.log(x) // &quot;nay&quot;</pre><pre>// SECOND SCOPE ENDS</pre><pre>}</pre><pre>console.log(x) // &quot;hey&quot;<br>// FIRST SCOPE ENDS HERE</pre><p>Here, however, we’re using let to declare and initialize x. As you can see, using let creates a new scope in the block statement. Unlike the previous example, logging the value of x outside of the block will give us whatever x was assigned to in the outer scope. This time, x is not getting re-assigned, but is getting assigned at two different times.</p><p>That wasn’t so bad! So what was all this about? Well, let’s (finally) look at the definition of hoisting in JavaScript.</p><blockquote><strong>Hoisting</strong> is the <strong>JavaScript</strong> interpreter’s action of moving all variable and function declarations to the top of the current scope.</blockquote><blockquote>Source: <a href="https://www.sitepoint.com/back-to-basics-javascript-hoisting/">https://www.sitepoint.com/back-to-basics-javascript-hoisting/</a></blockquote><p>Although this is a controversial definition of hoisting, let’s use it for the sake of grasping the concept. I will write more about why this could be a misleading definition later on; however, it works for now.</p><p>Without further ado, let’s look at a simple example of hoisting:</p><pre>console.log(x) // undefined</pre><pre>var x = &quot;hey&quot;</pre><p>Here we’re trying to log x before we declare and assign the value of x. Surprisingly, instead of throwing us a ReferenceError: x is not defined, this example logs undefined. This is because hoisting in JavaScript “moves” declarations to the top of the current scope. So even though console.log(x) precedes the declaration and initialization of x, JavaScript captures our code as a whole and recognizes that x has been declared as a variable somewhere in the code. Another point to catch here is that only the declaration is hoisted, not the assignment. Hence the value of x remains undefined, but we know it’s been declared.</p><pre>console.log(y) // ReferenceError: t is not defined</pre><pre>let y = &quot;what?&quot;</pre><p>This example is very simple and similar to the one above. The only difference is that let is used in place of var. However, this time, it does not seem like the declaration has been hoisted. According to MDN,</p><blockquote>In ECMAScript 2015, <strong>let</strong> bindings are not subject to <strong>Variable Hoisting</strong>, which means that <strong>let</strong> declarations do not move to the top of the current execution context. Referencing the variable in the block before the initialization results in a <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError">ReferenceError</a> (contrary to a variable declared with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting">var</a>, which will just have the undefined value). The variable is in a &quot;temporal dead zone&quot; from the start of the block until the initialization is processed.</blockquote><blockquote>Source: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let">https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Statements/let</a></blockquote><p>Another rule to remember is that functions are declared and defined at the same time, so both the declaration and assignment are processed beforehand for functions. Look at this example:</p><pre>greetings(); // &quot;Hi&quot;</pre><pre>function greetings(){<br>   console.log(&quot;Hey&quot;)<br>}</pre><p>So, what is really happening when functions and variables get hoisted? We said they are “moving” to the top of the execution context, but that was said to only make our understanding easier. What’s happening is that the declarations are getting put into memory during the compilation!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a101a098b6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I got 1100011 problems but a bit ain’t one!]]></title>
            <link>https://medium.com/@yurachoi/i-got-1100011-problems-but-a-bit-aint-one-72e9de535d2e?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/72e9de535d2e</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[binary]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Sun, 17 Sep 2017 20:55:56 GMT</pubDate>
            <atom:updated>2017-09-17T20:55:56.273Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever since I began learning about computer principles, I knew the existence of ‘binary’, composed of a bunch of 1’s and 0’s, and that it was somehow related to the machine I use called ‘computer.’ Somewhere along the way I was also told that these numbers represent bytes, but had never attempted to wrap my head around the concept — especially because I don’t get along well with numbers. However, now that I’m in the last module of the program at Flatiron School, I know better than to avoid my problems. So I decided to face the music and do some research on the basic building blocks of computer. Better late than never… right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*BcOUj0kJPELq94KO8slYmA.jpeg" /></figure><p>Let’s travel back in time when computers were first built. Back in the day, we could solely enter the data by flicking switches on and off, or by feeding in punched cards. Our modern computers now have billions of switches called “transistors” operated by electricity instead of our hands. Transistor can be turned on by applying electrical current, and electricity can flow through the transistor just as it does when a light switch is on. Will this sound more applicable if I mention that iPhone 7 has over 3,300,000,000 transistors?</p><h3>What is Binary?</h3><p>In plain English, binary means “relating to, composed of, or involving two things.” In the world of computing, binary digit, or bit, refers to the smallest unit of data represented by the digits 0 and 1 — hence the “two things.” If you haven’t guessed already, the digits 1 and 0 in binary each exhibits the on and off state of a transistor. In the past, a hole would have corresponded to 1 and no hole would have corresponded to 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Um-qKrB2QLxRU0C8CkCCeg.png" /></figure><p>This number system is different from what humans are familiar with today — decimal. In decimal, ten digits from 0 to 9 are used as opposed to just two digits of 0 and 1 in binary.</p><p>Let’s consider the number ‘14’ in decimal for example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aGt6b78NSIreIzw-QhUQ1A.png" /><figcaption>I used candy canes to demonstrate number 14 in decimal to celebrate only 99 days until Christmas!</figcaption></figure><p>The number 14 in decimal is composed of 1 lot of ten and 3 lots of one. There is 1 lot of 10 candy canes in the first column, and 4 lots of 1 candy cane in the second column, adding up to a total of 14 candy canes.</p><p>Let’s take a look at the same value but in binary instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arsVGXAyl3_UbXnWrMGG5Q.png" /></figure><p>Here, you can see that binary also has columns similar to the ones in decimal, only with different folds. Instead of increasing by 10 as we go left, it now increases by 2. So the number 14 is now composed of 1 lot of 8, 1 lot of 4, 1 lot of 2, and 0 lot of 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oTvYAKGgNyPRbFcOtKenOA.png" /></figure><p>Since the binary system allows a number to be represented as a string of 1’s and 0’s, the number 14 can be written in binary as 1110, or as on-on-on-off in electric signals.</p><h3>How is this relevant?</h3><p>As I just mentioned, in binary, a successive column has twice the value of its previous column. One column, or one digit of either 0 or 1 represents a “bit.” 8 of those bits come together to make a byte.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*ZTk7rze1w_rBNL7b-ShCrA.png" /><figcaption>| 128s | 64s | 32s | 16s | 8s | 4s | 2s | 1s |</figcaption></figure><p>Then, these bytes are grouped to form even larger structures such as music, texts, and photographs that we see in our computers, stored as binary code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ss0sZjEjUcdYjZNx6UEPfg.png" /></figure><p>Here is a visual example from a really great YouTube video on binary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OYKBHT_IW7KnDKdeD2NtQ.png" /></figure><p>Take a look at the color magenta. The full strengths of Red and Blue and none of Green make up Magenta. We now know how to convert those numbers into binary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RDONMfSv7ijtByelWROYMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*B5jYRIW_3bLh-lTVW9exCg.png" /></figure><p>Almost any color could be represented by using 3 bytes, or 3 sets of 8 bits.</p><p>Text works the same way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGJvdIBw5gsG4k0QULkLoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*N6PzHerGZTjGiGx1AxymRg.png" /></figure><p>Each letter or symbol is assigned a number, and those numbers get converted to a set of binary code. Then, central processing unit (CPU) addresses these commands and allocates memory and devices according to how programmers have written the program.</p><p>Resources:</p><ul><li>A video on how computer works by Joshua Hawcroft: <a href="https://www.youtube.com/watch?v=AtqjxyV9t1I">https://www.youtube.com/watch?v=AtqjxyV9t1I</a></li><li>Intro to Binary: <a href="http://www.bbc.co.uk/education/guides/zwsbwmn/revision">http://www.bbc.co.uk/education/guides/zwsbwmn/revision</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72e9de535d2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s a memory leak? I forget]]></title>
            <link>https://medium.com/cloudboost/whats-a-memory-leak-i-forget-b27fc8201b?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/b27fc8201b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[memory-leak]]></category>
            <category><![CDATA[closure]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Fri, 25 Aug 2017 02:20:42 GMT</pubDate>
            <atom:updated>2020-07-16T15:09:09.171Z</atom:updated>
            <content:encoded><![CDATA[<p>This week, Sho and I gave a presentation on JavaScript’s concept of closure at Flatiron School Presents. While doing the research, we came across one disadvantage of using closures: memory leaks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*dNrlTKIl1ZmDg3QJundw6w.gif" /></figure><p>A memory leak happens when a program requests for and takes up the memory, but doesn’t actually use it. Computer memory is stored in and retrieved from Random Access Memory (RAM), just like how human’s short term memory gets stored in the hippocampus, a very specific region of our brain. The memory that RAM temporarily stores is the data of running applications.</p><p>Luckily, JavaScript is a “garbage collecting” language that automatically frees objects and strings that are not in use anymore. Therefore local variables in a function are released when the function returns them, and clears the space for other memory to be allocated.</p><p>But, what if a function is a closure?</p><p>To allow the understanding of memory leaks in JavaScript, I would like to point out the most prominent attribute of a closure. However, I won’t go too into the concept of closure in this post since closure itself is a huge topic of discussion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4w13tmeVsJQ4QO3L." /></figure><p>A closure is a child (inner) function that has access to the scope of its parent (outer) functions. To be more clear, closures in JavaScript can access the information in the outer functions because they carry references to the outer functions’ variables, not the actual value. For example, if the value of the var y changes from 15 to 5, function g() would hold the updated value of 5.</p><p>Since a closure’s job is to hold on to the reference to the outer function’s scope, instead of getting released, it takes up extra RAM space in your system. This phenomenon sounds much like the definition of memory leaks, doesn’t it?</p><p>This is just one example of different potential causes of memory leaks in your system. Other JavaScript related causes may include the following:</p><ol><li>Using timers or callbacks that make reference to data that is no longer required</li><li>Not explicitly removing the EventListeners when they are not needed outside of the local scope</li></ol><p>To check how much memory space your currently running applications are taking up, you can Spotlight Search ‘Activity Monitor’ and click on the ‘Memory’ tab.</p><p>In this specific example, I had happened to have about 29 tabs open in Chrome with some of other applications. The Activity Monitor shows that whatever I’m doing with my computer at the moment, it’s taking up 7.01 GB / 8.00 GB RAM space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKEjHIh5aadilLiggTb4CQ.png" /></figure><p>When the RAM is full, contents get saved onto the hard disk to free up space in RAM. This process is called “swapping.” In the example above, 227.MB of my RAM space was swapped for that amount of space in my hard drive. While accessing data stored in the RAM can be instantaneous, it takes longer to retrieve the data from the hard disk. Unlike the RAM that’s temporarily storing data, the data in the disk first needs to be located, read and sent to the RAM before it gets processed.</p><p>So how do you know if there is a memory leak? Memory leaks don’t result in physical or permanent damage. Since it’s a software issue, it will slow down the applications or even your whole system. However, a program taking up a lot of RAM space doesn’t always mean its memory is leaking somewhere. The program you’re using may really need that much space.</p><p>Earlier in the post I mentioned that JavaScript is a garbage collecting language. Garbage collection runs when memory is allocated and lost. It looks for memory that is not in use and releases it back to the system, decreasing the likelihood of memory leaks (that are not caused by closures!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*EDSsudglCbQQ0CTm_iRvMQ.png" /><figcaption>Closing the application forces garbage collection to run.</figcaption></figure><p>Find out more on using developer tools to locate memory leaks:</p><p><a href="http://gent.ilcore.com/2011/08/finding-memory-leaks.html">Finding memory leaks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b27fc8201b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudboost/whats-a-memory-leak-i-forget-b27fc8201b">What’s a memory leak? I forget</a> was originally published in <a href="https://medium.com/cloudboost">CloudBoost</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[JavaScript] Ruby was so yesterday]]></title>
            <link>https://medium.com/@yurachoi/javascript-ruby-was-so-yesterday-b24ebb853346?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/b24ebb853346</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Sun, 06 Aug 2017 05:49:17 GMT</pubDate>
            <atom:updated>2017-08-08T00:48:11.066Z</atom:updated>
            <content:encoded><![CDATA[<p>It is now Week 7 at Flatiron School, and it is hard to believe how much I have learned in the past two modules. Last week’s Ruby on Rails project was a success, thanks to my partner Luke. Nothing has felt more accomplishing than being able to apply all of the technical skills I’ve gained so far. And just when I thought I was getting the hang of Ruby… It is now time to put that off aside, and learn a whole new different language, JavaScript! Wait, did I say a whole new different? How would I know? I’m not sure. Let’s find out how those two languages are different in terms of their syntax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*hPVU5B4BO6SKaFqT3VAoZw.gif" /></figure><h3>Ruby vs JavaScript</h3><h4>Methods vs Functions</h4><p>In JavaScript, functions work the same way as methods in Ruby, but with a different syntax:</p><pre>def hello_world<br>  puts &quot;Hello World!&quot;<br>end</pre><p>In Ruby, this method would return nil. In JavaScript, we use console.log() to print. Similar to the concept of printing in Ruby, console.log() has a return value of undefined unless we explicitly state the desired return value.</p><pre>function helloWorld() {<br>   console.log(&quot;hello&quot;);<br>}</pre><h4>Variables</h4><pre>def author<br>  @author = &quot;Margaret Atwood&quot;<br>end</pre><p>In Ruby, @ indicates an assignment of a variable. In JavaScript, “var” or “let” does it as long as the variable is declared and assigned within the scope of its function. In this case, each variable in both languages are storing the author as “Margaret Atwood.”</p><pre>function author() {<br>   var author = &quot;Margaret Atwood&quot;<br>   return author<br>}</pre><h4>Array</h4><pre>ingredients = Array.new</pre><pre>ingredients = [&quot;ham&quot;, &quot;cheese&quot;, &quot;pickle&quot;, &quot;mayo&quot;, &quot;lettuce&quot;]<br>ingredients[2] <br>#=&gt; &quot;pickle&quot;</pre><p>Similar to how we create an array in Ruby, we can also create an array in JavaScript like this:</p><pre>var ingredients = new Array();</pre><pre>var ingredients = [&quot;ham&quot;, &quot;cheese&quot;, &quot;pickle&quot;, &quot;mayo&quot;, &quot;lettuce&quot;]<br>console.log(ingredients[2])<br>#=&gt; &quot;pickle&quot;</pre><h4>If</h4><pre>def pizza(temp)<br>  if temp == &quot;hot&quot;<br>    return &quot;happy tummy&quot;<br>  elsif temp == &quot;cold&quot;<br>    return &quot;where is the microwave?&quot;<br>  else<br>    return &quot;is it hot or cold?&quot;<br>  end<br>end</pre><p>In JavaScript, we can write out “else if” to indicate Ruby’s “elsif.” Also, notice how === is used for comparison. Using the == operator would coerce values in JavaScript which will not always return us the desired result.</p><pre>function pizza(temp) {<br>   if (temp === &quot;hot&quot;) {<br>     return &quot;happy tummy&quot; <br>   } else if (temp === &quot;cold&quot;) {<br>     return &quot;where is the microwave?&quot;<br>   } else {<br>     return &quot;is it hot or cold?&quot;<br>   }<br>}</pre><h4>String interpolation</h4><pre>@name = &quot;Tim&quot;</pre><pre>&quot;#{@name} is our instructor!&quot;<br>#=&gt; &quot;Tim is our instructor!&quot;</pre><p>When interpolating, JavaScript wraps the string with a pair of back ticks instead of quotes. Also, a dollar sign, $, before the curly braces indicate the interpolation as opposed to the octothorp, #, in Ruby.</p><pre>var name = &quot;Tim&quot;</pre><pre>`${name} is our instructor!`<br>#=&gt; &quot;Tim is our instructor!&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*7XdGtm7fih1Pq6MT8P4i4Q.gif" /></figure><h3>Fun Facts</h3><ol><li>JavaScript was created in 10 days.</li><li>Initially JS was called Mocha.</li><li>Typeof null in JS is object (it’s considered to be an empty).</li><li>Both Ruby and JS were created in 1995.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b24ebb853346" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello Pry, Buh-bye Bug!]]></title>
            <link>https://medium.com/@yurachoi/hello-pry-buh-bye-bug-c89a1df00fe2?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/c89a1df00fe2</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[friday]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 00:58:59 GMT</pubDate>
            <atom:updated>2017-07-21T01:28:03.111Z</atom:updated>
            <content:encoded><![CDATA[<p>Happy Friday! I refuse to believe this, but we’re already wrapping up Week 4. Time flies when you’re coding! I think it’s a good sign, that I’m immersed into learning and finding the overall experience at <a href="https://medium.com/u/973c5cbfb09b">Flatiron School</a> delightful.</p><p>We have switched to the second module of the program, which deals with building web frameworks using Rack-based Sinatra and Rails. The truth is, our code is only getting more complex, and the more complex it gets, the more inevitable the errors become.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*7dFF3N2BwzlPz5MHA3_eyA.gif" /></figure><p>No matter how deep we’re in, it is always smart to test out our code. When I first learned Ruby, I began the practice of testing out my code in Interactive Ruby. IRB evaluates our input and returns the result. However, IRB provides a blank slate to work with every time, which may be inefficient if we have to keep transferring our code. Then Pry came along. Pry is similar to IRB in its function, but it allows us to work directly inside our program.</p><h3>Pry</h3><pre><strong>require &#39;pry&#39;</strong><br>class Dog</pre><pre>    def bark<br>        puts &quot;Woof!&quot;<br>    end</pre><pre>    def sit<br>        puts &quot;The Dog is sitting&quot;<br>    end<br>end<br><strong>binding.pry</strong></pre><p>We first need to include <strong>gem ‘pry’</strong> in our <em>Gemfile</em>. As shown above, in order to use the gem Pry, we must <strong>require ‘pry’</strong> at the top of our file and place <strong>binding.pry</strong> within the block we desire to test. In this case, the context of pry is main.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*bN56ljM4hSDYI31grwoATg.png" /></figure><p>Our code gets evaluated and the result gets printed out on to the terminal.</p><p>You will notice that pry is more convenient than IRB since we didn’t have to copy and paste our class and methods onto the shell.</p><p>Then how do errors in pry look like?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*CPSoUuZeTPjZUyi58k95CQ.png" /><figcaption>NoMethodError in Pry</figcaption></figure><p>Pry displayed a NoMethodError since we haven’t defined a “howl” method. So what can we do to solve this particular error?</p><ol><li>Create a howl method</li><li>Don’t call on howl method (it doesn’t exist until you create it)</li></ol><p>Pry is cool and useful because we get to FEEL and BREATHE the errors instead of avoiding them. But then… I noticed our instructors using a special, by invite-only debugger called ‘byebug’ whenever pry got them frustrated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gY7FAY43Zaa3KV8zKSTTmA.png" /><figcaption>NoMethodError detected using ‘byebug’</figcaption></figure><h3>Byebug</h3><p>Frankly, I was intimidated by trying out byebug. I didn’t want anything to do with facing more errors…. I was afraid of generating more errors by looking up more ways to find errors!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*eZEXyCUVhGfWtwE1nwA1OQ.gif" /><figcaption>Goodbye bug!</figcaption></figure><p>I came to a realization that byebug is just another gem like pry that we can use to debug our code. According to “Debugging using ByeBug Gem in Rails 5” written by <a href="https://rubyplus.com/about">Bala Paranj</a>, this gem is included in Rails 5 project by default. If you create a new Rails 5 project, your <em>Gemfile</em> should already have <strong>gem ‘byebug’ </strong>listed. Just don’t forget to ‘bundle install’ your gems.</p><pre>get &#39;/juices&#39; do<br>    @juices = Juice.all<br>    <strong>byebug</strong><br>    erb :&#39;juices/index.html&#39;<br>end</pre><p>How to use byebug? We can drop ‘byebug’ anywhere you would like to test as long as you know the gem is in the Gemfile. (No need to require ‘byebug’ on top of the page!) Run shotgun and execute the local host address in the browser, with ‘/juices’ at the end. If you look at your terminal, you would see that you’ve entered a byebug session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*v1Mm-AFUnnmt91BwwSJvfg.png" /></figure><p>Just like in pry, you can test your code in your terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*1JhqwC3_wqUDKAmdnGS_pA.png" /></figure><p>Upon entering the instance variable @juice, byebug has returned the array of all the juices. This is a way to inspect variable by printing. If you type help, you will be able to see all the list of available commands as well.</p><h3>Differences?</h3><ul><li>The most obvious one is that Pry gives us highlighted syntax while byebug doesn’t.</li><li>Different commands</li><li>Byebug has its own useful commands such as “next.” Next steps byebug over to the next line within the same frame.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*WSODGEp0gf2P-M7WPNsV0w.png" /><figcaption>The arrow is pointing at line 5</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*WqSJvO-aVxatY5FmLpt4rA.png" /><figcaption>“next” command skipped over line5, so we’re now on line 6.</figcaption></figure><p>Adding gems such as <strong>pry-debugger</strong> , <strong>pry-byebug</strong> or <strong>pry-nav</strong>to Pry will also allow the use of byebug’s commands!</p><h3><strong>Conclusion</strong></h3><p>Use whatever comes most natural to you, whenever you need. Sometimes, the best way to detect an error is to look away, and get back to them after a well deserved break.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c89a1df00fe2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[SQL] Clause order & WHERE vs. HAVING]]></title>
            <link>https://medium.com/@yurachoi/sql-clause-order-where-vs-having-b31553e3cb6?source=rss-728f28e71b04------2</link>
            <guid isPermaLink="false">https://medium.com/p/b31553e3cb6</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Yura Choi]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 12:48:36 GMT</pubDate>
            <atom:updated>2017-07-07T12:48:36.036Z</atom:updated>
            <content:encoded><![CDATA[<p>Coding is sooo easy, I had 8 hours of sleep last night! Said no one ever.</p><p>The truth is…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*FZTJmlfN6IXZeO-RbKvC8g.gif" /><figcaption>Do you ever feel so lost that you don’t even know what you’re lost about?</figcaption></figure><p>Although learning to code has been quite a challenge for me, unconditional support from my cohort mates and staffs at <a href="https://medium.com/u/973c5cbfb09b">Flatiron School</a> has helped me gradually absorb various concepts and skills over the past two weeks.</p><p>This week, we dived into SQL — Structured Query Language.</p><blockquote>SQL (Structured Query Language) is a programming language designed for managing data in a relational database. It’s been around since the 1970s and is the most common method of accessing data in databases today. SQL has a variety of functions that allow its users to read, manipulate, and change data. Though SQL is commonly used by engineers in software development, it’s also popular with data analysts for a few reasons:</blockquote><blockquote>It’s semantically<strong> easy to understand</strong> and learn.</blockquote><blockquote>Because it can be used to<strong> access large amounts of data directly where it’s stored</strong>, analysts<strong> </strong>don’t have to copy data into other applications.</blockquote><blockquote>Compared to spreadsheet tools, data analysis done in SQL is <strong>easy to audit and replicate</strong>. For analysts, this means no more looking for the <a href="http://www.washingtonpost.com/blogs/wonkblog/wp/2013/04/16/is-the-best-evidence-for-austerity-based-on-an-excel-spreadsheet-error/">cell with the typo in the formula</a>.</blockquote><blockquote>SQL is great for performing the types of aggregations that you might normally do in an Excel pivot table — sums, counts, minimums and maximums, etc. — but over much larger datasets and on multiple tables at the same time.</blockquote><blockquote>— Mode Analytics</blockquote><p>Much of the emphasis has been on creating, selecting, updating and deleting data from database tables as well as relating data within a database using SQLite3.</p><p>Let’s imagine we’re organizing a fundraiser and need to keep track of all the projects, users and pledges. Take a look at these <strong>CREATE TABLE</strong> statements:</p><pre>CREATE TABLE projects (<br> id INTEGER PRIMARY KEY,<br> title TEXT,<br> category TEXT,<br> funding_goal INTEGER,<br> start_date TEXT,<br> end_date TEXT<br>);</pre><pre>CREATE TABLE users (<br> id INTEGER PRIMARY KEY,<br> name TEXT,<br> age INTEGER<br>);</pre><pre>CREATE TABLE pledges (<br> id INTEGER PRIMARY KEY,<br> amount INTEGER,<br> user_id INTEGER,<br> project_id INTEGER<br>);</pre><p>With a given data, tables like the following could be generated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjhLVes3B7Iani-9xsFWug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*mGDqlIjbX5qeitOXlOXPdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*RZxbs1IN4MYLMHujRJPQ0g.png" /></figure><p>Using the above tables as a reference, let’s try selecting the category names and pledge amounts of all pledges in the books category.</p><pre>“SELECT projects.category, pledges.amount</pre><pre>FROM projects</pre><pre>INNER JOIN pledges</pre><pre>ON projects.id = pledges.project_id</pre><pre>WHERE projects.category = ‘books’”</pre><p>Notice all the clauses used in this query: <strong>SELECT, FROM, INNER JOIN, ON, </strong>and <strong>WHERE</strong>. Does the order of operations for these clauses matter?</p><p>The answer is YES. Here is the order simply listed out for you:</p><ol><li><strong><em>SELECT</em></strong></li><li><strong><em>FROM</em></strong></li><li><strong><em>ON</em></strong></li><li><strong><em>WHERE</em></strong></li><li><strong><em>GROUP BY</em></strong></li><li><strong><em>HAVING</em></strong></li><li><strong><em>ORDER BY</em></strong></li></ol><p>Following the order of these SQL elements helps us take the full advantage of SELECT queries. In the query above, we’re ultimately looking for the name of the category and the amount of pledges specifically in the ‘books’ category. In order to execute this, we must indicate in which table should we look for the ‘category’ and the ‘amount.’ Next, due to various projects and high volumes of pledges, it would be efficient to match the projects to their pledged amounts using their ID’s. Once projects and pledges are joined on their ID, we want to specify the exact category or categories, so that we can filter out the insignificant information using “WHERE.”</p><p>We can take a look at another query that uses a slightly different clause.</p><p>Now that we know how to locate the amount of pledges according to each category, or even project titles, how can we select the titles and amount over goal of all projects that have met their funding goal?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*KCoxUoDSYkshGNspQOv2_g.gif" /><figcaption>Keep calm and look at the hint.</figcaption></figure><p>Hint: SELECT — FROM — ON— GROUP BY — HAVING</p><pre>&quot;SELECT projects.title, (SUM(pledges.amount) - projects.funding_goal)</pre><pre>FROM projects</pre><pre>INNER JOIN pledges</pre><pre>ON projects.id = pledges.project_id</pre><pre>GROUP BY projects.title</pre><pre>HAVING (SUM(pledges.amount) - projects.funding_goal) &gt;= 0&quot;</pre><p>Notice how we’re using the clause “HAVING” as opposed to “WHERE.” What do you think the difference is?</p><h3>WHERE vs. HAVING</h3><h4><strong>WHERE</strong></h4><blockquote><em>The WHERE clause filters records by extracting only those records that fulfill a specified condition. It is used in SELECT, as well as in UPDATE and DELETE statements. — W3Schools</em></blockquote><h4>HAVING</h4><blockquote><em>The HAVING clause comes after GROUP BY. GROUP BY is usually paired with aggregate functions such as COUNT, MAX, MIN — and in this case — SUM. In the above example, HAVING is chosen over WHERE since we’re looking for a result that is produced by looking at more than one column. If there is no GROUP BY clause, then we would assume that we’re working with a single group and use WHERE.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*3k0BRxEdh5tPva8be1KdjA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b31553e3cb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>