Skip to content

Commit aae038f

Browse files
committed
chapter 1
0 parents  commit aae038f

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Code for Head First JavaScript Programming, by Elisabeth Robson and Eric Freeman.
2+
To be published later in 2013.
3+

chapter1/birthday.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Happy Birthday</title>
6+
</head>
7+
<body>
8+
</body>
9+
<script>
10+
var name = "Joe";
11+
var i = 0;
12+
while (i < 2) {
13+
document.write("Happy Birthday to you.<br>");
14+
i = i + 1;
15+
}
16+
document.write("Happy Birthday dear " + name + ",<br>");
17+
document.write("Happy Birthday to you.<br>");
18+
</script>
19+
</body>
20+
</html>

chapter1/code.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
scoops = 5;
2+
while (scoops > 0) {
3+
document.write("Another scoop!<br>");
4+
if (scoops < 3) {
5+
alert("Ice cream is running low!");
6+
} else if (scoops >= 5) {
7+
alert("Eat faster, the ice cream is going to melt!");
8+
}
9+
scoops = scoops - 1;
10+
}
11+
document.write("Life without ice cream isn't the same");

chapter1/generic.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Just a Generic Page</title>
6+
<script>
7+
setTimeout(wakeUpUser, 5000);
8+
function wakeUpUser() {
9+
alert("Are you going to stare at this boring page forever?");
10+
}
11+
</script>
12+
</head>
13+
<body>
14+
<h1>Just a generic heading</h1>
15+
<p>Not a lot to read about here. I'm just an obligatory paragraph living
16+
in an example in a JavaScript book. I'm looking for something to make my
17+
life more exciting.</p>
18+
</body>
19+
</html>
20+

chapter1/howdy.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Howdy</title>
6+
</head>
7+
<body>
8+
</body>
9+
<script>
10+
message = "Howdy" + " " + "partner";
11+
console.log(message);
12+
</script>
13+
</body>
14+
</html>

chapter1/icecream.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Icecream!</title>
6+
</head>
7+
<body>
8+
</body>
9+
<script src="code.js"></script>
10+
<!--
11+
<script>
12+
scoops = 5;
13+
while (scoops > 0) {
14+
document.write("Another scoop!<br>");
15+
if (scoops < 3) {
16+
alert("Ice cream is running low!");
17+
} else if (scoops >= 5) {
18+
alert("Eat faster, the ice cream is going to melt!");
19+
}
20+
scoops = scoops - 1;
21+
}
22+
document.write("Life without ice cream isn't the same");
23+
</script>
24+
-->
25+
</body>
26+
</html>
27+

chapter1/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>My First JavaScript</title>
6+
</head>
7+
<body>
8+
<script>
9+
var word = "bottles";
10+
var count = 99;
11+
while (count > 0) {
12+
console.log(count + " " + word + " of beer on the wall");
13+
console.log(count + " " + word + " of beer,");
14+
console.log("Take one down, pass it around,");
15+
count = count - 1;
16+
if (count > 0) {
17+
console.log(count + " " + word + " of beer on the wall.");
18+
} else {
19+
console.log("No more " + word + " of beer on the wall.");
20+
}
21+
}
22+
23+
</script>
24+
</body>
25+
</html>
26+

chapter1/kids.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>For Kids Only</title>
6+
<script>
7+
var age = 25;
8+
var name = "Owen";
9+
if (age > 14) {
10+
alert("Sorry this page is for kids only!");
11+
} else {
12+
alert("Welcome " + name + "!");
13+
}
14+
</script>
15+
</head>
16+
<body>
17+
<h1>This page is for kids only!</h1>
18+
</body>
19+
</html>
20+

0 commit comments

Comments
 (0)