Today, the lessons are starting out with arrays. From some Googling and just general info received from people, I know that arrays are going to be very useful. So, I need to keep my head up.
Yay! Loops and arrays! Check it out:
// Let's print out every element of an array using a for loop
var cities = ["Colorado", "The Grand Canyon", "A lot of Europe", "NYC because Gotta go at least once, I suppose.", "Japan", "Damn Yankee States", "New Orleans"];
for (var i = 0; i < cities.length; i++) {
console.log("I would like to visit " + cities[i]);
}
I added in the elements in the array. As you can see, I want to visit a profuse amount of places. Of course, this isn't an exhaustive list.
Wow. These people don't even remember what they are saying! They said, and I quote: "Remember, arrays use zero-based indexing!" The Image they show with it? <var arrayName=[1, 2, 3];> Um... no! That is NOT zero-based indexing! This is: <var arrayName = [0, 1, 2];> Duh. It's not like they don't know this! I learned what zero-based indexing is from them; they just can't show their work correctly all the time. Also, it would seem I should have known that if I have a <for> loop, you just run it. You don't need to print it to the console. I noticed that it was printing out the array in order going down, and then having it inside the brackets with the quotes and everything. I knew it shouldn't print twice, so I checked the forum, and they were all just running it. Well, now I know that too!
I always forget to put a space at the end of the quotes when it is concatenated with anything else. I better get that under control. Creating code with a solid simplicity also needs to be correct, of course. So, I better work on that. Don't want to get a job somewhere and then start doing crap code, do I? Of course not.
Today has been a win for me, I got a lot done, learned a lot of useful stuff, there was only a little bit of stupid. Winning! See y'all Wednesday!
--Martin
No comments:
Post a Comment