Monday, March 28, 2011

Week 9 - Trying a for loop of my own

I tried my for loop scripting ability on my own and came up with the following:

var a = 'Betty';
var b = 'Thomas';
var c = 'Peter';
var d = 'Jane';

var classNames = new Array (a, b, c, d);
for (var i = 0; i < classNames; i++)
{
        document.write(classNames[i] +
         'enjoyed the movie Cars 2 very much.');
}

 I haven't found a way to create a string array in Javascript, but I will keep searching. Therefore, I had to create several variables that contained strings within them. This code is supposed to write the following:

Betty enjoyed the movie Cars 2 very much.
Thomas enjoyed the movie Cars 2 very much.
Peter enjoyed the movie Cars 2 very much.
Jane enjoyed the movie Cars 2 very much.

The statement document.write(classNames[i] + 'enjoyed the movie Cars 2 very much.'); I believe is equivalent to a print statement in Java or Python. Strings in Javascript are embedded in single quotations.

This website helped me understand strings in Javascript. http://www.quirksmode.org/js/strings.html#charat

 Goals : 1. Photoshop Text Mystery Puzzle-Coming Soon!
             2. Learn about opacity, font, color, and animation techniques in
                 Photoshop Javascipt.
             3. Create gif animation script that uses the techniques in Goal #2.

No comments:

Post a Comment