• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The return Statement

The return statement is discussed here instead of in the last chapter because the statement can be used only as part of a function. The role of the return statement is to provide the value of the expressions within the function. But where does the function return the value to? For example, try out the following script:

<html> 
<head> 
<title>Return</title> 
<script language="JavaScript"> 
function returnMessage() {
      var part1="Good "; 
      var part2="Morning"; 
      var wholeThing=part1 + part2; 
      return wholeThing; 
      } 
returnMessage(); 
</script> 
</head> 
<body bgcolor="mistyrose"> 
</html> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint