Day 1: freeCodeCamp’s Learn Basic JavaScript “Using Objects for Lookups” & “Testing Objects for Properties”

Marbled surface with an iPad in the upper left corner and an Apple keyboard in the bottom right corner.

Wow, what a wordy title!

As I stated for my introductory post “Another Attempt at #100DaysofCode”, I wanted to see this challenge through! My main source of projects will be dependent on the non-profit freeCodeCamp (or fCC for short) as they have a lot of helpful tutorials on learning the basics of different programming languages. JavaScript at the moment is a language I’d like to become more proficient in as I journey through this web developer path.

Some of the challenges have stumped me – this one was no exception. This subsection focuses on objects, a variable that can store different types of variables that relate to it. The variables within are known as properties of that object. A similarity fCC and other programming websites use is an item or animal that has many words that can describe it. An example I made up can be seen below (and more information can be found at W3Schools’ JavaScript Objects article here). In this case, the object is humanFace and the properties are eyes, ears, eyebrows, mouth, and hair.

var humanFace = {

eyes: 2,

ears: 2,

eyebrows: 2,

mouth: 1,

hair: 10000 /* I'm sure a person has more hair than this but for the sake of simplicity I'm sticking with this number :) */

};

My focus was on “Using Objects for Lookups” as I had been stuck on it for some time now. This challenge was compared to using a dictionary to look up words. Turns out the one thing I was missing from completing the challenge correctly was a single line of code! I won’t give away the answer, but I will say it tied many of the previously included variables together and it was simpler than I imagined it to be. Once I received guidance from the website’s tutorial video for the lesson, it all clicked into place. This helpful resource can be found on their YouTube channel here.

My next question, “Testing Objects for Properties”, involves taking an object and a property into a function and seeing whether the property is included within. If this is true, it needs to give this value back to the function. Otherwise, it will give itself a negative message. I was able to piece together the requirements and proper behavior after a few reads but I’m still trying to determine why I haven’t been able to solve it. This will be an issue I’ll look deeper into tomorrow, hopefully with better success.

Background image by Alltechbuzz on Pixabay.