CodeNewbie Community 🌱

Cover image for Commit5 //JavaScript Fundamentals [Factory Functions]
Janet Webster
Janet Webster

Posted on • Updated on

Commit5 //JavaScript Fundamentals [Factory Functions]

Picture of the sunset in Bequia

I am learning with Skillcrush. Please check them out and consider signing up if you're looking to break into tech! Receive $250 off your course by using the link above.
NOTE: this discount is for Break Into Tech + Get Hired package exclusively. It's the same program I am participating in!

Factory Function Pattern [Intro Video]

allow you to design a pattern to quickly build several objects that share the same characteristics, AKA properties

allows you to loop over properties of a function

Not to be confused with FOR...OF LOOP.

Factory Functions & Looping Objects

the purpose is of the return statement is to return the property object

Factory functions are useful because of their flexibility in using parameters to pass values to the object they create. loops are used when you want to access just the key, the value, or both. It can be used to loop through one object or multiple.

The loop can be combined with an array to loop through multiple objects.

These lessons were relatively straight forward. My main takeaway is I'd like to find a way to columnize this. Instead of have it repeat, but I'm sure we'll get there.

GitHub Repo for Factory Functions & Looping Objects

Practice Quiz: Factory Functions

I guess I must be digesting what I'm studying because I only had like one error on the quiz! So I'm going to take a break and then try to smash through the rest of this module before the end of the week!

I wasn't able to finish Factory Functions within last week. I ended up re-assessing with my league, Charlotte Roller Derby, and placed on a roster that had a game up in Cleveland, Ohio on Saturday. So I spent Friday driving up there. I was able to visit with my family in southern Ohio and then compete in the game Saturday night.

It was a lot to be back. Definitely a challenge. I'm still recovering from the travel and the game, but I'm excited to dive back into these lessons and see what all I've retained.

Factory Function Pattern for Pets

I had a rely on the solution code a few times, but overall I felt good about my interpretation of the instructions and the code I generated.

I was most proud of knowing to type

this.isTired += 1;
Enter fullscreen mode Exit fullscreen mode

without having to look it up!

this.isTired also feels very representative of how I feel right now!

GitHub Repo for Factory Function Pattern for Pets

Display Pet Objects

This one was a lot more difficult. It called back to some of the earlier lessons and I couldn't quite remember how to do some of those things. While also using some new methods that are simpler which I didn't know to use instead of a potential older way to write the code.

I relied pretty heavily on the solution code, but I typed everything up to the best of my ability first before checking the solution to see how they wrote it.

GitHub Repo for Factory Function Display Pet Objects

Practice Exercises: Factory Function

Exercise #1
My brain feels off today. I typed out as much as I could, but I was missing a lot of the context clues for what I needed to accomplish in this exercise. The animals are also acting crazy today, so any little distraction like that today is throwing me way off.

Overall I still feel like I'm beginning to grasp concepts.

It came with a code along video and I didn't even realize it! Oh well.

GitHub Repo for Practice Exercises Factory Function 1

Exercise #2
This one was a struggle. We're now bringing a lot of things together and my brain just doesn't quite grasp everything. When I see it, it makes sense. I just can't think of how to code up some of these things to begin with.

GitHub Repo for Practice Exercises Factory Function 2

Exercise #3
Now on to the debugging exercise! These are quickly becoming my favorite exercises to work on lately.

This exercise was all about defining "book" and making sure it connected throughout the code. I caught a couple aspects, but several of them I didn't realize I needed to type "book" in there to make the connection.

GitHub Repo for Practice Exercises Factory Function 3

That's it for Factory Function and for me today. I have an interview tomorrow, so I need to spend the remainder of the day preparing for that instead of working on my coding courses.

If you know of more places where I can practice Factory Function, Arrays, Loops, etc. please let me know! I'd love to understand this better than I currently feel I do.

Thanks for reading and I'd love to hear from you! Feel free to drop a comment. <3

Latest comments (0)