Write Here Right Now: Displaying Results

JavaScript uses the write() function to write text to a web page. Figure 2-4 shows how to use write() to let your visitors know how many seconds there are in a day. (The new code is in bold.) Figure 2-5 shows the page this code displays.

Using write() to write to a web page

Figure 2-4. Using write() to write to a web page

JavaScript's calculations

Figure 2-5. JavaScript's calculations

Line-by-Line Analysis of Figure 2-4

Line ❶ in Figure 2-4 writes the words there are to the web page (only the words between the quotes appear on the page). Don't worry about all the periods and ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.