What is the use of return statement inside a function in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The “return” statement in JavaScript mentions a value, which you like to return. Inside a function, the value is returned to the function caller.

Example

You can try to run the following code to implement return statement inside a function

Live Demo

<html>
   <body>
      <script>
         function multiply(num1, num2) {
            return num1 * num2;
         }
         var result = multiply(5, 10);
         document.write("Multiplication: "+result);
      </script>
   </body>
</html>
raja
Published on 25-Jan-2018 11:36:56
Advertisements