Function in JS
A JavaScript function is a block of code designed to perform a particular task.
Why did Function need?
You can reuse code: Define the code once, and use it many times.
- How can we declare a function
- Parameterize Function
- Return the value from a function
- The function can be assign to a variable
Example Code:
function printData(numbr){ var num= numbr; var name = "Rohit"; if(num > 300){ return 'Number is more than 300'; }else{ return 'Number is less than 300'; } } var p1 = printData(200); var p2 = printData(301); gs.info(p1 + p2);
One response
For my thesis, I consulted a lot of information, read your article made me feel a lot, benefited me a lot from it, thank you for your help. Thanks!