10 Programming Structure VI

10 Programming Structure VI - Version 3 Use parameter...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
func tio n  convertToGrade( mark ) { var  grade ; if ( mark >80)  grade='A';   e ls e  if ( mark >65)  grade='B'; e ls e  if ( mark >45)  grade='C'; e ls e   grade='F'; return grade; } We call this function by its name followed by a value for the parameter in ( ) . Example: document.F1.CGrade.value = convertToGrade( document.F1.CMark.value ); mark is a  parameter  :  - is an input value that the  caller passes into this  function. This return . . statement passes a value back to the caller. Version 3: Use parameter, return : convertToGrade() MARKS TO GRADES CONVERSION Explanation 1: The Structure of convertToGrade()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Version 3: Use parameter, return : convertToGrade() MARKS TO GRADES CONVERSION Explanation 2: How convertToGrade() is Used: Consider: function  convertToGrade(mark) { } .. return grade; document.F1.CGrade.value = convertToGrade (document.F1.CMark.value); Step : Find the right-hand-side value: ie. Call the convertToGrade function. When it finishes, it will return
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/10/2012 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

Page1 / 4

10 Programming Structure VI - Version 3 Use parameter...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online