Cscityueduhkhelena other basics about javascript

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: In f1, x is 3 Call f1() Just alert it undefined To avoid confusion, we usually DON'T use the same name for local and global variables. 4. Program Structure III - 6 (CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong http://www.cs.cityu.edu.hk/~helena Other Basics about JavaScript Enclose statements in braces { and } va r m a rk; m a rk=p ro m p t('Wh a t is yo u r m a rk? ','') ; if (m a rk>4 0 ) d o c u m e nt.write ('P a s s e d ') ; e ls e d o c u m e nt.write ('Fa ile d .') ; d o c u m e nt.write ('<b r/>') ; d o c u m e nt.write ('Y o u m u s t ta ke th is c o u rs e a g a in!') ; What is your mark? 80 Although last 3 lines are aligned at the same column, JavaScript does not know that they are 'together'. In such case we add { and } to group them together: va r m a rk; m a rk=p ro m p t('Wh a t is yo u r m a rk? ','') ; if (m a rk>4 0 ) d o c u m e nt.write ('P a s s e d .') ; e ls e { d o c u m e nt.write ('Fa ile d .') ; d o c u m e nt.write ('<b...
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