| Index | Code Tester |
Decision Making with if
if (true) {alert("It's true");};if (!false) alert("True");var a = 3;var b = 6;if (a == b) {alert("a=b");alert("Another statement");};if (a > b) {alert("a is greater then b");};if (a <= b) {alert("a is less then or equal to b");}
Decisions Using if...else
Abbreviated Statementif (true) {alert("It's true");};else {alert("not true");};var a = 3;var b = 6;if (a == b) {alert("a=b");};else if (a < b) {alert("a < b");};else {alert("a > b");}
var a = 3;var b = 6;if (a != b) {alert("a does not equal b");}else {alert("a equals b");}
var a = 3;var b = 6;(a != b) ? alert("a not equal to b") : alert("a equals b")
1. What symbol(s) is (are) used to determine if two variables are equal?
2. What symbol(s) is (are) used to determine if two variables are not equal?
3. Write statements to check the following conditions. If the condition is true an alert should appear indicating true.
4. Write a function that accepts a number and determines if the number is negative, positive, or zero. The function should display the result in an alert. Create a page that enables the user to enter a number and then call the function to determine its status.
5. Write a function that accepts three numbers, x1, x2, x3. The function should determine if the numbers are in order and then return "true" if they are in order and "false" if not in order. Then create a web page that enables a user to enter three numbers and then display if the numbers are in order or not.
6. Create a page with a textbox, a button, two checkboxes, and two radio buttons. One checkbox should be labelled Italic and the other Bold. The radio buttons should represent two different fonts. When the user clicks the button, the contents of the textbox should be written using document.write in the selected font and italicized or bold if selected.