Friday, January 17, 2014

Loop Loop Loop... Loop.

     I stayed home today so that I could get some work done around the house. So, no latté or anything for me today. I'll probably do a french press if I find some beans that aren't dead. But I have the music! I didn't really feel the Tomahawk album, so today I'm sticking to some awesome Pink Floyd.
     I've done loops quite a few times and yet, I still can't remember how to do them from memory, so before I do anything in my lessons, I'm going to practice loops until I can remember how to do them from memory. And apparently having:
 for (var i=8; i<120; i+12){
    console.log(i);
}
will freeze the browser. I got it wrong, I know. Now I know not to do <i+12> or anything like that. The correct version:
for (var i=8; i<120; i+=12){
    console.log(i);
}
works. Notice the <i+=12>. Like I said, I need to work on my loops. Onwards and onwards and onwards! Heh. Loop.
Oh look a FizzBuzz. That's got loops. Yay! Good Thing I'm prepared. I like FizzBuzz tests.
     Good Lord the console is so specialized here that even when the code actually works, they just say that it wasn't what they wanted. I should at least be able to see what I did  get to work.
I'm really liking the <for> loops.  It's pretty handy to just have the one line that does so much work.

     So,when you are defining a function, you can use <return> with a string, but otherwise you need <console.log> I guess? OK.
"unreachable 'return' after 'break'." What does that even mean? Here is a part of the code:
var getReview = function (movie) {

switch(movie){
    case "Matrix":
    return "good trip out";
    break;
    case "Princess Bride":
    return "awesome date night movie";
    break;
After each break I got that error,  but the code worked and I passed the lesson. I checked, and that's what they wanted. Why would they want something that has errors to be the answer?
But hey, switch statements.I love their ease and simplicity. Simplicity over all, y'all!  The more I learn, the more I like this language! I'm sure that is true far anyone that likes a computer language. I just feel like I've really hit my stride with my lessons! I've just got to soldier on and get done so I can get a decent job somewhere nice!
I'll see y'all Monday!
--Martin

No comments:

Post a Comment