<?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 Madeline Dulchin on Medium]]></title>
        <description><![CDATA[Stories by Madeline Dulchin on Medium]]></description>
        <link>https://medium.com/@madelinedulchin?source=rss-ab2433dfe601------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vGfQ4V5XU_BUpEtm</url>
            <title>Stories by Madeline Dulchin on Medium</title>
            <link>https://medium.com/@madelinedulchin?source=rss-ab2433dfe601------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:51:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madelinedulchin/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[Convention over Configuration in Rails]]></title>
            <link>https://medium.com/@madelinedulchin/convention-over-configuration-in-rails-a5bf07669526?source=rss-ab2433dfe601------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5bf07669526</guid>
            <category><![CDATA[mvc]]></category>
            <category><![CDATA[convention-over-config]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Madeline Dulchin]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 01:32:38 GMT</pubDate>
            <atom:updated>2022-12-06T01:32:38.719Z</atom:updated>
            <content:encoded><![CDATA[<p>Convention, rather than configuration, is what makes the “magic” of Ruby on Rails work.</p><p>The concept itself is at the heart of Ruby on Rails. As the creator of Rails, David Heinemeier Hansson, writes in the <a href="https://rubyonrails.org/doctrine">The Rails Doctrine</a>, “by giving up vain individuality, you can leapfrog the toils of mundane decisions, and make faster progress in areas that really matter.” Convention allows programmers to focus on the meat of their applications, rather than the numerous mundane decisions that make up an application. In the group projects I created at Flatiron for the first 3 phases we often ran into issues as a group because of how we named our components (two of us would be working on different but related elements, and we would have ended up calling them almost the same thing, or we’d end up with something like “candleCreatorAgain”. There’s never a time that I feel less creative than when I’m naming elements of my application, and not uncreative in a way that leads to conveniently and well-named elements. Luckily, Rails takes care of that.</p><h3>Model-View-Controller</h3><p>The MVC structure is one of the most important examples of convention over configuration (CoC) because it makes up the typical structure of a rails application.</p><p>Model: where most of your logic will go, this is what talks to the actual database</p><p>Controller: communicates between model and view, it delivers the data that is viewed by the user</p><p>View: Renders the information to the page.</p><p>MVC has very strict naming conventions which allow them to properly communicate.</p><p>Imagine the data I want to show the user is all my favorite books. By convention my table would be called “books” — lowercase, plural, and snake_case if more than one word, and the MVC and file names would be based off of that table:</p><p>Model (and associations):</p><pre># the file name will be singular, lowercase, snake_case:<br>app/models/book.rb<br><br># the class name will be singular, uppercase, titlecase:<br>class Book &lt; ApplicationRecord<br>end<br><br># Associations:<br># where one model belongs to another: singular, lowercase, snake_case:<br>belongs_to :reader<br>#where one model has many of another: plural, lowercase, snake_case<br>has_many :readers<br># in a case where a model has many, through another model, both model names<br># will be plural, lowercase, and snake_case<br>has_many :reviews, through: :readers</pre><p>Controller:</p><pre># the file name will be plural, followed by the word &quot;controller&quot;, camelCase:<br>app/controller/books_controller.rb<br><br># the class name will be plural, titlecase, and ends with &quot;Controller&quot;,<br># (uppercase this time):<br>class BooksController &lt; ApplicationRecord<br><br>end </pre><p>View:</p><pre># the folder for each view will be plural, snake case, and <br># stored in the views folder<br>app/views/books<br># the file itself will be named after the action it&#39;s meant to display, <br># followed by .html.erb<br>app/views/books/index.html.erb</pre><p>This makes life so much easier. If I need to create a table to store any information, I know exactly the naming convention to follow. And, once I have my table in place, I know what I’m supposed to call the model, the view, and the controller, and how to properly associate them together.</p><p>These conventions are so deeply at the basis of Rails that it will basically do all of this creating for you with very few actual commands, and it’s all done in your terminal</p><h4>Rails Generators:</h4><p>Rails generators are basically templates (which also follow strict conventions) that make your life incredibly simple by creating your models, views, and controllers for you.</p><p>There are a variety of generators at your disposal, but I’m going to focus on the ones that deal with creating your MVCs</p><h4>Most basic syntax: rails generate* &lt;name of generator&gt; &lt;optional attributes&gt;</h4><ul><li>*generate can be shorted to just “g”</li><li>As you’ll see in the following examples, the name of the element we are trying to create is capitalized (although rails will know what you mean if you forget) followed by any attributes you’d like and their respective data types.</li></ul><p>rails generate model: creates both a model and a migration file</p><pre><br>rails generate model Book title:string* author:string price:integer<br><br>      invoke  active_record<br>      create    db/migrate/20221206005643_create_books.rb<br>      create    app/models/book.rb<br><br># *string is the default so you don&#39;t actaully need to specify it. <br></pre><p>rails generate migration: creates just the migration file. Imagine, for example, that we’d forgotten to include the author in our books table, and wanted to add that. Sounds inconvenient, but thats exactly what the migration generator will do for us.</p><pre>rails generate migration AddAuthorToBooks author:string<br>      invoke  active_record<br>      create    db/migrate/20221206010336_add_author_to_books.rb<br># that command will create a new migration that looks like this: <br>class AddAuthorToBooks &lt; ActiveRecord::Migration[6.1]<br>  def change<br>    add_column :books, :author, :string<br>  end<br>end<br>#and once we run rails db:migrate, those books will have an author. </pre><p>rails generate resource: creates your model, migrations, and controller!</p><pre>rails g resource Book author title price:integer<br>      invoke  active_record<br>      create    db/migrate/20221206010851_create_books.rb<br>      create    app/models/book.rb<br>      invoke  controller<br>      create    app/controllers/books_controller.rb<br>      invoke  resource_route<br>       route    resources :books</pre><p>If you look at the above examples you’ll see that rails has gone ahead and followed the naming conventions I mentioned earlier. Active record has created a model called “book” and a controller called “books_controller”, which is exactly what we did earlier when we created these by hand.</p><p>And, if you wanted to remove any of the things you just created (maybe you spelled author wrong or forgot to specify that price was an integer) all you have to do is replace the “g” with a “d” and run the exact same command as you did to create:</p><pre>rails d resource Book author title price:integer<br>      invoke  active_record<br>      remove    db/migrate/20221206010851_create_books.rb<br>      remove    app/models/book.rb<br>      invoke  controller<br>      remove    app/controllers/books_controller.rb<br>      invoke  resource_route<br>       route    resources :books</pre><p>You can see how efficient Rails conventions makes things.</p><p>Convention over configuration is wildly convenient because it was designed to decrease the number of decisions you, the programmer, need to make, and cuts down on the actual code you need to write because it supports abstraction so well. By cutting down on the tedious code you have to write you also cut down on typos, and therefore errors in your project.</p><p>For beginners the CoC paradigm lowers the bar to entry. Of course its good to understand what’s going on behind the scenes, but even if you don’t you can really efficiently being creating apps, as long as you know the most basic rules.</p><p>If you’re already a Rails/programming expert, CoC lets you focus only on the more challenging and exciting aspects of your app. If you’re joining someone else’s project you’re already off to a great start, as well, because you know exactly where all the elements will be stored and which of them will handle what.</p><p>By giving you less freedom, Rails frees you up to complete bigger and more complicated projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5bf07669526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Very Convenient Ruby Array Methods]]></title>
            <link>https://medium.com/@madelinedulchin/very-convenient-ruby-array-methods-8f6614ce217b?source=rss-ab2433dfe601------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f6614ce217b</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[array-methods]]></category>
            <dc:creator><![CDATA[Madeline Dulchin]]></dc:creator>
            <pubDate>Tue, 15 Nov 2022 16:57:15 GMT</pubDate>
            <atom:updated>2022-11-15T21:26:08.856Z</atom:updated>
            <content:encoded><![CDATA[<p>Learning Ruby has been by far the closest I’ve felt to being a 90’s movie hacker since starting this coding journey. Is the image below a scene from the Matrix, or an action shot of me learning Ruby?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*ONvCbQJOPZJtzyRPgqqm4A.jpeg" /><figcaption>source: <a href="https://www.wired.com/2011/03/0331the-matrix-film-released/">https://www.wired.com/2011/03/0331the-matrix-film-released/</a></figcaption></figure><p>Why does Ruby make me feel like I am Neo? Every time I need to perform some action on the data at hand, Ruby already has the built in method I need. And these methods are so intuitive and conveniently-named that it feels as though I’m making them up and Ruby is genuinely just a conversational partner who understands what I’m saying.</p><p>During the labs for this phase we’d be presented with prompts like, return the first item in an array. Surely, I would think to myself, this cannot be as simple as calling .first on the array. That would be too good to be true. It sounds like something I would make up if I were creating a programming language. And yet, that’s all it takes. Haha, I thought, it must just be a convenient built in method for the first item, but it’s probably a hassle to return any other item in the array. So when, to find the second item, I tried .second (mostly as a joke, because how can it be that pleasant!) and it worked, you can imagine my shock and delight. And you can see how I might be convinced that Ruby herself was actually just chatting with me.</p><p>Below I’ll be going over some basic and highly convenient array methods. Of course, there are lists of array methods all over the internet (like here: <a href="https://ruby-doc.org/core-2.7.3/Array.html">https://ruby-doc.org/core-2.7.3/Array.html</a>, for example), so instead of trying to go over all of them or sort them alphabetically or anything like that, these were selected by ability to make you feel like you’re the sunglasses-in-the-dark-wearing computer hacking main character of your own 90’s movie.</p><h3>Some Too-Good-To-Be-True Ruby Array Methods</h3><p>I’ll be demonstrating most of these methods using the array below</p><pre>array = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;]</pre><h4>.first (or .second, .third, .fourth, .fifth, etc)</h4><p>As mentioned above, .first will return the first (or second, third, fourth, etc) item in your array:</p><pre>array.first<br>&quot;a&quot;<br>array.second<br>&quot;b&quot;<br>array.third<br>&quot;c&quot;<br>array.fourth<br>&quot;d&quot;<br>array.fifth<br>&quot;e&quot;</pre><h4>.last</h4><p>You can find the final item in an array with .last:</p><pre>array.last<br>&quot;g&quot;</pre><p>With .first and .last you can pass them an integer, and they will return that number of items. Array.first(3), for example, will return the first three items:</p><pre>array.first(3)<br>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]<br>array.last(2)<br>[&quot;f&quot;, &quot;g&quot;]</pre><h4>.length</h4><p>.length will return the length of the array: <br>.size, an alias for .length, will do the same thing.</p><pre>array.length<br>7</pre><h4>.min</h4><p>returns the smallest integer, or first item alphabetically</p><pre>array.min<br>&quot;a&quot;</pre><h4>.max</h4><p>returns the largest integer, or last item alphabetically</p><pre>array.min<br>&quot;g&quot;</pre><h4>.minmax</h4><p>You thought there wasn’t a convenient option for getting both the min and max of an array at the same time? Think again!</p><pre>array.minmax<br> [&quot;a&quot;, &quot;g&quot;]</pre><h4>.sum</h4><p>If all the items in your array are integers it will add them together for you. If they’re strings, it will combine them all into one string.</p><pre>numbers = [1, 2, 3, 4, 5, 6]<br>numbers.sum<br>21<br>array.sum<br>&quot;abcdefg&quot;</pre><h4>.reverse</h4><p>Like all of these methods, .reverse does exactly what you think it should and reverses all of the items in the array:</p><pre>array.reverse<br>[&quot;g&quot;, &quot;f&quot;, &quot;e&quot;, &quot;d&quot;, &quot;c&quot;, &quot;b&quot;, &quot;a&quot;]</pre><h4>.rotate</h4><p>This method will take the first item in your array and move it from the front to the back. You can also specify the number of items you want rotated:</p><pre>array.rotate<br>[&quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;a&quot;]<br>array.rotate(4)<br>[&quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;]</pre><h4>.sample</h4><p>.sample is a super convenient way to get a random item from your array. And, like .rotate, can return multiple items when given a number:</p><pre>array.sample<br>&quot;b&quot;<br>array.sample(3)<br>[&quot;g&quot;, &quot;c&quot;, &quot;b&quot;]</pre><h4>.uniq</h4><p>returns a new array without an duplicate items</p><pre>doubles = [&quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;c&quot;]<br>doubles.uniq<br>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</pre><h4>.include?</h4><p>This method will return true if the given object is found within the array, and false if not:</p><pre>array.include?(&quot;b&quot;)<br>true<br>array.include?(&quot;r&quot;)<br>false</pre><h4>.tally</h4><p>You might run across a question that asks you to return the count of each unique item. You could definitely figure out a way to do that, but what if you were then asked to add that information to a hash? Sounds like a lot of work, you might be thinking — or might have if you hadn’t already seen the answer directly above this query— but don’t worry! .tally is here to save the day:</p><pre>array.tally<br>{&quot;a&quot;=&gt;1, &quot;b&quot;=&gt;1, &quot;c&quot;=&gt;1, &quot;d&quot;=&gt;1, &quot;e&quot;=&gt;1, &quot;f&quot;=&gt;1, &quot;g&quot;=&gt;1}<br><br>doubles = [&quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;c&quot;]<br>doubles.tally<br>{&quot;a&quot;=&gt;2, &quot;b&quot;=&gt;2, &quot;c&quot;=&gt;2}</pre><p>*** none of these methods will alter your original array. In every case they are adding each item to a new array, and returning that. If I were to call array, I’d have the same array I started with.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f6614ce217b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I love you, .map()]]></title>
            <link>https://medium.com/@madelinedulchin/i-love-you-map-bf268b18eaaa?source=rss-ab2433dfe601------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf268b18eaaa</guid>
            <dc:creator><![CDATA[Madeline Dulchin]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 13:23:07 GMT</pubDate>
            <atom:updated>2022-10-25T13:23:07.066Z</atom:updated>
            <content:encoded><![CDATA[<h3>I love you, .map()</h3><p>.map was introduced to me in phase 1 of Flatiron bootcamp and I thought to myself: not for me. I didn’t understand what .map was or why I would use it. It was introduced under the heading “array iteration”, so I knew it had something to do with iterating through arrays, but I could not have come close to telling you what. I had more pressing matters to understand, like figuring out what the DOM was or how to make buttons do what I wanted, and I figured that was that.</p><p>Phase 2 immediately re-introduced .map as the first and one of the most crucial steps of putting a collection of information on a page (and what is building a website other than that?)</p><p>Obviously I was alarmed to see this acquaintance-at-best-enemy-at-worst coming back to haunt me in my new phase when I thought I’d left it in the dust of phase 1. But, like all classic tales, my dislike of .map was nothing more than a misunderstanding and in the two weeks that have passed since our re-introduction we’ve fallen in love (at least I hope it’s mutual).</p><h3>What is .map? What does it do and why do I need it?</h3><p>Basically, .map() is a function that iterates over an array and creates a new one. It takes a callback, and applies that callback to each item in the array, returning a new array in which all the original items have been acted upon by that callback function.</p><p>— That might be a little confusing, so let’s look at some examples.</p><p><strong>Example 1: Doing some basic math on an array of numbers:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*8I14sWty0_a_gEvg0rw37A.png" /></figure><p>So we’ve got a basic array of numbers. Now let’s say that we want to multiply every item within the array by 2, but we don’t want to mutate the original array. How, you might ask, are we going to do that? .map, of course!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*CvcHg4emRIVqFuj-4MdMjw.png" /></figure><p>Our .map, attached to our numbers array, takes each item in the array and returns it in our new array, newNumbers, multiplied by 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*k1C0plPNAze0qZxsqjztHA.png" /></figure><p>As you can see, this function returns an array of the same length as the original, with every one of the original numbers multiplied by 2. How convenient! And, if I were to check on my original array, numbers, nothing has changed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*uP2i6dxafBg8r0jQIRO7PQ.png" /></figure><p>Useful, but not the most commonly employed use of .map in React. Typically what you’ll be doing with .map is rendering information to the DOM.</p><p><strong>Example 2: Rendering components to the DOM</strong></p><p>In this example I’m trying to create a to-do list, and all of the tasks that I’d like to have rendered onto the page in a nice orderly list are stuck in an array made up of objects.</p><p>Here’s my list of tasks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*a9kgEfhnFaMOZyvSrIcuRA.png" /></figure><p>I could, I suppose, create a list element by hand for each task and access it by index. There aren’t that many items here, so that wouldn’t be that much of a hassle.</p><p>But what if I have way more tasks? Or, as is the nature of a to-do list, I’m probably going to complete some of the items on my list and need to delete them, or new things are going to come up and I’m going to have to add items to the list.</p><p>Thats where .map() comes in. In this case, .map allows you to write a really brief and dynamic function to put each object in your array into its own list component. Here’s how that function might look:*</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*AHCSqohuAo9iREUM0eveAQ.png" /></figure><p>.map, as you can see, is really doing the heavy lifting for you. It’s taking every object in your task array and returning a new list item with the task description inside. By appending this within the To Do &lt;ul&gt;, we’ve got a dynamic to do list. You can add or delete, or change the data however you see fit. And look how much shorter that is than if you’d listed out each individual item in the list! Sorry I ever doubted you, .map.</p><p>Another cool example, if you want to take a look, is given here: <a href="https://www.pluralsight.com/guides/how-to-use-the-map()-function-to-export-javascript-in-react">https://www.pluralsight.com/guides/how-to-use-the-map()-function-to-export-javascript-in-react</a> . He uses the .map function to make an array of image-size objects into uniform strings of the information.</p><p>To recap:</p><p>.map allows us to dynamically, conveniently, and efficiently render information or update the information inside an array, and does so without mutating the original array. Everyone say “Thank you .map!”</p><p>*In this example I imported the data elsewhere and didn’t show that part for readability and because it’s not the focus of my ode to .map()</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf268b18eaaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Please Help Me Define Parameter and Argument]]></title>
            <link>https://medium.com/@madelinedulchin/please-help-me-define-parameter-and-argument-8dffa40d784d?source=rss-ab2433dfe601------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dffa40d784d</guid>
            <category><![CDATA[arguments]]></category>
            <category><![CDATA[parameter]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Madeline Dulchin]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 13:18:38 GMT</pubDate>
            <atom:updated>2022-09-28T13:18:38.820Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ll come clean: I’m still not sure what an argument or a parameter really is. Are they interchangeable? I don’t think so, but then why are people constantly using them as though they are? I know enough to fake my way through a conversation about them, but if you pushed back even a little you’d realize that they continue to baffle me.</p><p>I’ve got some hypothetically harder concepts down by this point (I can write a mean fetch request and probably even explain what’s going on with all that res.json business) but it’s truly the most basic of definitions that elude me. I took a quiz earlier this week on the basics of a JavaScript function and immediately failed at a multiple choice question where I just had to define a parameter. Not even in my own words, truly just picking one of five options. And the quiz didn’t ever tell me the right one! So I still don’t know!</p><p>So that’s what this blog post is: my journey to define an argument and a parameter in a way that makes sense to me and that I’ll retain. But, if I don’t retain it, at least I’ll have this helpful blog post to look back on. I assume, if you’ve reached this blog, you’re just as lost as me on this one.</p><p>I’ll start with some definitions I’ve crowdsourced (from the internet and people who know more than me)</p><h3>Parameters:</h3><ol><li>“<em>Parameters</em> are locally-scoped variables that are usable (“scoped”) to inside the function” -Flatiron module “Review: Functions”</li></ol><p>2. “a variable that must be given a specific value during the execution of a program or of a procedure within a program.” -<a href="https://www.dictionary.com/browse/parameter">Dictionary.com</a></p><p>3. “parameter is just a placeholder”- Alexis</p><p>I’ve ordered these from more complicated to less. Combining all three definitions makes it start to make sense to me. Parameters, basically just a placeholder that will eventually be given a specific value, are only usable within the function because they are “locally-scoped”, meaning that they are constrained to the function itself and only useable within it.</p><h3>Arguments:</h3><ol><li>“Function <strong>arguments</strong> are the real <strong>values</strong> passed to (and received by) the function.”-<a href="https://www.w3schools.com/js/js_function_parameters.asp">W3 Schools</a></li></ol><p>2. “arguments is an Array-like object accessible inside functions that contains the values of the arguments passed to that function” -MDN</p><p>3. “what you put into a function — what the function is going to use — it’s an input.”- Keshav</p><p>The argument is no longer a placeholder, it’s the actual value that is going to be used by the function.</p><h3>My Own Definition, Hopefully, Synthesized From All The Other Definitions I’ve Read:</h3><ol><li>parameter: the arbitrarily-named variable for each value, only within that function. The parameter is the locally-scoped variables <em>name</em></li><li>argument: the actual value thats going to be used in the function. The argument is the variables <em>value</em></li></ol><h3>Why Am I Using These?</h3><p>Parameters and arguments are what make functions function.</p><p>If I wanted to create a function to do some simple addition I might do something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*p1A8X425uaJnfLZ3Iu4pCw.png" /></figure><p>This function is adding together two numbers and returning their sum.</p><p>Parameters, or the arbitrary-but-hopefully-relatively-self-explanatory-names of our variable, go in the parenthesis after our function declaration. In this case, we’ve got a and b, which are basically standing in for our actual values later on. We are letting our function know that whatever we replace a and b with later on when we call, or invoke, our function is what we want javascript to add together. Without parameters our function wouldn’t know what to do with the information we give it.</p><p>The arguments, or the values of the variables we have given our function, are what we replace a and b with. If we didn’t include an argument, the function wouldn’t know what it was supposed to add together. It would have the values we wanted to use, but nowhere to put them.</p><h3>Other Things I’ve Found Helpful in Thinking about Parameters and Arguments</h3><p>Often you’ll hear that the argument is what we pass to the function*. I prefer to think of it as providing, or letting the function have, the value I want it to use. I know that sounds like a pretty tiny difference, but the rephrasing helps me.</p><p>An explanation I found helpful for thinking of the difference between arguments and parameters is that arguments can, and often will be, changed multiple times throughout my code. Why create a function if I only want to use it that one time? If I really just wanted to know the sum of 2 + 4 I wouldn’t have had to even write a function. I could have just put 2 + 4 and javascript would have given me 6. I write a function to invoke it a number of times. And arguments are what change, or the value we give the function to use, each time we invoke it.</p><p>I can call my function as many times as I want, and each time I can use new arguments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*6nj7cHfWIrdONRYlBYeKHQ.png" /></figure><p>*<em>I personally find this wording confusing, largely because of the way functions look. Aren’t I passing my sum function the parameters a, b, just as much as I am passing it my arguments, in that they are both in a set of parenthesis after the word sum? The word “passing” here sounds distinctly too passive to me. A function is all set up to do it’s job but it can’t until we give it the values we want it to use! I imagine the function absolutely chomping at the bit, desperate to get its hands on a value so it can finally do the one and only thing it was created to do. “Passing” just doesn’t cut it. We’ve got to be hurling our arguments</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dffa40d784d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>