1. JavaScript Tutorial
  2. Loop For & While
  3. Math Object
  4. What is Array
  5. What is JSON
  6. Function in JS
  7. RegExp – Regular Expression

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';

return 'Number is less than 300';

var p1 = printData(200);

var p2 = printData(301);

gs.info(p1 + p2);

One response

  1. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *