<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jami</title>
    <description>The latest articles on DEV Community by Jami (@eunovira).</description>
    <link>https://dev.to/eunovira</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3887998%2Fa17c9e5d-8391-44c4-9ad4-ebfe0d9119bd.jpeg</url>
      <title>DEV Community: Jami</title>
      <link>https://dev.to/eunovira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eunovira"/>
    <language>en</language>
    <item>
      <title>Breaking Down Code</title>
      <dc:creator>Jami</dc:creator>
      <pubDate>Mon, 20 Apr 2026 01:58:36 +0000</pubDate>
      <link>https://dev.to/eunovira/breaking-down-code-3m94</link>
      <guid>https://dev.to/eunovira/breaking-down-code-3m94</guid>
      <description>&lt;p&gt;Disclaimer: I am a student coder for a coding bootcamp program, not an educator. My blog posts may come off as confusing however the entire point is me figuring out the answers to my own questions and proving myself wrong as I write. The full answer will never be given or explained well initially however as I write I will do my best to get to a suitable solution. Happy reading!&lt;/p&gt;

&lt;p&gt;One of the lessons from this week that really stumped me went a little something like this...&lt;/p&gt;

&lt;p&gt;// Memorize an expensive function's results by storing them. You may assume&lt;br&gt;
  // that the function only takes primitives as arguments.&lt;br&gt;
  // memoize could be renamed to oncePerUniqueArgumentList; memoize does the&lt;br&gt;
  // same thing as once, but based on many sets of unique arguments.&lt;br&gt;
  //&lt;br&gt;
  // _.memoize should return a function that, when called, will check if it has&lt;br&gt;
  // already computed the result for the given argument and return that value&lt;br&gt;
  // instead if possible.&lt;/p&gt;

&lt;p&gt;My interpretation...&lt;/p&gt;

&lt;p&gt;Create a function: Memoize&lt;br&gt;
This function should only take primitive (aka simple) values as arguments. It should return a function that when called, will check if it has already computed the result and return it if it has.&lt;/p&gt;

&lt;p&gt;Memoize is based on Once: A function that takes in another function and returns a new version of the function it takes in. It can only be called at most one time and any calls after that should return the original function. This means the code can only run once and should only have one solution. &lt;/p&gt;

&lt;p&gt;We solved Once by first creating a new variable called alreadyCalled and setting it equal to false and another new variable called result. We then returned an empty function that determined if alreadyCalled was not false and instead was true, then apply the arguments to the given function and compute the result and set the answer equal to the result variable. After the function returns the result, set alreadyCalled to true and return the result of the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;once&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;alreadyCalled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;alreadyCalled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;alreadyCalled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code if there is already an answer then there is no need to run the return function, the result will automatically return as it is outside of those conditions. In any other case, if the result has not been computed, the computer will run the return function determining already called as true. Next the computer will apply the input arguments to the function using .apply and this which accesses the initial func parameter. Once the answer is produced the result will be set and alreadyCalled will be set officially to true. The result will be returned and the code will end. &lt;/p&gt;

&lt;p&gt;How this applies to Memoize:&lt;br&gt;
Memorize (a different function) is used to store the result of a function like the one above. Mem-o-ize is designed to check whether a result in Memorize has already been stored. &lt;/p&gt;

&lt;p&gt;We start by making a memory variable within the Memoize function that will store the results of any function just like Memorize traditionally would.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;memoize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Say we have a function that takes 5 as an argument. The purpose of that function is to square the number 5 in this instance. The result would be 25. The way this would be stored in the memory object would appear like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If 5 is used again as an argument in the future, then there will be a result of 25 again resulting in the memory object appearing like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Memoize needs to check whether 5 has already been used as an argument and whether the results are the same as well. This would mean that there is a duplicate result which based on the tests we're given would not be ideal or necessary.&lt;/p&gt;

&lt;p&gt;The next step in Memoize is to determine what to do if the arguments we are given are not string values. In order to check for duplicates we need these value types to all be the same. If there is a string '5' in the object but then a 5 in the object, it makes in more difficult for the computer to check for duplicate results in an efficient manner. &lt;/p&gt;

&lt;p&gt;The part that stumped me wasn't necessarily how the function should work, but more so how JSON.stringify worked. JSON.stringify is meant to compute a specified parameters position into a string to make it easier for the computer to read and recognize. From what I've read, in this instance JSON.stringify would stringify the position of the argument, not necessarily the argument itself. If an argument of 5, 6, 7, 8 are entered then 5 would hold call position 0, 6 would hold call position 1 and so on using typical indexing. I couldn't understand why the position itself needed to be a string or how it made it easier for the computer to read. What I've learned is: Javascript naturally stores keys in objects as strings to make for a more stable key lookup. I had no idea. So to revamp everything I've said until now, what's actually going on is JSON.stringify is positioning the arguments given to the input function as their own object. Under the hood, this would appear as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What then happens is the function computes the action you are looking to do based on the given argument and it's position. When the function computes the computer stores it as so:&lt;/p&gt;

&lt;p&gt;Computer Model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nl"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mental Model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The true purpose of Memoize is speed. If the answer has already been created then it will be produced efficiently, otherwise Memoize will compute it itself and then return the result. &lt;/p&gt;

&lt;p&gt;To complete this code we must create a variable that is set to utilizing JSON.stringify on the arguments that are input into the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;memoize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, we create our condition. If there is a key and value already in the memory object, the value will be returned since the point of Memoize is to improve efficiency. If there is no key in the memory object that we created (aka if the memory is empty) a value for the stringified key variable that applies the argument on the function. Because the key has already been defined as the positioned arguments...&lt;/p&gt;

&lt;p&gt;Ex: {"0": 5, "1": 6, "2": 7, "3": 8}&lt;/p&gt;

&lt;p&gt;These will be our new keys and we can set the values as the result of completing the action on the argument via the function (Ex: squaring each argument) and we return the values in the memory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;memoize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

      &lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lesson taught me more about how to use JSON.stringify, how it works and why it is necessary to update functions we have created in the past to improve efficiency for our code. Coding is all about efficiency and finding new pathways to limit as many bugs as possible. Thank you for reading and until next time!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>This Weeks Lesson</title>
      <dc:creator>Jami</dc:creator>
      <pubDate>Mon, 20 Apr 2026 01:00:45 +0000</pubDate>
      <link>https://dev.to/eunovira/this-weeks-lesson-3c69</link>
      <guid>https://dev.to/eunovira/this-weeks-lesson-3c69</guid>
      <description>&lt;p&gt;If I have learned anything this week about coding javascript and debugging sites using developer tools, it's that I know nothing at all. I have somehow passed the bootcamp phase of the code camp I'm a part of. Week after week for 3 hours a day we sat on meetings learning everything from variables, to loops, to functions. I can tell you why loops are necessary in code. I can tell you that without them, coding would be very meticulous and messy and it would be very difficult to debug anything, however I am now learning loops can be just as messy. &lt;/p&gt;

&lt;p&gt;This week we had a few lessons that were very difficult for me in which I could feel myself falling behind. One was the function of the underscore library and the importance of utilizing functions to run instruction specific code. I'm realizing there's something for everything. There is a setTimer function which takes in a parameter of a wait time in ms. There is a way to take the difference of values multiple array's and return the values that are reoccurring in each array all to be returned as a new array. To put it short, there are many different ways to do many different things. &lt;/p&gt;

&lt;p&gt;Before I started code and realized what developers meant by it being a language I assumed code was mostly like simplistic math. I assumed it only had one way of solving and one solution. I'm now realizing there is a whole world of code. There are combinations of code I had no idea existed until a few days ago. &lt;/p&gt;

&lt;p&gt;Here's an example:&lt;/p&gt;

&lt;p&gt;Say you're given a list of people and they all have names and ages and that list goes on for miles. You're told you need to be able to sort this list in numerous ways whether that be from a - z, z - a, or some other way of sorting.&lt;/p&gt;

&lt;p&gt;For this example we created a _.sortby function that could take in a collection (that list) and an iterator (whatever key in the list you're sorting). This stumped me for a while because the instructions declared that we have to find a way to figure out if the iterator is a string or whether it is something else. In no world would I have assumed that the iterator would be anything but a string. That's the thing, in coding you have to be able to look ahead in case there is a typo on the part of another developer who potentially forgot to include quotes around a word that we are using for lookup or in the case that there is no string at all. For this problem we sliced the list and used .sort and two parameters to sort the list in ascending order. &lt;/p&gt;

&lt;p&gt;_.sortBy function(collection, iterator) {&lt;/p&gt;

&lt;p&gt;return collection.slice().sort((a, b) =&amp;gt; {&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;To specify what we wanted to sort in the list, we included conditions via an if statement. If the iterator itself was a function and already had the sort conditions specified (that being the key and the sort type) then we would invoke the function on the first parameter to the invocation of the second parameter to sort the list in ascending order. Otherwise, if iterator was a string, we would return the first parameter and call the key in the list (Ex: 'name') to sort the list in ascending order using bracket notation instead of function invocation. &lt;/p&gt;

&lt;p&gt;_.sortBy function(collection, iterator) {&lt;/p&gt;

&lt;p&gt;return collection.slice().sort((a, b) =&amp;gt; {&lt;/p&gt;

&lt;p&gt;if(typeof iterator === 'function') {&lt;br&gt;
        return iterator(a) - iterator(b);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  } else if (typeof iterator === 'string') {
    return a[iterator] - b[iterator];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;})&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;This was our final solution. Before Friday I had no idea how to use .sort and I would have had trouble understanding why it needed to be used differently depending on whether a parameter acted a as a function or a string. Now, I can semi-confidently say that a - b is a sort type. It will always sort in ascending order. To invoke the iterator function on the sort type is to simply say what we need to sort in ascending order within the list. To use bracket notation on the sort type is to do the same thing. The syntax is just different depending on the type of value iterator entails, but .sort never really changes. &lt;/p&gt;

&lt;p&gt;Looking back, there is not much account for how the code should run in the instance that name is not a string and was entered incorrectly or for many other instances like what would happen if iterator had no value at all and was undefined or null. However, that seems like a lesson for next week. For now I believe we did our best with the information we were given and the code still passed all the provided tests. That's all for now!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
