Head First JavaScript: Hands On Head First JavaScript

Welcome to Hands-On JavaScript, where you can type in JavaScript code and run it directly in your web browser. You don't even have to create a file—just enter your code and click the Run button. If the code returns a value of any kind, it will appear in the output box below the Run button. Following are some suggestions to try. To force a return value, just specify a variable on the last line of code by itself, as shown in the examples. Feel free to cut and paste the examples to get started.

Perform a calculation

var radius = 3.5;
var circumference = 2 * Math.PI * radius;
circumference;

Sort an array of strings

var names = [ "Duncan", "Alan", "Ruby", "Jason", "Seth", "Howard", "Owen" ];
names.sort();
names;

Enter JavaScript code here:


Gear