Days 23 & 24: Almost Done with Basic Algorithm Scripting

Days 23 & 24: Almost Done with Basic Algorithm Scripting

#100DaysOfCode Challenge

Writing basic JavaScript algorithms is both frustrating and fun at the same time. Here are my entries for Days 23 and 24 of #100DaysOfCode. You can read my full journey on GitHub.

Day 23: August 28, 2022

Today’s Progress:

Today I read Chapter 6 ‘The Secret Life of Objects’ in Eloquent JavaScript by Marijn Haverbeke and I completed a few challenges on Basic Algorithm Scripting section of the JavaScript course from freeCodeCamp. I’m currently 69% complete with this section.

Here are some quotes and key ideas from Eloquent JavaScript:

  • “The core idea in object-oriented programming is to divide programs into smaller pieces and make each piece responsible for managing its own state.”
  • “Different pieces of such a program interact with each other through interfaces, limited sets of functions or bindings that provide useful functionality at a more abstract level, hiding their precise implementation.”
  • JavaScript currently doesn’t support a way to distinguish from public and private properties so “it is also common to put an underscore (_) character at the start of property names to indicate that those properties are private."
  • Encapsulation is the idea of separating interface from implementation
  • “In addition to their set of properties, most objects also have a prototype. A prototype is another object that is used as a fallback source of properties.”
  • “JavaScript’s prototype system can be interpreted as a somewhat informal take on an object-oriented concept called classes. A class defines the shape of a type of object — what methods and properties it has. Such an object is called an instance of the class.”
  • “By convention, the names of constructors are capitalized so that they can easily be distinguished from other functions.”
  • “JavaScript classes are constructor functions with a prototype property.”
  • “The class keyword starts a class declaration, which allows us to define a constructor and a set of methods all in a single place."
  • In programming, the word map refers to two different things: as a verb it means to transform a data structure by applying a function to it while as noun it is a data structure that associates values (the keys) with other values.
  • To avoid confusion, “JavaScript comes with a class called Mapthat is written for this exact purpose. It stores a mapping and allows any type of keys"
  • “The methods set, get, and has are part of the interface of the Map object"
  • “When a piece of code is written to work with objects that have a certain interface — in this case, a toString method—any kind of object that happens to support this interface can be plugged into the code, and it will just work. This technique is called polymorphism. Polymorphic code can work with values of different shapes, as long as they support the interface it expects."
  • “Symbols are values created with the Symbol function. Unlike strings, newly created symbols are unique—you cannot create the same symbol twice."

a large image of the thinking emoji displayed on a phone Photo by Markus Winkler on Unsplash

Thoughts:

The concepts in Chapter 6 of Eloquent JavaScript were challenging to wrap my brain around. I think I’ll need to read more about how prototypes, classes, symbols, and matrices work in JavaScript. I also found the challenges on freeCodeCamp difficult as well, particularly the challenge about capitalizing the first letter in a string.

My first attempt did not work. I surfed around the internet to find some ideas for solutions, but those didn’t work either (see below for some references). In the end, I consulted the freeCodeCamp hints and solutions. I modeled my response after that, but I’m still unsure why my first attempt didn’t work and (stupidly) I didn’t save it so I could play around with it later, outside of freeCodeCamp’s interpreter, or show it to someone else to get help on it. -_-

Overall, while today’s session was challenging it was a good reminder to be patient and move slowly.

References:

For my progress visit the timeline on my freeCodeCamp Profile.


Day 24: August 29, 2022

Today’s Progress:

I completed challenges on the Basic Algorithm Scripting section of the JavaScript course from freeCodeCamp. I’m currently 94% complete with this section. The challenges focused on using loops, indexing, string conversion, and other concepts learned up until this point.

a 3-D image of a human skeleton with the hand held up to the chin in a ‘thinking’ posture Photo by Mathew Schwartz on Unsplash

Thoughts:

As with the previous challenges in this section they are both exciting and difficult to complete. I’m enjoying being able to start a script from scratch and work to completion on it, but also finding it difficult when it doesn’t work. I’m know this is all part of the learning process and probably mimics what a developer’s job is like, but diving in tutorials and forum posts is not as convenient as poking your co-working for help when you need it.

Overall, I’m satisfied with my progress today. I would have liked to finish the section completely (only one challenge left!), but I’m too tired from the work day.

For music today, I drifted away from Battlestar Galactica and listened to Mozart’s Piano Concerto №23 on repeat.

References:

I found the following tutorials useful in today’s session:

For my progress visit the timeline on my freeCodeCamp Profile.

You can read my full #100DaysOfCode journal on GitHub