March 10th, 2020
Before we begin, I’d like to make sure you’ve checked out yesterday’s story. If you have, well done! Today we’ll be having our 2nd Review Day! If you haven’t, feel free to click on the link below!
Javascript in 15 Days : Functions
So, a quick overview! For the past few days, we’ve talked about functions, loops, and Object Math. Now let’s start with functions.
What are functions? Well, functions, put simply are a block of previously defined code, which will never be run unless invoked/called. So, how does this look like? Let’s see.
Now that you know how we can declare it, how do we call/invoke them? Well, let’s see, shall we? Below is an example of how we would find the result of a multiplication.
So, after we defined our function above, simply call the same function, pass the parameters needed, and voila! The function was called successfully, and the expected result is printed to console! Now, onto our next topic, loops.
Loops, put simply are a block of code, that will be repeated, as long as our predefined condition hs not been met. So, to demonstrate, I will show below, an example to loop numbers from 1 ~ 100, and print multiples of 5, both in for-loop and while-loop.
So, as you can see, those are loops! We’ve seen a for-loop, a while-loop, and their output! Now, onto our next and final topic, Object Math, the source of our magical Mathematical operations! So what is the Object Math? You can regard Object Math as a set of built-in functions, prepended with the keyword Math, to access all possible Mathematical operations like square root, power, round, floor, ceil, etc. So many possibilities, so little time!
Haha, I know right? You must be puzzled with all these information! No worries, as long as you practice, practice, and practice, this will all make more sense in time! Just remember to try your best and learn at your own pace!
That it’s the end of our Review Day! If you need some practices, be sure to hit me up on my LinkedIn or Twitter handle. Next up, we’ll be going to have a lot of fun learning arrays and objects, basically how to store more than one data-types at once! I’m sure it’ll be a lot of fun! Have fun learning and see you tomorrow!