if mark45 ie the variable result is no longer

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: </script> To pass function convertToPassFail(mark) back the value of the variable result, NOT to pass back the variable result. { if (mark>45) ie. the variable result is no longer required after "return result='Pass'; result;". else result='Fail'; } return result; http://www.cs.cityu.edu.hk/~helena </script> 4. Program Structure III - 5 Names of Variables and Functions ? What happens if a local and a global variables have the same name.. The function can see the local x only, not the global x. The function sets the local x to 3, it doesn't set the global x. <html> <head> <title>Demo</title> <script type="text/javascript"> var x; fu nc tio n f1 ( ) { var x; x=3; a le rt(" In f1 , x is " + x) ; } </s c rip t> </h e a d > <b o d y > <a h re f=" ja va s c rip t:f1 ( ) ;" >C a ll f1 ( ) </a > <b r/> <a h re f=" ja va s c rip t:a le rt(x) ;" >Ju s t a le rt it</a > </b o d y > </h tm l>...
View Full 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.

Ask a homework question - tutors are online