Functions, variables and more... I NEED HELP! [VERY EASY]

Discussion in 'JavaScript' started by Spyder23, Feb 13, 2008.

  1. #1
    This is an assignment for school, and I need to do the following to the code below:



    Modify the getCompanyName() function in the following code so that it returns the company name to another calling function. Also, add statements after the getCompanyName() function definition that call the getCompanyName function and assign the return value to a variable named retValue. Finally, print the contents of the retValue variable.






    Here is the code:
    <HTML>
    <HEAD>
    <TITLE>Company Name</TITLE>
    <PRE>
    <SCRIPT type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS
    function getCompanyName() {
    var companyName = "Course Technology";
    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </SCRIPT>
    </PRE>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>






    This will probably be easy for most of you... but I just started this stuff today.

    Any help would be greatly appreciated because this is due tomorrow.

    Thanks, Spyder
     
    Spyder23, Feb 13, 2008 IP
  2. mjamesb

    mjamesb Member

    Messages:
    88
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #2
    function getCompanyName() {
    var companyName = "Course Technology";
    return companyName;
    }

    function test()
    {
    var retval = getCompanyName();
    document.write(retval);
    }
     
    mjamesb, Feb 14, 2008 IP