Teach Yourself JavaScript by Mac Bride

Teach Yourself JavaScript by Mac Bride

Author:Mac Bride [Bride, Mac]
Language: eng
Format: mobi
Publisher: Hodder Headline
Published: 2003-03-31T16:00:00+00:00


<SCRIPT>

store = new Array(11)

/* create an array numbered 0 to 10 */

for(loop = 0; loop <= 10; loop++)

store[loop] = 0

for(count = 0; count <1000; count++)

{

/* generate a random number in the range 0 to 10 */

x =rand(10)

/* increment the counter for that number */

store[x] = store[x] + 1

}

for(loop = 0; loop <= 10; loop++)

document.write(“store[“+loop + “] has “ + store[loop] + “<BR>”)

</SCRIPT>

</HTML>

Strings and numbers

eval() will give you the numerical value of a string or the result of a calculation. Try this to see it at work:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.