Docsity

JavaScript Document: Getting and Formatting Dates, Random Numbers, and Alert Boxes, Slides of Computer Science

Partial preview of the text

Download JavaScript Document: Getting and Formatting Dates, Random Numbers, and Alert Boxes and more Slides Computer Science in PDF only on Docsity!

JavaScript Examples

Getting the date

» 27/10/

Getting a random number

• The following code gets a random floating-

point number between 0 and 1:

•

Getting a random integer

• The following code gets a random integer

between 1 and 10:

•

Telling what happened

  • In my Concise JavaScript, part 2, I have code that shows what events occur when the user takes various actions
  • In the of the HTML page I define:
  • For each form element, I have a handler for every (plausible) event

Telling what happened (Button)