MSc-IT Study Material
June 2010 Edition

Computer Science Department, University of Cape Town

Review Questions

Review Question 1

What are the names of functions in the code below:

	function displayMessage( message )
	{
	document.write( "<p> Message was: " + message );
	}
	displayMessage( "Hello" );
	displayMessage( Math.sqrt( 25) );
      

You can find a Answer to this question at the end of the unit.

Review Question 2

Write a specification for a function triangleArea to calculate and return the area of a triangle, for a provided height and width.

You can find a Answer to this question at the end of the unit.

Review Question 3

What code would you need to create the following user-defined function:

Table 16.10. Function to multiply two numbers and return the result

Name (optional)multiply
Arguments (optional)n1, n2
body
var result = n1 * n2;
	      return result;
Returns (optional)Returns the result of multiplying the two given numbers


You can find a Answer to this question at the end of the unit.

Review Question 4

What value is displayed when the following minus() function is invoked?

	function minus()
	{
	document.write( 5 - 6 - 7)
	}
	minus();
      

You can find a Answer to this question at the end of the unit.