+ 2

Help understand javascript functions

3rd May 2020, 3:19 AM
Humoyun
Humoyun - avatar
6 Answers
+ 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();
3rd May 2020, 3:54 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
3rd May 2020, 3:47 AM
Ayush Kumar
Ayush Kumar - avatar
+ 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
3rd May 2020, 3:56 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Thank you very much
3rd May 2020, 5:35 AM
Humoyun
Humoyun - avatar
0
Thanks 😊. You are a good writer.
22nd Jun 2020, 3:04 PM
Đ˜Đ»ŃŒŃ
Đ˜Đ»ŃŒŃ - avatar