20 function calculation IV

20 function calculation IV - /As k fo r a ll IDs a n d /s e...

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

View Full Document Right Arrow Icon
<b o dy > <h2>Ra ndo m  S tude nt  Pic ke r</h2>  <script type="text/javascript"> //The global array of student IDs var all = new Array(5); setupIDs (); writeIDsToDocument (); </script> <a href="javascript:  pickOne ();" > Pic k a  s tude nt</a> : <s pan id=" re s ult" ></s pa n> </b o dy> //As k fo r a ll IDs  and //s e t the  c o nte nt in the  a rray func tio n  setupIDs () { var i=0; while  (i<5) { a ll[i]=pro m pt(" Input a  s tude nt ID" ); i++; } } //Write  a ll IDs  to  the  do c um e nt func tio n  writeIDsToDocument () { var i=0; while  (i<5) { do c um e nt.write (a ll[i]); do c um e nt.write ('<b r/>'); i++; } } //S e le c t a  ra ndo m  s tude nt ID fro m  the  a rra y func tio n  pickOne () { var idx=Ma th.flo o r(Math.rando m ()*5); do c um e nt.g e tEle m e ntById(" re s ult" ).inne rHTML=a ll[idx]; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
Strings More about String Manipulations Each string may contain 0 or more characters. The .length property tells the number of characters in the string. Examples: Each character in a string has an index . The first character is located at index 0. To get the character at a given location: The charAt( index) method: Returns the character at the given index . If
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.

Page1 / 7

20 function calculation IV - /As k fo r a ll IDs a n d /s e...

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