What is function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is function

Help

24th Sep 2019, 11:14 PM
Chan Andoy
Chan Andoy - avatar
8 Answers
+ 5
these are blocks of code that perform a specific task.. and they can be reused anytime you wish to. . example: void helloWorld(){ System.out.println("Hello World"); System.out.println("This is a function"); } then you can call this method anytime you want, and it will display; 'Hello World This is a function'
24th Sep 2019, 11:30 PM
DOJ
DOJ - avatar
+ 5
Functions make the code reusable.
25th Sep 2019, 6:02 AM
Manoj
Manoj - avatar
+ 5
A function is simply a set of commands or tasks which are performed on being called. A function is defined in a separate line or block of code; consider the following JS example: function sum(s1, s2){ return s1 + s2; } In the above example, sum is the name of the function. The parentheses following it contains the list of parameters (or arguments) which are the variables whose values are passed on function call (in this case, the two numbers s1 and s2). It can be empty (no arguments) and only a blank set of parentheses will be used in such case. Then, whenever required, the function is called: var result = sum(3, 5); OR var a = 3, b = 5, result; result = sum(3, 5); The return statement is optional, depending on whether you want the function to return some value on being called.
26th Sep 2019, 12:02 PM
SSki11
SSki11 - avatar
+ 4
Reusable blocks of code for performing specific tasks
24th Sep 2019, 11:15 PM
Dlite
Dlite - avatar
+ 4
Functions help keep the code concise and prevent the need to repeat statements in the code.
25th Sep 2019, 1:25 AM
Sonic
Sonic - avatar
+ 2
It is a collection of statement(s) where you want it to be performing a specific task like for instance a keyboard is a collection of keys to input text data into a device the task is input so the keyboard can be used any time after it is declared useful... when writing instructions to a computing device then there are instructions you want to group together to work as a unit to archive a task or tasks so that's what is a function in many words
26th Sep 2019, 6:11 PM
Victor Kariuki
Victor Kariuki - avatar
+ 2
They are simply blocks of code which can be used multiple times.
26th Sep 2019, 6:22 PM
Anthony Kwesi Saah
Anthony Kwesi Saah - avatar
+ 1
The process of act known as function
26th Sep 2019, 11:49 AM
voiser speed
voiser speed - avatar