Functions in javascript is the reusable blocks of code designed to Perform specific task.Instead of writing the same code again and Again you can put it inside a function and call it whenever needed.
- SIMPLE IDEA
A function is like a machine,You can give a inputs it's called (parameters),it's processes and gives to back a output(called a return value).
- SYNTAX
function ogadd(boys, girls);
return boys + girls;
}
- Function is the keyword referring that we are writing a function
- ogadd is the name given to the function it's used to call the function
- boys and girla are the parameters inputs of the function it's like a Variable
return is the keyword if can used to the return the result once the Function is called
EXECUTION
let result = ogadd(25, 20);
console.log(result);
- Once if you can calling the function is 25 and 20 are the arguments It's take the place of parameters boys and girls
- It's runs the function addition operation returns the value 45 is Stored in the variable result
We have a returned the value it will stored in the variable result
SIMPLE UNDERSTANDING
- Start with function is defined - ogadd
- Next function is called - ogadd(25, 20)
- Then assigned the value for boys and girls - boys = 25, girls = 20
- Calculation - 25 + 20 = 45
- The function returns 45
- The return value 45 is stored in result
- finely printing the result to the console.
Top comments (0)