4programstructureiii

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: Program Structure III Insertion of Semicolons (;) Location of JavaScript Blocks Names of Variables and Functions Enclose statements in Braces { and } Assignment Statements Data Types (Numbers, Strings, Booleans) and Operations [Please switch off your phone] (CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong http://www.cs.cityu.edu.hk/~helena 4. Program Structure III - 1 The mystery of Semicolons (;) Semicolons (;) are used to separate statements from each other. Can be omitted if each statement is on a separate line. But not suggested to omit!! a = 3 a = 3 b = 4 a = 3 ; b = 4 ; b = 4 The fact: JavaScript automatically inserts semicolons if the line seems to be complete. a = 3 b = 4 a le rt(a +b ) //c a lc u la te a ve ra g e o f m a rks : va r a = ( p a rs e Int(d o c u m e nt.F1 .C Ma rk.va lu e ) + p a rs e Int(d o c u m e nt.F1 .EMa rk.va lu e ) + p a rs e Int(d o c u m e nt.F1 .MMa rk.va lu e ) ) / 3 a le rt(a ) Example: a = 3 ; b = 4 ; a = 3 ; b = 4 ; a le rt(a +b ) ; The invisible semicolons are automatically inserted. //c a lc u la te a ve ra g e o f...
View Full Document

Ask a homework question - tutors are online