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

This document from docsity.com provides javascript examples for getting and formatting dates, generating random numbers, and displaying alert boxes. It includes code snippets for getting the current date and formatting it using weekday and month names, getting a random floating-point number and integer, and displaying an alert box when a button is clicked.

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharamnishth
dharamnishth 🇮🇳

2.5

(2)

50 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JavaScript Examples
Docsity.com
pf3
pf4
pf5
pf8
pf9

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)