Just like Tileland, there are instructions that are sequentially executed. (here's a great resource for intro javascript )
code
explanation
<!DOCTYPE html>
<html>
<script>
// begin
document.writeln("<h1>Script output</h1>");
var num;
num = 4;
var num2 = 3;
console.log(num+" "+num2);
document.writeln(num + num2);
num = num + 1;
num2 = num;
console.log(num+" "+num2);
document.writeln(num + num2);
// end
</script>
</html>
// html intro
 
// a comment to indicate the start of code
// add content to the webpage
// declare a variable
// assign a value to a variable
// declare and assign a value to a variable
// log information for a developer
 
// manipulate variables …try other operations
 
//html wrapper
 


Try this out using Chrome
note: comment, declare, and assign

Playing with math


A complex example using if

here's a game http://jimmorey.com/bull/simpleBull.html

playing around with strings

"jim morey".length
-- 9
"jim morey".toUpperCase()
-- "JIM MOREY"
"jim MORey".toLowerCase()
-- "jim morey"
"jim MORey".indexOf("m")
-- 2
"jim MORey".indexOf("e")
-- 7
"jim MORey".indexOf("or")
-- -1
"jim MORey".indexOf("OR")
-- 5
"jim MORey".substring(5,7)
-- "OR"
"jim MORey".substring("jim MORey".indexOf("OR"),7)
-- "OR"
"jim MORey".substring(4,7);
-- "MOR"
"jim MORey".substring(4,8);
-- "MORe"
"substring".substring(2,9)
-- "bstring"
"substring".substring(0,3)
-- "sub"
"substring".substring(5,9)
-- "ring"
var jim = "fjdsklfjeslfiewi fjslfi"
-- undefined
jim.length
-- 23
jim.substring(0,5)
-- "fjdsk"
jim.substring(23-5,23)
-- "jslfi"
jim.substring(jim.length-5,jim.length)
-- "jslfi"
jim = "hello there"
-- "hello there"
jim.substring(jim.length-5,jim.length)
-- "there"
var short = "lo"
-- undefined
jim.indexOf(short)
-- 3
jim.substring(jim.indexOf(short),jim.length)
-- "lo there"
jim.substring(jim.indexOf(short)+short.length,jim.length)
-- " there"