Of course, I don’t mean this the way William Shakespeare did in Hamlet…
Today, we were introduced to the wonderful world of JavaScript functions. We got our feet wet with simple functions(). Then we did functions where we passed arguments to parameters (this sounds like something you’d do with relatives at the dysfunctional Thanksgiving dinner table, but I assure you it’s nothing like that). THEN, we got into passing arguments to parameters and RETURNED something…which is where it got really confusing for a lot of us. I kept getting the variables inside and outside of the function mixed up. Also, we learned that variables are “hoisted”–that is to say, they are moved to the top of the current scope (to the top of the current script or the current function). However, their initializations are NOT hoisted. Then we got into even MORE murky depths with the introduction of the “let” and “const” keywords, which are NOT hoisted, and behave in a most peculiar fashion, to the point where…yes, I definitely think I need some Advil…
The good news is that we went back to some of our previous code and retooled it to have functions. If anyone wants me to calculate the area of a circle or a square for them, I’m all set! I can also tell you if a year is a leap year…
We are having to keep up a portfolio of all our work, which I think I finally have up to date. Our instructor wants us to print this out, which I’m going to need to do at work, as I’d probably kill our home printer churning out all the pages I have so far…and this is only DAY 3 of our JavaScript training; this is going to go on for several more WEEKS. I suspect I’m going to have the equivalent of War and Peace or Moby Dick by the time I’m done.