www.crosswinds.net/~fishcaro/day_J5_assg_st.htm
INDEX CARD #J5:
ASSIGNMENT STATEMENTS (J5a)x = 5.2; is an assignment statement. Think of x as specifying
a particular location in memory, where you can put things. (Think of it as a
folder in a filing cabinet, if you want!) You're putting the number 5.2 in that
location with the previous statement.
One particularly important type of assignment statement looks like this:

BOOLEAN VALUES (J5b) true and false .
Boolean values typically arise when two JavaScript objects are being compared.
A comparison operator compares the values of two things, and returns
either For example, the statement Don't mix up these two DIFFERENT types of statements:

COMPARISON OPERATORS (J5c)

A SIMPLE CONDITIONAL STATEMENT (J5d)
Here's a simple conditional statement.
If x is equal to 1, then it increases the current value of y by 2.Otherwise, it decreases the current value of y by 2. This could be written more simply on one line, like this:

Printable version of Index Card J5a
Printable version of Index Card J5b
Printable version of Index Card J5c
Printable version of Index Card J5d
WORKSHEET #J5:
In Netscape, bring up a JavaScript Interpreter Screen, as discussed in the previous lesson.
Type in each of the following, to explore assignment statements, comparison
operators, and boolean values.
PREDICT what you'll get in each case BEFORE you press enter!
Identify each value of x as either a number or a string.
x = 5.2; x = x + 1; document.write("The value of x is " + x + "<BR>");
x = 5.2; x = x  1; document.write("The value of x is " + x + "<BR>");
x = 5.2; x = x + 2*x; document.write("The value of x is " + x + "<BR>");
x = 5.2; x == 5.2;
x = 5.2; x == 6.2;
x = 5.2; x == x;
x = 5.2; x == x+1;
x = 2; y = 3; x == y;
x = 2; y = 3; x != y;
x = 2; y = 3; x > y;
x = 2; y = 3; x < y;
x = 2; y = 3; x >= y;
x = 2; y = 3; x <= y;
x = 4; y = 4; x == y;
x = 4; y = 4; x != y;
x = 4; y = 4; x > y;
x = 4; y = 4; x < y;
x = 4; y = 4; x >= y;
x = 4; y = 4; x <= y;
x = 3; if (x == 3) {y = 1;} else {y = 2;} document.write("the value of y is " + y + "<BR>");
x = 4; if (x == 3) {y = 1;} else {y = 2;} document.write("the value of y is " + y + "<BR>");
x = 1; y = 2; if (x > 0) {y = y + 1;} else {y = y  1;} document.write("the value of y is " + y + "<BR>");
x = 1; y = 2; if (x < 0) {y = y + 1;} else {y = y  1;} document.write("the value of y is " + y + "<BR>");
<SCRIPT>
container, to do the following:
x
and y
. (You'll want to check your program with lots of different values.)
x
and y
are equal, then double y
.
y
in half.
x
and y
.
<BODY> Here's a sample alert box:<BR> <SCRIPT LANGUAGE="JavaScript"> alert('Hello there!'); </SCRIPT> </BODY>Describe what happens when you pull this code into a browser. Does it work in both Internet Explorer and Netscape Navigator?
<BODY> <SCRIPT LANGUAGE="JavaScript"> Here's a sample alert box:<BR> alert('Hello there!'); </SCRIPT> </BODY>
<BODY> Here's a sample alert box:<BR> <SCRIPT LANGUAGE="JavaScript"> alert("Hello there!"); </SCRIPT> </BODY>