Chapter 6 was titled “Programming Fundamentals, Part I”.
In the beginning of Chapter 6 it talks about data and value, as well as what they do and what they mean. Value has a different meaning in programming than what it is outside of programming. With programming, a value can be a string of words, a number, a boolean value (true or false), or just null.
I learned what a variable is, and how to call a new variable. If you want to call a new variable called “myAge” you simply type “var myAge” into the script to set the variable for myAge. It also teaches how to assign a value to the variable. This can be done two ways: initializing the variable (“var myAge = 45″) or assigning a value after the declaration of the variable
myAge = 45″)
Then it talks about variable names, such as which names are recommended and which are bad practice. A bad example would be naming them with single letters (unless it’s common-practice, such as using the letter ‘i’ as a counting variable in repeat loops). A good practice is to name the variable with what it actually does. However, you cannot use spaces so your name has to be one word or string. You can combine the words with either an underscore between the words, or use what he calls interCap where you leave the first word lowercase and then capitalize the first letters of the following words. (I refer to this as camelCase).
Another important piece of information that you can use with any programming is expressions and evaluation. This just means that when you say something such as the myAge variable earlier, “var myAge = 45″, the script remembers that information if you choose to use it later. So if you say “var yourAge = myAge – 15″, it will result in 30, because myAge (45) minus 15 is 30. We then learn about how we used an expression like this in our first script in Chapter 3 when we used our document.write() function to show the user what web browser they are using. Also, we can declare a variable, and then call it later in a function.
In the book it said to use Navigator to do this, however we don’t have Navigator. So I attempted it in DreamWeaver. I had to tinker with the script a little bit, however I got the same result except for the line breaks between each result. In the photography, on the left is the script I used and the right was the result.
I stopped on the section “Date Type Conversions” because I had to leave early do to Drumline practice. I will finish Chapter 6 and begin Chapter 7 tomorrow.