Negation !
Tests if something is NOT TRUE.
"Is it true that something is not...."
var loggedIn = false;
if (!loggedIn) {
document.write("Log in Please");
}
Nesting
if (condition) {
//do this
if (condition B) {
//do that
}
}
Arrays
// Arrays are zero indexed.
<script type="text/javascript">
var myMagicalList = ['Narnicorns', 'Chupacabra', 'Gelfling'];
//another method - use the Array () function with keyword new
var myMagicalListB = new Array ('Donkey Lips McGee', 'Azreal', 'Orko');
document.write(myMagicalList);
//determine the number of items in an array
document.write('<p>Length of my list is: ' + myMagicalList.length + '</p>');
myMagicalList[myMagicalList.length] = 'Fart Burger';
document.write('<p>Length of my list is: ' + myMagicalList.length + '</p>');
</script>
//pop - remove off the end
//push - add to the end
//shift - take something off the top
//unshift - add to the top
-----------------
Loop
For repetitious task
You have to do these 3 things:
1. Set a counter (how many times am I going to repeat this task
2. Test a condition
3. Change the counter
while
var myCounter = 1;
while (myCounter <= 10) {
document.write("The number is " + myCounter + "<br>");
myCounter++;
for
while + arrays
for + arrays
--------------------------
http://960.gs
http://www.thegridsystem.org
No comments:
Post a Comment