+ 2
Help understand javascript functions
6 Respostas
+ 4
Alright, in real life what is a function? Or what do we refer by the word 'function'? For example, when we say 'The machine is functioning well.' What did we mean by the word function? Here is what we mean :
The machine was made by combining many components altogether and is giving us the purpose right? We mean that all those components is working fine. However, this is kind of similar in programming too. How?
You define a function to get a specific work done. For example, you can write a function to get your birthday, you can write a function to do your home work 😂, you can even write a function to take you to the sky, xD. Again how? Let's now consider how you do that :
In javascript to write a function you should follow the following syntax :
function find_my_birthday() {
// code to find your bday
}
function take_me_to_sky() {
// code to take you to the sky
}
Now to make work, you just write the name :
find_my_birthday();
take_me_to_sky();
+ 3
+ 3
[...continued]
You can go to sky as many times as you want, and you can find your birthday as many times as you want as well. That is you can call the function as many time as you want.
However, consider reading this page again :))
https://www.sololearn.com/learn/JavaScript/1145
+ 3
Thank you very much
0
Thanks 😊. You are a good writer.