<?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[Codesmith Student Blog - Medium]]></title>
        <description><![CDATA[Read some of the blog posts students have written during their time at Codesmith and beyond! - Medium]]></description>
        <link>https://medium.com/codesmith-student-blogs?source=rss----42ee0dd3e5a6---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Codesmith Student Blog - Medium</title>
            <link>https://medium.com/codesmith-student-blogs?source=rss----42ee0dd3e5a6---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:20:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/codesmith-student-blogs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTML + CSS + JavaScript (+ jQuery)]]></title>
            <link>https://medium.com/codesmith-student-blogs/html-css-javascript-jquery-8c0abdf651d6?source=rss----42ee0dd3e5a6---4</link>
            <guid isPermaLink="false">https://medium.com/p/8c0abdf651d6</guid>
            <dc:creator><![CDATA[Arko Dewri]]></dc:creator>
            <pubDate>Fri, 19 Jun 2015 16:56:05 GMT</pubDate>
            <atom:updated>2015-06-16T00:48:25.603Z</atom:updated>
            <content:encoded><![CDATA[<p>An HTML file lacks both taste and flavor without the CSS styling and JavaScript interactivity. How you would link CSS and JavaScript to HTML?</p><p>In order to link CSS stylesheet (file) to an HTML file, add the following code between &lt;head&gt; and &lt;/head&gt; in your HTML file.</p><pre>&lt;link rel=”stylesheet” type=”text/css” href=”stylesheet.css”&gt;</pre><p>Put the name of your CSS stylesheet (file) instead of “stylesheet.css”.</p><p>In order to link JavaScript file to an HTML file, add the following code between &lt;head&gt; and &lt;/head&gt; in your HTML file.</p><pre>&lt;script type=&quot;text/javascript&quot; src=&quot;script.js&quot;&gt;&lt;/script&gt;</pre><p>Put the name of your JavaScript file instead of “script.js”.</p><p>If you wish to code in jQuery in your JavaScript file, DO NOT forget to add jQuery library in your HTML file. To do so, add the following code between &lt;head&gt; and &lt;/head&gt; in your HTML file.</p><pre>&lt;script src=”<a href="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js</a>&quot;&gt;&lt;/script&gt;</pre><p>Instead of 1.8.3, you can put the most recent <a href="http://jquery.com/download/">jQuery library</a> available. Also, make sure you ready your JavaScript file for coding in jQuery. To do so, add the following code snippet at the beginning or end of your JavaScript file.</p><pre>$(document).ready(function() {...});</pre><p>Inside the function, you can add the code of your choice (which will run when the page is ready, such as printing out “ready” using console.log() or adding code to refresh the page).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c0abdf651d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codesmith-student-blogs/html-css-javascript-jquery-8c0abdf651d6">HTML + CSS + JavaScript (+ jQuery)</a> was originally published in <a href="https://medium.com/codesmith-student-blogs">Codesmith Student Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diagramming Your Code: Part 1 Defining Variables]]></title>
            <link>https://medium.com/codesmith-student-blogs/diagramming-your-code-part-1-defining-variables-71725541cb98?source=rss----42ee0dd3e5a6---4</link>
            <guid isPermaLink="false">https://medium.com/p/71725541cb98</guid>
            <dc:creator><![CDATA[Jasmine Giang]]></dc:creator>
            <pubDate>Wed, 17 Jun 2015 19:24:49 GMT</pubDate>
            <atom:updated>2015-06-16T00:59:06.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Knowing what’s going on during runtime is essential to debugging and understanding your code.</p><p>A great tool for this is a website called PythonTutor (<a href="http://www.pythontutor.com/visualize.html#mode=edit">http://www.pythontutor.com/visualize.html#mode=edit</a>). The name is a bit deceiving; it is actually compatible with a couple of different programming languages, including JavaScript. Given a snippet of code, PythonTutor will walk you step-by-step through diagramming your program as it runs.</p><p>Although this incredibly useful tool exists, it is extremely valuable to be able to diagram on your own. We will use PythonTutor as a starting point to learn the basics of how to structure our diagrams, but the goal is to internalize the process.</p><p>Let’s start with a simple snippet of code to get see how variables are declared and initialized.</p><pre>var num = 0;<br>var bool = true;<br>var str = &quot;hello world&quot;;<br>var numArray = [0, 1, 2];<br>var arrPtr = numArray;<br>var increment = function() {num += 1};</pre><h4>Some rules:</h4><ol><li>In JavaScript: Primitives types (numbers, booleans, strings, and null/undefined) are passed by value</li><li>In JavaScript: Everything else (non-primitive data, including functions) is an object and is passed by reference</li><li>All data is stored in frames, starting at the global frame</li><li>New frames are created when functions are called</li></ol><p>PythonTutor walks us through this code, showing which line is being executed at each step and how that execution affects the values of variables in our frames. The final diagram should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJs_HVLm08s6H4COs5sNww.png" /><figcaption>diagram after all of the code to the left has been executed</figcaption></figure><p>The next post will tackle diagramming function calls!</p><p>A separate post about pass-by-value vs pass-by-reference may also be in the near future!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71725541cb98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codesmith-student-blogs/diagramming-your-code-part-1-defining-variables-71725541cb98">Diagramming Your Code: Part 1 Defining Variables</a> was originally published in <a href="https://medium.com/codesmith-student-blogs">Codesmith Student Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge Sort in Javascript]]></title>
            <link>https://medium.com/codesmith-student-blogs/merge-sort-in-javascript-ec5fb0fd9180?source=rss----42ee0dd3e5a6---4</link>
            <guid isPermaLink="false">https://medium.com/p/ec5fb0fd9180</guid>
            <dc:creator><![CDATA[David Petri]]></dc:creator>
            <pubDate>Wed, 17 Jun 2015 18:57:03 GMT</pubDate>
            <atom:updated>2015-06-16T02:40:15.083Z</atom:updated>
            <content:encoded><![CDATA[<p>Merge sort is both an efficient sorting algorithm and a great way of learning recursion. A merge sort follows three main steps:</p><ol><li>If the array is 1 element long, return the given array because it’s already sorted.</li><li>Split the array into two and merge sort each of the halves. (Yay for recursion)</li><li>Take the resulting sorted halves and zip them together.</li></ol><p>Don’t worry if those steps don’t make any sense yet. Just read on and refer back to the steps later.</p><p>To begin, a merge sort function accepts as a parameter an unsorted array of unspecified size:</p><pre>function mergeSort(array) {...}</pre><p>If the array given is only one item in length, then voila, the array is already sorted. In this case merge sort simply returns the given array. This is also the recursive base case.</p><pre>if (array.length &lt;== 1) {<br>  return array; //awesome, already sorted!<br>}</pre><p>Merge sort then operates based on the knowledge that it’s quite fast and easy to combine two sorted lists together into one sorted list. Right now you may be thinking “Okay, that sounds great, but I don’t exactly have two sorted lists. I have one very much unsorted list.” This is quite correct, and merge sort has a very tricky way of turning an unsorted list into two sorted lists. First, you split the unsorted array into two:</p><pre>// array = [6, 4, 9, 2]<br>var length = array.length;          //length = 4<br>var mid = Math.floor(length / 2);   //mid = 2</pre><pre>var leftSide = array.slice(0, mid); // [6, 4]<br>var rightSide = array.slice(mid);   // [9, 2]</pre><p>Now for the tricky part: merge sort recursively calls itself twice, each time passing in one of the two new half arrays.</p><pre>var leftSorted = mergeSort(leftSide);   //leftSide = [6, 4]<br>var rightSorted = mergeSort(rightSide); //rightSide = [9, 2]</pre><p>Let’s take a look at the resulting two function calls. First, mergeSort gets called with the leftSide array of [6, 4]. The array gets checked to see if its length is 1 or less, which in this case it isn’t:</p><pre>// array = [6, 4]<br>if (array.length &lt;== 1) {  //array.length === 2<br>  return array;<br>}</pre><p>Shucks, it looks like the array needs to get down to one element long before it’ll hit our base case. Remember from above that mergeSort now recursively calls itself again, splitting this new array twice more:</p><pre>// array = [6, 4]<br>var length = array.length;          // length = 2<br>var mid = Math.floor(length / 2);   // mid = 1</pre><pre>var leftSide = array.slice(0, mid); // [6]<br>var rightSide = array.slice(mid);   // [4]</pre><pre>var leftSorted = mergeSort(leftSide);   //leftSide = [6]<br>var rightSorted = mergeSort(rightSide); //rightSide = [9]</pre><p>Now we have two more recursive calls being created! But notice that now the arrays being passed in, [6] and [4], are each only 1 element long, and the thing about a list of one item is that it’s guaranteed to already be sorted. These two new recursive function calls will hit the base case and return immediately:</p><pre>// array = [6]<br>if (array.length &lt;== 1) {  //array.length === 1<br>  return array;            // return [6]<br>}</pre><pre>// array = [4]<br>if (array.length &lt;== 1) {  //array.length === 1<br>  return array;            // return []<br>}</pre><p>Wow, the [6] and the [4] both returned because they satisfied the base case. Merge sort now takes these resulting already sorted arrays and zips them together, maintaining the sorting:</p><pre>var sortedArray = zip_up(leftSide, rightSide); //leftSide === [6]<br>                                               //rightSide === [4]</pre><p>zip_up here is just a function that takes in two sorted arrays and merges them together. Given [6] and [4], zip_up will return [4, 6]. I’ll get into the specifics of how it does this later but it’s not too tricky. the [4, 6] gets returned up to our first recursive call, which now has the following state:</p><pre>var leftSorted = mergeSort(leftSide);   //leftSide = [6, 4]<br>var rightSorted = mergeSort(rightSide); //rightSide = [9, 2]</pre><pre>//leftSorted = [4, 6]<br>//rightSorted = [2, 9]</pre><pre>var sortedArray = zip_up(leftSorted, rightSorted); //zipping up [4, 6] and [2, 9]</pre><p>Now we see that thanks to the recursion each time zip_up gets called, it has two sorted lists to zip up. The final crucial step that merge sort must make is to simply return the result of the zip up:</p><pre>return sortedArray; [2, 4, 6, 9]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec5fb0fd9180" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codesmith-student-blogs/merge-sort-in-javascript-ec5fb0fd9180">Merge Sort in Javascript</a> was originally published in <a href="https://medium.com/codesmith-student-blogs">Codesmith Student Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>