<?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: Rhymes Toasterface</title>
    <description>The latest articles on DEV Community by Rhymes Toasterface (@triplejdev).</description>
    <link>https://dev.to/triplejdev</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%2F15852%2Fae233dd2-8ace-414d-adeb-9d7c90828f56.jpg</url>
      <title>DEV Community: Rhymes Toasterface</title>
      <link>https://dev.to/triplejdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/triplejdev"/>
    <language>en</language>
    <item>
      <title>Day three - async/await and db refactor</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Sun, 10 May 2020 20:16:51 +0000</pubDate>
      <link>https://dev.to/triplejdev/day-three-async-await-and-db-refactor-2pap</link>
      <guid>https://dev.to/triplejdev/day-three-async-await-and-db-refactor-2pap</guid>
      <description>&lt;h2&gt;
  
  
  10/5/20 Step one. Still
&lt;/h2&gt;

&lt;p&gt;The async/await thing has been bothering me. I didn't do it because I had never used it and never really bothered/had the time to figure it out.&lt;/p&gt;

&lt;p&gt;So, I figured now was as good a time as any - I'm supposed to be learning, right?&lt;/p&gt;

&lt;p&gt;So for this instalment, dear reader, I went for the async thang.&lt;/p&gt;

&lt;p&gt;Turns out it wasn't really all that difficult. I changed the connection/client - added an async keyword:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ew3fOnRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/35szgdhhmlk45vkth65q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ew3fOnRm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/35szgdhhmlk45vkth65q.png" alt="async client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The bigger changes happened in the db functions, although they weren't really that big:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vkhLWkc7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/86kuq40yz107s0v9ldo5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vkhLWkc7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/86kuq40yz107s0v9ldo5.png" alt="async db functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other than this, I made some changes to the recipe interface:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--avV3UxMn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9117tf23pix65so4ej6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--avV3UxMn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9117tf23pix65so4ej6b.png" alt="recipe interface"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also changed the recipe db functions - mostly, I wasn't happy with the db and collection names.&lt;/p&gt;

&lt;p&gt;I was working with a db called 'Recipes'. Which kind of forced me to use collections by recipe type - main, dessert, whatever.&lt;/p&gt;

&lt;p&gt;I wasn't happy with this - what if I wanted to change the type of a recipe - who knows why, but I might want to. I would have to change the recipe type AND migrate it across collections.&lt;/p&gt;

&lt;p&gt;This wasn't the one - I now settled for a 'Toasterfaves' db and a recipes collection. Maybe there will be other things to save with this site? As well as this, you might note I added the dbName argument to the db functions. This will open up those functions to be usable later on if/when we add more dbs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PkiUUhZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ex0mycbv9h42it1wtmjz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PkiUUhZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ex0mycbv9h42it1wtmjz.png" alt="recipe db functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's pretty much it for now. I'm happier these things are done and I don't need to come back and refactor them further down the line.&lt;/p&gt;

&lt;p&gt;I guess next, I will have to expose these functions - I assume using express. Then, I will have to get that api running on the cpanel server. That'll be fun...&lt;/p&gt;

&lt;p&gt;Stay tuned...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one thing worth noting - I can't be sure any of this is correct! But it works. And I'm pretty happy with it. If you have any suggestions, let me know.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>cpanel</category>
    </item>
    <item>
      <title>Day two - envs, directory structure and db connections</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Thu, 07 May 2020 13:45:13 +0000</pubDate>
      <link>https://dev.to/triplejdev/day-two-envs-directory-structure-and-db-connections-oda</link>
      <guid>https://dev.to/triplejdev/day-two-envs-directory-structure-and-db-connections-oda</guid>
      <description>&lt;h2&gt;
  
  
  4/5/20 Step one. Still
&lt;/h2&gt;

&lt;p&gt;This evening, I did a bit more work - I started on the database connection and functions. Brave, huh?&lt;/p&gt;

&lt;p&gt;First things first - I found the connection details from Mongo Atlas for the new cluster I had created previously. Then, I set up some environment variables in my server terminal:&lt;/p&gt;

&lt;p&gt;I edited the &lt;span class="terminal-font"&gt;.bash_profile&lt;/span&gt; using the text editor of my choice (nano, what of it?). I added a few exported variables in there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;export MONGO_USER=&amp;lt;user name from mongo&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;export MONGO_PASSWORD=&amp;lt;password from mongo&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;export MONGO_PREFIX=&amp;lt;from the connection string&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you choose this route (I chose it because it is slightly more secure than plain text strings in my code base - I imagine it will go up to github at some point), don't forget to &lt;span class="terminal-font"&gt;source ~/.bash_profile&lt;/span&gt; after you have updated and saved it - this will make these new environment variables available to you on the server.&lt;/p&gt;

&lt;p&gt;Next, I created a bit of a file structure. By the way, it is probably time to mention I decided to use &lt;a href="https://www.typescriptlang.org/"&gt;TypeScript&lt;/a&gt; for this project. We use it at work, I like it, maybe you will too! Anyway, I have a main &lt;code&gt;index.ts&lt;/code&gt; in the root directory. I then have a &lt;code&gt;src&lt;/code&gt; directory as well. Within that, I have a &lt;code&gt;db&lt;/code&gt; directory, &lt;code&gt;recipes&lt;/code&gt; directory and an &lt;code&gt;interfaces.ts&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;db&lt;/code&gt; directory, I have an &lt;code&gt;index.ts&lt;/code&gt; and a &lt;code&gt;client.ts&lt;/code&gt;. In a brave move, I am going to introduce some images. This will give you a better idea of the starting structure (this may be refactored later, but I am making hay while the mental sun is shining):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TlvcC2pY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k4lcryta89g4vmiinhy1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TlvcC2pY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k4lcryta89g4vmiinhy1.png" alt="structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see I also added a &lt;span class="terminal-font"&gt;recipes&lt;/span&gt; directory with an index of its own as well.&lt;/p&gt;

&lt;p&gt;Inside the client file, I set up a Mongo connection using those environment variables I set in the server earlier:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oOgwcp62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zc8xzbzcerwqzsnjw0fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oOgwcp62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zc8xzbzcerwqzsnjw0fk.png" alt="connection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is nothing out of the ordinary here - I followed the &lt;a href="https://mongodb.github.io/node-mongodb-native/3.5/tutorials/connect/"&gt;Mongo docs&lt;/a&gt; for connecting with the nodejs driver.&lt;/p&gt;

&lt;p&gt;I guess the only sadness is not using async/await, but I am too tired to think about that. This works, and a refactor later won't hurt as both will still return a promise-y value. Let's just be happy there are no callbacks...&lt;/p&gt;

&lt;p&gt;I did it this way because I would have a reusable connection that I could use without having to reference the variables etc. every time. You might want to do it a different way, but I have written and reusable connection this way before and like it. &lt;em&gt;shrugs&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can see the db functions I added to use this connection in the next instalment. Same Bat-time, same Bat-channel.&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>cpanel</category>
    </item>
    <item>
      <title>Day one pt2 - initial setup, cpanel, mongo, node</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Thu, 07 May 2020 09:26:06 +0000</pubDate>
      <link>https://dev.to/triplejdev/day-one-pt2-initial-setup-cpanel-mongo-node-4gnk</link>
      <guid>https://dev.to/triplejdev/day-one-pt2-initial-setup-cpanel-mongo-node-4gnk</guid>
      <description>&lt;h1&gt;
  
  
  Episode two - electric boogaloo
&lt;/h1&gt;

&lt;h2&gt;
  
  
  3/5/20 Step one...still
&lt;/h2&gt;

&lt;p&gt;So, I cheated a bit....&lt;/p&gt;

&lt;p&gt;I started last night, but in the interest of documenting the process, I am retrospectively adding this information.&lt;/p&gt;

&lt;p&gt;I started thinking about this more properly last night. I logged in to cpanel and checked for terminal access - I think I had to request it through my provider before as they locked access down by default, but they seemed fine about adding it.&lt;/p&gt;

&lt;p&gt;I accessed that through the cpanel page and was presented with a terminal window. There, I was able to install &lt;a href="https://github.com/nvm-sh/nvm#install--update-script"&gt;nvm&lt;/a&gt;. Easy step one - once done, I could type &lt;span class="terminal-font"&gt;nvm use node&lt;/span&gt; to make sure I had a version installed and then &lt;span class="terminal-font"&gt;nvm alias default node&lt;/span&gt; to make sure the nvm version of node was the one accessed by new versions of the terminal.&lt;/p&gt;

&lt;p&gt;This all went swimmingly...&lt;/p&gt;

&lt;p&gt;Then I looked into installing mongo on the server. This looks like it needs &lt;code&gt;sudo&lt;/code&gt; or &lt;code&gt;su&lt;/code&gt; permissions to do it the easy way. This is when I started thinking about &lt;a href="https://www.mongodb.com/cloud/atlas"&gt;Atlas&lt;/a&gt; instead of installing on the server. This seems like it might be useful to learn anyway - we use all of these tools at work, but (probably similarly for most of you), it is already set up and we just build on it&lt;/p&gt;

&lt;p&gt;Fortunately, I already have a mongo account, but if you don't you will need to set one up - as I said, there is a free tier you can take advantage of.&lt;/p&gt;

&lt;p&gt;You will have to create a new cluster. Once this is provisioned, you can connect to it - mongo will ask you to whitelist an ip and set up a user. Once that is done, you should be good to go.&lt;/p&gt;

&lt;p&gt;At this point, you don't need to worry about creating any collections, tables or schemas - as soon as you insert from your app (as long as the connections are all set up correctly), mongo will allow you to connect to the cluster.&lt;/p&gt;

&lt;p&gt;I think that will do for today. Next time, we can look at getting a api directory set up and connecting to mongo.&lt;/p&gt;

&lt;p&gt;Time for a nap...&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>cpanel</category>
    </item>
    <item>
      <title>A new project. Back to basics</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Thu, 07 May 2020 07:55:56 +0000</pubDate>
      <link>https://dev.to/triplejdev/a-new-project-back-to-basics-1eh7</link>
      <guid>https://dev.to/triplejdev/a-new-project-back-to-basics-1eh7</guid>
      <description>&lt;h1&gt;
  
  
  Episode one - a new thing
&lt;/h1&gt;

&lt;h2&gt;
  
  
  3/5/20 Background and Plan
&lt;/h2&gt;

&lt;p&gt;So, I wanted to make me a React. Because I don't really know how to. So I dived straight in.&lt;/p&gt;

&lt;p&gt;I wanted to make a website to keep all of our favourite recipes in one place. Toasterfaves. Save using that minging old recipe book we have.&lt;/p&gt;

&lt;p&gt;Then I thought about it...&lt;/p&gt;

&lt;p&gt;What I actually wanted to make was an end to end app. FULL STACK BRO BRO. YEAH. BRO. Or something.&lt;/p&gt;

&lt;p&gt;So I started back right from the very beginning.&lt;/p&gt;

&lt;p&gt;Maybe it will help someone. Maybe not. But it might help me...&lt;/p&gt;

&lt;p&gt;First step - start React Udemy course.&lt;/p&gt;

&lt;p&gt;Second step - ignore that and start again.&lt;/p&gt;

&lt;p&gt;Third step - start writing the api for the app.&lt;/p&gt;

&lt;p&gt;Fourth step - ignore that and start at the VERY BEGINNING.&lt;/p&gt;

&lt;p&gt;REAL first step - hosting.&lt;/p&gt;

&lt;p&gt;I already have a &lt;a href="https://www.triplejdeveloping.com"&gt;website&lt;/a&gt;. I've had it for a very long time. As you can probably see from that website, I changed careers a few years back. I quit my office job and went to a coding bootcamp. The course was based around PHP/LAMP stack, but covered a bit of node towards the end. When I finished the course, I started writing a cms for a website for a private client. I used php - it was the most knowledge I had. I got some cheap Linux cpanel hosting and away I went. Everything on there is PHP. I've wanted to change over to node (I have been a sefver side dev for a few years now, and that is all written in node), but didn't get round to it - I didn't have ssh permissions for the server blah blah blah so made excuses to put it to the back of the pile. I thought now was maybe the time to get it to the top of the pile!&lt;/p&gt;

&lt;p&gt;This will be a series.&lt;/p&gt;

&lt;p&gt;I don't promise to release a new one on a schedule - I have too many kids to make promises like that. When I get round to doing a new bit of the project, I will write some more up.&lt;/p&gt;

&lt;p&gt;These are the things I plan to cover in this series:&lt;/p&gt;

&lt;p&gt;Get the server set up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Install node using nvm, to be able to manage the version easily&lt;/li&gt;
&lt;li&gt;  Use a database - I plan to use mongo, just because it is what I know and super easy to use

&lt;ul&gt;
&lt;li&gt;  I haven't decided whether to install it on the server and hold the dbs there - I could run a cron job on the cpanel to back up the data/dbs directory that mongo uses, but at the same time, I could just use atlas - mongo has a free tier and I don't plan to go over that - I was going to make a simple site to hold cooking recipes.&lt;/li&gt;
&lt;li&gt;  Atlas is probably a nicer idea - just in case 1 BILLION people want to copy my banging thai sweet potato and chicken soup&lt;/li&gt;
&lt;li&gt;  Connecting to atlas might be more interesting and a more useful use case for others&lt;/li&gt;
&lt;li&gt;  I might struggle to get set up on the server as I have no access to &lt;code&gt;sudo&lt;/code&gt; or even &lt;code&gt;su&lt;/code&gt;. There is no &lt;code&gt;apk&lt;/code&gt; or &lt;code&gt;yum&lt;/code&gt;. It's going to be a fun ride...&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;  Figure out how to expose the backend api through this server

&lt;ul&gt;
&lt;li&gt;  Create an api for the app&lt;/li&gt;
&lt;li&gt;  As I said, I plan to use the app for recipes, but it could go on to be used for a blog, for example, or other things&lt;/li&gt;
&lt;li&gt;  Basic crud routes, with authentication&lt;/li&gt;
&lt;li&gt;  Storing images - who wants to read about food without seeing a picture of some???

&lt;ul&gt;
&lt;li&gt;  I have toyed with the idea of storing images in a db as base64 for a while. At work, we store in an s3 bucket - this is another option - AWS has free tiers and access or size shouldn't be a problem.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;  Create a front end for the app

&lt;ul&gt;
&lt;li&gt;  Initially, I want to create a front end to display the stuff - I plan to use react, because I am interested, but may try Vue or A.N.Other by the time I get to this stage...&lt;/li&gt;
&lt;li&gt;  I haven't planned to set up a front end for the creation of items/recipes/whatevers.&lt;/li&gt;
&lt;li&gt;  This will probably come later on&lt;/li&gt;
&lt;li&gt;  Can use postman in the interim once the api is up and running&lt;/li&gt;
&lt;li&gt;  There is an admin section of my website, so I can put it behind there, but it isn't a big deal for me right now&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originially published at &lt;a href="https://www.triplejdeveloping.com/blogarticles?blog=step-one-day-one"&gt;triplejdeveloping&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>cpanel</category>
      <category>react</category>
    </item>
    <item>
      <title>What do I do?</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Wed, 06 Mar 2019 13:53:38 +0000</pubDate>
      <link>https://dev.to/triplejdev/what-do-i-do-3me5</link>
      <guid>https://dev.to/triplejdev/what-do-i-do-3me5</guid>
      <description>&lt;p&gt;As I have gotten older, my social life has waned, but every now and then, I venture out, just like in the good old days….&lt;/p&gt;

&lt;p&gt;Recently, I did just that. Met some friends, had some drinks, chatted. I hadn’t seen them for a while and the conversation turned to my work, my job. They asked if I was still enjoying it, if I had made the right decision to change careers etc.&lt;/p&gt;

&lt;p&gt;Then came the million dollar question: WHAT DO YOU ACTUALLY DO?&lt;/p&gt;

&lt;p&gt;Cue the charades answer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/11M1k4fIwVqPF6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/11M1k4fIwVqPF6/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Past that, I was pretty much stumped - it is &lt;em&gt;really&lt;/em&gt; difficult to explain what you do as a “developer” or “coder” when someone has no idea what you are talking about.&lt;/p&gt;

&lt;p&gt;So, I am going to try to answer it now…..&lt;/p&gt;

&lt;p&gt;These are the things (I can think of) that I do on a daily basis:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type/write “code”&lt;/li&gt;
&lt;li&gt;think&lt;/li&gt;
&lt;li&gt;stand up (you just stand up?)&lt;/li&gt;
&lt;li&gt;meetings - planning, estimations, spikes&lt;/li&gt;
&lt;li&gt;swim&lt;/li&gt;
&lt;li&gt;eat - lunch, fruit&lt;/li&gt;
&lt;li&gt;drink - coffee, hot chocolate, water, squash&lt;/li&gt;
&lt;li&gt;go home, work (sometimes)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of these are self-explanatory. The second half of the list is the easy stuff. In fact, it might be easier to work up from the middle…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meetings, planning, estimations, spikes&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Meetings: fairly obvious, even to the un-scrummed&lt;/li&gt;
&lt;li&gt;Planning, easy.&lt;/li&gt;
&lt;li&gt;Estimations? Well… yeah, fairly easy. We estimate how much &lt;strong&gt;effort&lt;/strong&gt; a job/task/story/thing will need to be completed. Sometimes this considers time, but mostly how hard it will be (and this is the important bit:) &lt;strong&gt;compared to other pieces of work we have completed&lt;/strong&gt;. This enables us to get a slightly more accurate idea of how difficult a job might be. We then do more planning on these smaller chunks of work. If we know something more simple took less effort/time, we know this thing will take longer, more people, more planning, more investigation beforehand etc.&lt;/li&gt;
&lt;li&gt;Spikes: these are time-limited “investigations” into the bigger chunks of work. It might involve individually looking into technologies that haven’t been used in our project before. It might be a few of us whiteboarding options, padding out ideas, thinking about where this thing might go in the future and how we can plan for that. These then help us estimate the bigger chunks of work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Stand up&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another bit of an odd one if you don’t agile/scrum/scrumbut, but effectively, everyone in a team stands up together and &lt;em&gt;generally&lt;/em&gt; talks briefly about three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What you did yesterday&lt;/li&gt;
&lt;li&gt;What you plan to do today&lt;/li&gt;
&lt;li&gt;What is blocking you (what is stopping you from getting what you plan/planned to do done)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It takes about 15 - 20 minutes, but ideally shouldn’t be too long. It helps get problems out in the open - if I am “blocked” by something, somebody else might have encountered that problem already. Talking about it might get different opinions or approaches which all help to get the job done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Think&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This one is obvious, but maybe not so much to some people. I have lots of things around my desk which you would NEVER see in any other job I have done:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rubik’s cubes&lt;/li&gt;
&lt;li&gt;A guitar&lt;/li&gt;
&lt;li&gt;Fidget spinner&lt;/li&gt;
&lt;li&gt;Colouring books, pens/pencils&lt;/li&gt;
&lt;li&gt;Books&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is good to think. All of the things above help clear my head. Sometimes, it is good to take a step back, slow down, think about what you are doing, then go back to it fresh. It doesn’t have to be hours, but sometimes any brain-rest time will help.&lt;/p&gt;

&lt;p&gt;It would also be very strange (and probably frowned upon) in most of the other jobs I have done to spend time just staring into space, thinking for any amount of time.&lt;/p&gt;

&lt;p&gt;But in this job, it helps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type / write code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the really difficult one. I guess it covers most of my time. But is the hardest to explain, as much as the Jim Carrey gif does try.&lt;/p&gt;

&lt;p&gt;How do you explain something very technical to somebody not necessarily non-technical, but with no idea of how to write any sort of code?&lt;/p&gt;

&lt;p&gt;I remember this from when I was a kid:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;10 Print “Hello”&lt;br&gt;&lt;br&gt;
20 Goto 10&lt;br&gt;&lt;br&gt;
Enter&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’ve always enjoyed messing around with computers, always dabbled on and off with some sort of code (I also remember trying to figure out linux on a ps2!). So it &lt;em&gt;kind of&lt;/em&gt; makes sense to me. But if this doesn’t sound like you, it probably will make sense if I explain what I do.&lt;/p&gt;

&lt;p&gt;I mostly focus on backend development in my day to day work. This means that instead of programming the things you see in your browser, I write the bits that you don’t see. For example, if you log into your online banking, it shows you all of your accounts, savings, credit cards etc.&lt;/p&gt;

&lt;p&gt;These will all (most likely) be stored in a database. The developer will then build a bridge between the browser and the database. This will involve retrieving the appropriate data from the database (somehow) and sending it back to the browser (by witchcraft, normally).&lt;/p&gt;

&lt;p&gt;You want to make a payment/transfer somewhere? You put the payment information into the online banking in the browser, the backend developer takes your request for a transfer, does some stuff, then the money arrives at the destination.&lt;/p&gt;

&lt;p&gt;This is where the planning and spikes etc. come into play - I could just delete the amount from the one account record and add it to the other, but that would just be silly. What if you don’t have enough money to transfer in the first place? What if the account/destination you want to send money to doesn’t exist? What if there are tax implications of where you are transferring to? What if, what if, what if….&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL:DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is what a developer does&lt;/strong&gt; - it is working with the what ifs. The whys. The whens and the hows: dealing with those, figuring out how to handle them, then converting those thoughts, ideas and plans into a language that computers understand using an already constructed language with different operators and built-in functions to make that as simple and as clear as possible.&lt;/p&gt;

&lt;p&gt;Any clearer? Maybe, maybe not. It’s got to make a bit more sense than the typing mime, right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/MM0eFa1iaJ9ja/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/MM0eFa1iaJ9ja/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>agile</category>
      <category>softwaredevelopment</category>
      <category>developer</category>
      <category>developerrelations</category>
    </item>
    <item>
      <title>Adventures in Javascript pt.2</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Sun, 01 Oct 2017 11:01:15 +0000</pubDate>
      <link>https://dev.to/triplejdev/adventures-in-javascript-pt2-e38</link>
      <guid>https://dev.to/triplejdev/adventures-in-javascript-pt2-e38</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F888%2F1%2A2kLbv7LDPIw0dq7cRnR4Kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F888%2F1%2A2kLbv7LDPIw0dq7cRnR4Kg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, as &lt;a href="https://dev.to/triplejdev/adventures-in-javascript-pt1"&gt;last week’s article&lt;/a&gt; was such a success (thanks for all the likes and retweets, by the way), I thought I should continue where it left off!&lt;/p&gt;

&lt;p&gt;So, last time, we talked about map, filter and reduce, how they work and what they look like behind the scenes.&lt;/p&gt;

&lt;p&gt;This time, we will talk about &lt;strong&gt;composing&lt;/strong&gt; those functions, or &lt;strong&gt;chaining&lt;/strong&gt; them together.&lt;/p&gt;

&lt;p&gt;Again, we will look at how this looks done with our hand-made functions to get a feel for it, then do it with the “real JS functions.&lt;/p&gt;

&lt;p&gt;Short and sweet. Nice. Let’s crack on.&lt;/p&gt;

&lt;p&gt;We had an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [1,2,3,4,5,6,7,8,9];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using our last functions, we will map over it, adding one to each, filter it down to numbers over 5, then reduce what is left down to a total of these values. Expecting a total of 40. I think… (quick maths, u know).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F571%2F1%2AAgQYwKPN_IkoMcNUuJVjmQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F571%2F1%2AAgQYwKPN_IkoMcNUuJVjmQ.png"&gt;&lt;/a&gt;Man’s notÂ hot&lt;/p&gt;

&lt;p&gt;Here goes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let ourMapResults = map(nums, addOne);
// [2, 3, 4, 5, 6, 7, 8, 9, 10]

let ourFilterResults = filter(ourMapResults, moreThanFive);
// [6, 7, 8, 9, 10]

let ourReduceResults = reduce(0, ourFilterResults);
// 40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hurrah, and indeed, HUZZAH.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F312%2F1%2AehHnVThWqH1kGs5upYtGvQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F312%2F1%2AehHnVThWqH1kGs5upYtGvQ.jpeg"&gt;&lt;/a&gt;So, soÂ happy&lt;/p&gt;

&lt;p&gt;And, as expected, this works fine. It’s fairly simple.&lt;/p&gt;

&lt;p&gt;“So, what’s the beef ? you may find yourself asking (you do, right?).&lt;/p&gt;

&lt;p&gt;Firstly, you are creating all of these new variables just for the sake of being able to pass them to the next function in the chain. They won’t be used again, they won’t fulfil their life goal as variables. Or something. You wouldn’t want that for your variables, would you?&lt;/p&gt;

&lt;p&gt;Also, each item in the chain is doing &lt;strong&gt;just one thing.&lt;/strong&gt; It is easy to keep track of what is going on.&lt;/p&gt;

&lt;p&gt;Also, this is a VERY simple example. These chains can go on for a very long time and can get vey complicated. You would have extra variables everywhere, your code base would be (probably) a lot bigger, less maintainable and a lot less clear.&lt;/p&gt;

&lt;p&gt;There are probably lots more reasons it is better, but look - it’s a Sunday morning. Stop picking on me!&lt;/p&gt;

&lt;p&gt;Anyway - now, let’s do than the “real” way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let reduceResults = nums.map(addOne)
  .filter(n =&amp;gt; n &amp;gt; 5)
  .reduce((sum, num) =&amp;gt; sum + num, 0)
// 40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F640%2F1%2Atk06nEalW_g3TbQlNODQJA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F640%2F1%2Atk06nEalW_g3TbQlNODQJA.png"&gt;&lt;/a&gt;Great success&lt;/p&gt;

&lt;p&gt;Something to watch out for in this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let reduceResults = nums.map(addOne)
  .filter(n =&amp;gt; n &amp;gt; 5)
  .reduce((sum, num) =&amp;gt; sum + num, 0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is the values being used. Firstly, this looks quite strange:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let reduceResults = nums.map(addOne)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;addOne doesn’t have anything passed in to it. Really, this is just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let reduceResults = nums.map(eachNumber =&amp;gt; addOne(eachNumber))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;map walks through the array and passes each value to the function given (remember, it is just a for loop).&lt;/p&gt;

&lt;p&gt;Each function after it is taking the result of the previous one in the chain and bringing it in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// n = nums.map(addOne)

.filter(n =&amp;gt; n &amp;gt; 5)

/*
* It is worth noting here that the name of n can be anything. It is
* generally shortened as much as possible, but this is where it is
* made, you can call it what you want!
*/

.filter(numberOfMagicBeans =&amp;gt; numberOfMagicBeans &amp;gt; 5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just as an aside, some of you may be familiar with PHP and its dot concatenation (I’m thinking of you here, Bert):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“this .  is , “a . “string”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may help to think of chaining functions to work in a similar way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"nums.map(addOne)" . "filter(n =&amp;gt; n &amp;gt; 5)" . "reduce((sum, num) =&amp;gt; sum + num, 0)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All you are really doing with the dot is accessing the methods stored on the JS &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" rel="noopener noreferrer"&gt;array prototype&lt;/a&gt; object, over and over again. Remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nums.map(addOne) 
// nums is an array (array.prototype.map)

thatNewArray.filter(n =&amp;gt; n &amp;gt; 5) 
// (array.prototype.filter)

newerArray.reduce((sum, num) =&amp;gt; sum + num, 0) 
// (array.prototype.reduce)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, don’t let the ES6 arrow functions confuse you.&lt;/p&gt;

&lt;p&gt;They make chains like this easier to read, but watch out for the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions" rel="noopener noreferrer"&gt;way they bind to this&lt;/a&gt; if you have any OO-ish code.&lt;/p&gt;

&lt;p&gt;Really, all we are saying is,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nums.filter(function (number) { 
    return number &amp;gt; 5;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The filter might look a bit tricksy because of all the equals signs and angle brackets (especially if we were checking for &amp;gt;= instead of just &amp;gt;)!&lt;/p&gt;

&lt;p&gt;So, there we go. Nice, pretty composed functions.&lt;/p&gt;

&lt;p&gt;As before, you can try this in your own terminalâ€Š–â€Šcopy and paste, it should work the same way.&lt;/p&gt;

&lt;p&gt;If you have any questions, drop me a line.&lt;/p&gt;

&lt;p&gt;Maybe there will be more (if I can think of a topic…).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F420%2F1%2AM4q-Tm9RCI1oXuXprPyHCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F420%2F1%2AM4q-Tm9RCI1oXuXprPyHCQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>filters</category>
      <category>javascript</category>
      <category>composing</category>
      <category>functional</category>
    </item>
    <item>
      <title>Adventures in Javascript pt.1</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Sun, 24 Sep 2017 18:12:36 +0000</pubDate>
      <link>https://dev.to/triplejdev/adventures-in-javascript-pt1</link>
      <guid>https://dev.to/triplejdev/adventures-in-javascript-pt1</guid>
      <description>&lt;p&gt;I keep thinking about writing more, but the more I think about it, the less I do it. So today I stopped thinking and started writing.&lt;/p&gt;

&lt;p&gt;It can only go downhill from here…&lt;/p&gt;

&lt;p&gt;Mostly, I couldn’t think of anything to write about. Most things I know have been written about TO DEATH. But today, I realised: that’s ok! Everyone learns things differently (which is also ok, by the way), so it may be that somebody doesn’t understand something because it just hasn’t been demonstrated, or explained, in a way that suits their learning style.&lt;/p&gt;

&lt;p&gt;As well as that, they say the best way to cement your learning of something is to write it down, or pass it on. Maybe this will help someone, even if that someone is just me!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F888%2F1%2Agj0PczAJKxzDtNf7aMrLFg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F888%2F1%2Agj0PczAJKxzDtNf7aMrLFg.png"&gt;&lt;/a&gt;Some sort of adventure-type dude&lt;/p&gt;

&lt;p&gt;This morning, I was thinking about compositional chaining of functions in Javascript — something we are doing more and more of at work as we move to a more functional style (yes, yes - I know it’s not REALLY functional programming, but it’s a step in the right direction. Note, I said STYLE. We’re not going full blown Haskell and twiddly moustaches just yet…).&lt;/p&gt;

&lt;p&gt;Anyway, I thought I would put down my thoughts on the old favourites - map, filter and reduce. These took some brain-wrangling to get my head around. I read a lot, watched a lot of videos (thanks &lt;a href="https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript" rel="noopener noreferrer"&gt;Professor Frisby&lt;/a&gt;), but it just wouldn’t stick. They aren’t difficult, but my brain just couldn’t deal with it, for whatever reason.&lt;/p&gt;

&lt;p&gt;So, first up is  &lt;strong&gt;Map&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Map can be called on an array, which then calls the function passed in to it on each item in the first array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addOne = num =&amp;gt; num + 1;
let nums = [1,2,3,4,5,6,7,8,9];
let jsMap = nums.map(addOne); // [2, 3, 4, 5, 6, 7, 8, 9, 10]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can paste this into your editor, or IDE and run with Node to see this for yourself (same with all of these examples).&lt;/p&gt;

&lt;p&gt;It’s also useful to remember that this doesn’t have to be a function passed in (although, this will probably prove more beneficial in filter and reduce):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [1,2,3,4,5,6,7,8,9];

let jsMap = nums.map(num =&amp;gt; num&amp;gt;= 5);
// [false, false, false, false, true, true, true, true, true]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important thing about map is that &lt;strong&gt;the original array is unmodified:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addOne = num =&amp;gt; num + 1;
let nums = [1,2,3,4,5,6,7,8,9];
let jsMap = nums.map(addOne); // [2, 3, 4, 5, 6, 7, 8, 9, 10]
console.log(nums); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems to me that this is on of the main bonus points of Functional Programming - &lt;strong&gt;immutability&lt;/strong&gt;. Basically, this means that the original &lt;em&gt;thing&lt;/em&gt; remains unchanged. Not mutated. By radiation or any other thing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2AF4bhZugZLbxJtVcYXPknuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2AF4bhZugZLbxJtVcYXPknuw.png"&gt;&lt;/a&gt;Map. Innit.&lt;/p&gt;

&lt;p&gt;So, back to my opening gambit- what is different about this explanation? I’m sure you’ve seen the addOne function written a trillion times if you’re trying to get your head around these “pure functions. Well, nothing. So far.&lt;/p&gt;

&lt;p&gt;But now, I thought I would write a manual map function. Using good, old-fashioned JavaScript for loops (although, these are now pretty much the Devil). Everyone understands a forloop. If you don’t, I would go back to something more basic….&lt;/p&gt;

&lt;p&gt;So, here goes (using our addOne function from earlier):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = (arr, func) =&amp;gt; {
  let results = [];
  for(let i = 0; i &amp;lt; arr.length; i++) {
    let result = func(arr[i]);
    results.push(result);
  };

// Note that results is returned -
  // the original array that was passed in is non-radioactive

return results;
  }

let ourOwnVerySpecialMapResults = map(nums, addOne);
// [2, 3, 4, 5, 6, 7, 8, 9, 10]

// Nums is still unchanged
console.log(nums); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A couple of things to note - the original nums array hasn’t become radioactive (or changed in any way). Where the addOne function is passed in to our map, only the name is passedwithout the function being called - that is done in the manual map we wrote.&lt;/p&gt;

&lt;p&gt;But the main thing to take away from this is that &lt;strong&gt;it is just a for loop!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every result of the array value being passed to the function is pushed to a new array that is returned.&lt;/p&gt;

&lt;p&gt;I guess the next question is: if it is this easy, why do we use the JS map? Well, we can easily chain other functions on to the end of our mapped result. More on that later. Part 2, maybe (if there is one)…&lt;/p&gt;

&lt;p&gt;Next, &lt;strong&gt;Filter:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As with map, filter is really just another for loop in disguise. It walks through an array, checks each value and passes it to a new array if the value matches expectations. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [1,2,3,4,5,6,7,8,9];
let jsFilter = nums.filter(num =&amp;gt; num &amp;gt; 5); // [6, 7, 8, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, it walks through nums, checks each value to see if it is greater than five:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;num =&amp;gt; num &amp;gt; 5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And returns it in the array if it is. Simples.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2A-5TVKUIC9xGONGkqGYl5Zw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2A-5TVKUIC9xGONGkqGYl5Zw.jpeg"&gt;&lt;/a&gt;Filter. Innit.&lt;/p&gt;

&lt;p&gt;There we have it, a simple JS filter. As before, let’s write our own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const moreThanFive = num =&amp;gt; {
  if (num &amp;gt; 5) {
    return num;
  }
}

const filter = (arr, check) =&amp;gt; {
  let results = [];
  for(let i = 0; i &amp;lt; arr.length; i++) {
    if (check(arr[i])) {
      results.push(arr[i]);
    }
  };
  return results; // nums is still non-mutant
};

let ourOwnVerySpecialFilterResults = filter(nums, moreThanFive);
// [6, 7, 8, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As before, it is just a for loop, but with an if statement inside that controls what is pushed to the results array.&lt;/p&gt;

&lt;p&gt;Is this making sense? Are you with me? I hope so…&lt;/p&gt;

&lt;p&gt;Finally, &lt;strong&gt;Reduce:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So. Reduce takes two things: a function and a ‘3.5 inch floppy disk’ (or storage device of your choice). It walks through the array it is called on, passes each value to the function and then saves it to the floppy disk (Minions USB memory stick). The floppy disk doesn’t have to be a number, it can be an array etc. - just remember that it will stick to it’s type: if your floppy disk (64gb Sandisk micro SD card) is an array to begin with, the results of the function will be pushed to that array. If it is a number you can dictate what to do - add, subtract etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let jsReduce = nums.reduce((sum, num) =&amp;gt; {
  if (moreThanFive(num)) {
    return sum + num;
  } else {
    return sum; // nums is unaffected still
  }
// The floppy disk here is the (number) 0 passed after the function:
}, 0);
// 30 (6 + 7 + 8 + 9)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will go through our nums array, check if the value is moreThanFive. If it is, it will save it to the floppy disk (spiral bound, lined notebook).&lt;/p&gt;

&lt;p&gt;You can think of it as a kind of map function, but all of the results are smooshed down into one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2AXdsk3ImRVrfZ_KZB-qtAVA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F300%2F1%2AXdsk3ImRVrfZ_KZB-qtAVA.jpeg"&gt;&lt;/a&gt;Reduced. Geddit?&lt;/p&gt;

&lt;p&gt;This is probably the more complicated of the three. Take some time to make sure you get &lt;em&gt;what&lt;/em&gt; it has done, not necessarily &lt;em&gt;how&lt;/em&gt; it has done it.&lt;/p&gt;

&lt;p&gt;So, let’s try writing our own reduce function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const reduce = (floppyDisk, arr) =&amp;gt; {
  for(let i = 0; i &amp;lt; arr.length; i++) {
    if (arr[i] &amp;gt; 5) {
      floppyDisk += arr[i];
    }
  };
  return floppyDisk; // nums is still not a mutant/zombie/whatever
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a very simple version - it will only work with numbers, but you get the idea. The JS version is much more powerful - it can push to arrays etc.&lt;/p&gt;

&lt;p&gt;BUT, you can see it is &lt;strong&gt;still&lt;/strong&gt; just a forloop with an if check inside it.&lt;/p&gt;

&lt;p&gt;I hope this has demistified these three higher-order functions. I think I was fairly confident in using them before now, but writing this has really cleared it up for me.&lt;/p&gt;

&lt;p&gt;Give them a try, see how it works out for you.&lt;/p&gt;

&lt;p&gt;If it helps, let me know - leave a comment, retweet or whatever.&lt;/p&gt;

&lt;p&gt;If it’s wrong, let me know.&lt;/p&gt;

&lt;p&gt;There may be a better way to do it than this, but I’ve tried to keep it clear and simple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REMEMBER KIDS: Reducing variables down to one letter REALLY doesn’t help anybody when they are trying to learn.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>composing</category>
      <category>filters</category>
      <category>maps</category>
      <category>reduce</category>
    </item>
    <item>
      <title>Hi, I'm Rhymes</title>
      <dc:creator>Rhymes Toasterface</dc:creator>
      <pubDate>Sun, 09 Apr 2017 07:31:32 +0000</pubDate>
      <link>https://dev.to/triplejdev/hi-im-rhymes-toasterface</link>
      <guid>https://dev.to/triplejdev/hi-im-rhymes-toasterface</guid>
      <description>&lt;p&gt;I started programming properly in September of 2016. I started my first commercial job as a Software Engineer in March 2017. &lt;/p&gt;

&lt;p&gt;You can find me on Twitter as &lt;a href="https://twitter.com/TripleJDev" rel="noopener noreferrer"&gt;@TripleJDev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I live in Bath, UK.&lt;/p&gt;

&lt;p&gt;I work for &lt;a href="https://seccl.tech" rel="noopener noreferrer"&gt;Seccl Technology&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: JS/Node.&lt;/p&gt;

&lt;p&gt;I am currently learning more about Typescript/Docker/allthethingsidontknow.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
