Use of Return Statement Inside a Function in JavaScript



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>
Updated on: 2020-01-07T08:51:24+05:30

271 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements