bbb Home
Functions 2 Contents        

FUNCTIONS THAT ACCEPT AND RETURN VALUES

function functionName(parameter1, parameter2){

code

return(returnValue)

}


EXAMPLE

Font: 8pt   12pt   20pt   24pt   Width: Min. 50%   75%   100%   

PRACTICE

    1.  Write a function that accepts three numbers and returns their sum.

    2.  Write a function that accepts three numbers and returns their average. Use the function from #1. Create a page to test your function.  Add three textboxes and a button.  When the user clicks the button, the contents the average of the textboxes should be displayed.

    3.  Write a function that accepts two strings, adds them together (with a space between them), and returns the combined string.  Create a page to test your function.

    4.  Write a function that accepts two textboxes as objects and switches their values.

    5.  Write a function that accepts an object and two values representing the distance in the horizontal and vertical directions. The object should be moved the amount specified.


SELF-QUIZ