Control Shift J or F12 in Chrome

One of the suggested readings for Unit 3 of Connected Courses is Answers for Young People, by Tim Berners-Lee, in which he briefly recounts his motivation for creating the World Wide Web, how it works, and the difference between the Web and the Internet. The Internet consists of cables, routers, IP, and TCP or UDP. The Web is one application on the Internet, consisting of HTTP browsers, servers, and HTML pages.

The guy who invented the Web has a message for you.

I want you to know that you too can make new programs which create new fun ways of using computers and using the Internet. I want you to realize that, if you can imagine a computer doing something, you can program a computer to do that.

In Google Chrome, Ctrl+Shift+J opens the JavaScript Console. (Chrome, Firefox, Safari, Opera, IE.) You can hit Ctrl+L to clear the console.

Type a math expression, and hit Enter to see the result.

2 + 3
2 - 3
2 * 3
2 / 3
2 + 3 * 5
(2 + 3) * 5

Autocomplete shows lists of constants and functions.

Math.PI
Math.E
Math.pow(2,3)
Math.pow(8,1/3)    // For roots, use fractional powers.

You can save values by creating variables, with almost any name you want.

var x = Math.pow(2,1/2)

You can write your own functions:

function radians(d) { return (d/180 * Math.PI); }
radians(180)
Math.cos(radians(60))

JavaScript can dynamically alter anything on a web page.

document.write("<h1>Hello, World!</h1>")
document.bgColor = "yellow"
c = prompt("Favorite color?")
document.bgColor = c
document.location.reload()

This zip file contains a very simple demonstration of how to include CSS and JavaScript in a web page, along with a couple more JavaScript functions. Just double-click test.html to open it in your browser.

If you’d like to learn more:
JavaScript for Cats: an introduction for new programmers
* HTML, CSS, JavaScript – tutorials at w3schools.
* Mozilla Webmaker Tools (play with Meme Maker)
A great JavaScript overview that assumes you have some experience.
* Speaking JavaScript, also by Axel Rauschmayer, free to read online.
Eloquent JavaScript is an introduction to programming.
* A Re-introduction to JavaScript, a medium-long tutorial.
* JavaScript Reference in detail.