This was a big week. I finished up a huge chapter on loops, and started in on functions. I’m still working on functions.
Functions are a game changer. I’m started to understand that functions are perhaps the most important thing to learn in programming. Functions are written once and then reused over and over again throughout a piece of code.
Advice of the week: When you’re learning core concepts, it’s really hard, and you should dedicate time every day, even if it's just 15 minutes. Make a small dent every day, rather than trying to study for 8 straight hours on the weekend. Let things soak in.
Accomplishments for Week 6:
- I wrote my first nested loop. I definitely talked about this at length with my entire dev team at work, which is extremely embarrassing, because they do way more complicated stuff for a living. (For the record, they were nice about it, and encouraging.)
- I wrote my first function. Again, this was an extremely simple function (and Udacity definitely gives you clues for how they want you to write it) but it felt like a big accomplishment.
- Functions get confusing because you have to keep in mind there are arguments and parameters. A parameter is always going to be a variable (declared in the function declaration), and an argument is an actual value.
- Loops often exists as part of functions. This was confusing for me at first, because you’re declaring parameters as part of the function, but then you’re declaring other variables inside of the loop. It’s hard to keep all of the variables straight.
- Just when I thought I was comfortable with functions, I was taught that you can store a return value in a variable, and use that variable to do other stuff. Jesssuuussss my head hurts.
- A function's return value can be stored in a variable or reused throughout your program as a function argument.
Ah Ha Moment(s):
- Understanding the difference between print (console.log) and return. Printing and returning are two different things. Duh.
- A function ENDS at return. So if you have:
the function will return x, because the function ended when you wrote 'return' the first time. Therefore, the function never gets to the ‘return y’ part.