JS Functions with Return Value

 
<!DOCTYPE html>
<html>
<head>
    <title>JavaScript</title>
    <script>
        function fullname(fname = "Yahoo", lname = "Baba") {
            var a = fname + " " + lname;

            return a;
        }
        
        var fn = fullname("Ram","Singh");
        document.write(fn);
    </script>
</head>
<body>
</body>
</html>
 
<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    function sum(math,eng,sc){
      var s = math + eng + sc;

      return s;
    }

    function percentage(tt){
       var per = tt/300 * 100;
       document.write(per);
    }

    var total = sum(80,80,80);

    percentage(total);
  </script>
</head>
<body>

</body>
</html>