I’m still in the game

Somebody commented on one of my earlier posts today (glad I could help and thanks for sharing your solution) and it reminded me that I haven’t posted in a while. I do have another half dozen or so Bonfire solutions that I’ve completed and are ready to post, but the freeCodeCamp revamp a few weeks back threw me off. I got distracted by having to go back and finish up some of the Bootstrap and jQuery tasks (and now I’m working through the Basic Front End Development Ziplines). I should be posting the outstanding Bonfires this weekend though, if anyone is interested.

I’m just about done with Build a Personal Portfolio Webpage if anyone is interested in partnering through these Ziplines (or any of the Bonfires when I get back to that point).

‘Bonfire: Seek and Destroy’ or $!#@$% Array.filter()

The second Bonfire I got through this week is Seek and Destroy. For this Bonfire you have to take an array, filter out some values, and then return the filtered array. This Bonfire is supposed to teach you about the Arguments object (yup, it did that) and the description seems to hint that Array.filter() would be handy as well (maybe, but I couldn’t tell you). Here’s the code I used to solve it:

function destroyer(arr) {
  // Remove all the values
  var initial = arguments[0];
  var args = [];
  for (a=1;a<=arguments.length-1;a++){
    args.push(arguments[a]);
  }
  newArr = [];
  for (c=0;c<=args.length-1;c++){
    for (b=0;b<=initial.length-1;b++){
      if (initial[b]===args[c]){
        arr.splice(b,1);
      }
    }
  }
  //console.log(initial);
  //console.log(args);
  //newArr = arr.filter(checker);
  return arr;
}

I forgot to comment the code as I went, so I’ll walk you through it. This block of code here uses the Arguments object (and the arguments passed to the destroyer function) to set an initial array and an args array.

  var initial = arguments[0];
  var args = [];
  for (a=1;a<=arguments.length-1;a++){
    args.push(arguments[a]);
  }

This code here loops through each of the arrays I created above (initial and args), and if it finds a matching value uses Array.splice to remove that value from the initial array.

  for (c=0;c<=args.length-1;c++){
    for (b=0;b<=initial.length-1;b++){
      if (initial[b]===args[c]){
        arr.splice(b,1);
      }
    }
  }

And this just returns the initial array, now spliced.

  return arr;

But wait, what about those other lines of code, and where the hell is Array.filter? Well I never could get Array.filter to work, but Array.splice worked just great. As for the extra code, it’s just leftover from my filtering attempts. I hadn’t cleaned the code up because I wasn’t sure it was going to work.

‘Bonfire: Where art thou’ or why searching for help sometimes helps

Well so far I’ve managed to get through only two Bonfires this week. The first was the ‘Where art thou’ bonfire. For this you have to find all of the objects that have equivalent properties. Here’s the code I used:

function where(collection, source) {
  var arr = [];

  var sourceProp = Object.keys(source)[0]; // Take the first key, index=0
  console.log(sourceProp);

  for (i = 0; i<collection.length; i++){
    // Use collection[i][sourceProp] to take the value
    if (collection[i].hasOwnProperty(sourceProp) && collection[i][sourceProp] == source[sourceProp]){
       arr.push(collection[i]);
    }
  }

  return arr;
}

I spent way too long trying to figure this out, mostly because I misread what I was supposed to be doing in the first place. When I finally decided to start searching for an answer, the first result in Google was the code above (courtesy of Stack Overflow). Fortunately, once I took a look at the code I realized immediately what my problem had been, I’m an idiot who didn’t read the problem correctly.

So thank you to Stack Overflow for teaching me the importance of reading comprehension, and showing me working code.

Hello World

Welcome to my blog. I started this as a way to share my experience of working through the freeCodeCamp program. I stumbled onto freeCodeCamp while trying to find some advice on turning an idea I had into an engaging site. I’ve been plugging away at this for about a month, and have made it about halfway through the Basic Algorithm Scripting lessons. You can check out my progress on my profile page. I plan on posting here each time I start and finish a new lesson.

I don’t have any formal coding or web development training outside of a single semester of Visual Basic and a year of Java in college. I’ve completed the JQuery and JavaScript courses on Codecademy, done some PHP tutorials, and experimented a bit with Ruby, Python, and other languages.

In case you were curious about my professional background, here goes. I’m currently a technical writer doing SDLC documentation for SharePoint and Java development. Before switching to tech writing, I was the project manager for a small team of web developers mostly doing intranet pages in SharePoint. Even further back, I was a telecommunications/technology ¬†OSINT analyst. I’ve worked around code and web development, but it’s never been my real focus.