Journey to Being a Code Jedi: 2D Arrays & Loops
So, it’s been a full week since I posted my first installment to the Journey to Being a Code Jedi post series.
So at the moment, (due to celebrating my birthday weekend/week) I’m currently on 2D Arrays, leading up to this I brushed up on loops, including the while, do while and the for loop, which is ya girls personal fav.
An example of a program I made for this section was a number guessing game using a do while loop, a get random number function which implemented both Math.floor() and Math.random() AND prompt in order to provide the user with a spot to enter which number they wanted to guess. I’ve included an image of this code down below. (Ps. if anyone is wondering the theme I use is called Dracula.)
When it came to the array programs, in the beginning these were just simple things revolving around an array that stored a shopping list, or even playlist song names. An example I can use though is some code a wrote with a LITTLE more functionality. Using prompt the program asked the user to enter either list, to get a list of groceries that were in stock, quit to quit the program, OR there was the option to type in a type of food, which when ended the program would let the user know whether or not this product was in or out of stock.
Again, the code is down below in case you are interested in checking it.
There were a few bumps in this section, but these mainly revolved around me needing to break apart a program and figure out exactly how I wanted to approach it, so a case of the infamous Blank Page Syndrome. That was until I got to 2D Arrays, which on their own are quite self explanatory, but not in the case of actually implementing them into a quiz project which is where I am currently at or more so, am stuck at. But even though this is so, I’ve stepped away from the program, took some space, which I definitely recommend when you get overwhelmed and now I’m ready to jump back in and kick its butt.
Before closing this, I’d like to post one more program, I’m hoping that next week will include some code revolving around objects and that I’ve solved my current 2D array program! For this one though, this was a playlist program that using a 2D array stored both the song title and the artist that it is by. I took this 2D array and passed it into a function, which then cycled through it with a for loop and posted both the song name and the artist into an ordered list. Again, an image of how I did this is down below.
So, there you have it, that’s my recap this week. I hope to have a ton of more code to show off next week as well, and at the moment I’m also working on two videos that I will be filming soon for my channel.
What did you guys learn this week?