Cover | Table of Contents
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/ html4/strict.dtd"> <html> <head> <title>My Web Page</title> <script type="text/javascript"> </script> </head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/
html4/strict.dtd">
<html>
<head>
<title>My Web Page</title>
<script type="text/javascript">
alert('hello world!');
</script>
</head><script type="text/javascript">
alert('hello world');<link href="../css/global.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> alert('hello world'); </script> </head>
<script type="text/javascript">
document.write('<p>Hello world!</p>');
</script>
<script type="text/javascript" src="../js/jquery.js"></script>
alert('Hello World!');alert('Hello World!');document.write(5 + 15);
alert('Hi Bob');var score;
Operator | What it does | How to use it |
|---|---|---|
+ | Adds two numbers | 5 + 25 |
- | Subtracts one number from another | 25 - 5 |
* | Multiplies two numbers | 5 * 10 |
/ | Divides one number by another | 15/5 |
var price = 10; var itemsOrdered = 15; var totalCost = price * itemsOrdered;
<h1>Using a Variable</h1> <script type="text/javascript"> </script>
var firstName = 'Cookie'; var lastName = 'Monster';
document.write('<p>');document.write(firstName + ' ' + lastName);
<script type="text/javascript">
var firstName = 'Cookie';
var lastName = 'Monster';
document.write('<p>');
document.write(firstName + ' ' + lastName);
document.write('</p>');
</script>
<script type="text/javascript">
var name = prompt('What is your name?', '');
</script>
var item1 = 'Xbox 360'; var item2 = 'Tennis shoes'; var item3 = 'Gift certificate';
<script type="text/javascript"> var authors = [ 'Ernest Hemingway', 'Charlotte Bronte', 'Dante Alighieri', 'Emily Dickinson' ]; </script>
<script type="text/javascript"> document.write('<p>The first author is <strong>'); document.write(authors[0] + '</strong></p>'); </script>
// this is a comment
var price = 10; // set the initial cost of the widget
/* JavaScript Slideshow: This program automates the display of images in a pop-up window. */
/* this is a single line comment */
<script type="text/javascript">
var luckyNumber = prompt('What is your lucky number?','');
</script><script type="text/javascript">
if (luckyNumber == 7 ) {
</script><script type="text/javascript">
if (luckyNumber == 7 ) {
}
</script>document.write("Hey, 7 is my lucky number too!");<script type="text/javascript">
if (luckyNumber == 7 ) {
document.write("Hey, 7 is my lucky number too!");
} else {
document.write("The number " + luckyNumber + " is lucky for you!");
}
</script>while (condition) { // javascript to repeat }
document.write('Number 1 <br>');
document.write('Number 2 <br>');
document.write('Number 3 <br>');
document.write('Number 4 <br>');
document.write('Number 5 <br>');var answer1=prompt('How many moons does Earth have?','');
if (answer1 == 1 ) {
alert('Correct!');
} else {
alert('Sorry. The correct answer is 1');
}
var answer2=prompt('How many moons does Saturn have?','');
if (answer2 == 31) {
alert('Correct!');
} else {
alert('Sorry. The correct answer is 31');
}Object | Parts | Actions |
|---|---|---|
dog | bark | |
tail | wag | |