So the Chapter 7 assignment was really vexing me. I could see what they wanted me to do (and could have done it easily in another language), but I wasn't getting my syntax right. My initial error (before I took the problem to class) was a typing problem. I was forgetting to force type to string. Then it was a syntax issue. I forgot the parenthesis in .toString();. Now I'm right as rain and making progress again. I'll knock that assignment out today, and then complete the test.
We worked on chapter 8 and chapter 9 in class. Those deal with branches (ifs and cases) and arrays. I felt very comfortable with those - they work like they do in C, except for the "for in" loop which is kind of a nifty idea. One of the things that I had a lot of fun with was that the guy who sat next to me wanted to experiment a little. One of the examples that we went over sets up an html table using a loop. He wanted to put a link in each td element, but wasn't quite sure how to handle that - so I showed him.
When we were going over branching, the instructor seemed to favor branching by Case as easier than using If statements. I'm not sure if I agree with that. I think it depends on what you're trying to accomplish. If I'm prompting the user to make an either/or choice - IE do you want this shirt in Blue or Green, I think an if statement is the way to go. I think Cases are better when you're giving the user a number of options - IE Do you want: A) A burger, B) A burger and fries, C) A burger, fries, and a soda, D) A burger, fries, soda, and an apple pie? Because cases can "fall through" they work really well for this, where using ifs would be possible but obnoxious to set up. In web terms, ifs are radio buttons, or selections (usually) whereas case branches are more suited to check boxes.
I'm really enjoying myself here. One thing I love about this instructor is his willingness to experiment. At one point, when we were covering associative arrays, someone asked if you could still access array elements by number. It didn't work (undefined), but it was fun to see what would happen. We had a similar situation with typing - where we observed the interpreter retyping a string as an int during a comparison. Very cool stuff.
No comments:
Post a Comment