4 min read

Loopy arrays, object stuff and practice things!

Loopy arrays, object stuff and practice things!

Ironhack Days 5, 6 and 7

Day 5

Deeper into JavaScript, scratching away at the surface of this amazingly cool programming language (yes, I said it!). Since I practiced all of this weeks ago, I almost forgot half of it again. Fundamentals like while and for loops I thankfully can explain with my eyes closed - but if I think back to early June, how much trouble I had with for-loops? Sheesh. The only thing that helped here was practice - just creating loop after loop after loop after loop.

You know, until all that other stuff came around for me. Like

.join()
.split()
.forEach()
.reduce()
.map()

But you shouldn't forget about the foundations, even if they appear to you as clunky or bulky.

The labs today addressed that: solve a bunch of puzzles without the more advanced methods like the above - it suddenly becomes a fun little game how to replace push (or .replace() ) with a loop. After that, it makes you really appreciate what you got with those array methods and what-not tools.

And it took me a while to get those labs done, and not without the help of my classmates! The problem was: I  could  only  thing of  "advanced" methods - an in this case, "advanced" means stuff like the above and not stuff  like promises or whatnot.

It does sound a bit "oh I'm so great"-ish saying that I had to think about it a second to come up with ideas how to solve some of the lab's puzzles, but it's just simple fact: when you come across something that  seems  easier and  cleaner and  shorter  you tend to forget the ways that seem  to be more work.  But never forget  loops.

Day 6

Deeper and deeper still, but we're still scratching at the surface here. From the super-basics to still basics - arrays and such. And at first, in June, when I learned about them I thought "this is some stuff you learn now and never use again" - which is obviously super nonsense. Arrays are so much - saving values for later, storing them in a place and sorting them, adding, retrieving, all things you need to do to have a working program, an app, a little game, what have you.

Everytime I'm doing an exercise or a lab or a kata on Codewars I'm reminded of the fact that arrays are essential.

So what we're essentially doing is a collection of little exercises, slide shows, VS Code demos and graphs and graphics powered by Figma on how to read and manipulate arrays and how to return data from a computation more efficiently - creating and manipulating objects. This is very much where the action starts - regarding Object Oriented Programming. But we only really got into that in a later class.

Since I already had a head start on the labs of this day I was able to assist two of my classmates with theirs a bit, since the last half hour or so of the Saturday class is always planned for getting started on the labs. Our instructor and TA's pop by to answer any question we might have - in my case, I had seen that the Jasmine testing we used (for the first time, mind) on  this lab  to check our code had a particular requirement - it wanted the specific function to  throw an  error, something I hadn't come across so  far. To speed it up: ALL of us had a problem with this, and only a look at the test's specs revealed that it  was expecting a very specific error message. No wonder the tests didn't work out without throwing the error with a verbatim message.

Overall, this was a really fun lab, just repeating the same thing over and over in different form; for me, what it did was really strengthening my loop-skills (especially for 2d arrays) as well as some array methods like .reduce() and .sort() and the use of the ternary operator.

Day 7

This day's lesson was a bit of a jump, not in any particular direction, but we started on a different topic already kind of broached the class before. Returning a value could be a very strict and rigid procedure, but with the use of a return object - or an object in general - things could get a bit more dynamic. So the topic at the core of the class was objects and and how they are pretty important for how we work with JavaScript. The lesson saw us creating a whole bunch of objects using object literals, including arrays in objects, arrays of arrays in objects, objects in arrays in objects and that kind of stuff.

I found that stuff less easy to grasp because I really had to wrap my head around it when I first encountered it at Odin, but I still picked it up pretty quickly (it just needed a few more references of source material before I was sure about it).

The lab of this class reinforced it: a sort of game of Clue (only that you couldn't really play it - the functions you wrote would spit out someone who killed Mr Boddy with a what in that room).

I didn't know that the person killed was named Mr Boddy. Having played only the German version of the game years ago, I was used to "Dr. Schwarz", or Dr. Black as he is called in the original UK version. In the US version, you have Mr Boddy who is nefariously murdered by someone with what in that room. So basically, you have a dead Boddy. I laughed a bit about that.

But what it entailed was creating a whole lot of objects - exercising the object syntax as well as getting to know your IDE a bit better (for example, multi-line editing in VSCode, replacing or jumping positions and such).

So far, so good - understandable, fun, and the exercises both in class and in labs really help to drive home the point. It's all good to learn about JavaScript during a talk and reading theory, but what really helps (and the only way that works for me) is to slap a few lines of code together to make something do something and then taking the steps one by one until it works.

And it will hopefully work. Because if not, I will find out even if I have to sit here till after midnight.

jmc