Monday, January 20, 2014

New Font New Lessons

     Well, I'm at the coffee shop. I wasn't planning on going here, but the internet is down. I mean really down! the line got cut somewhere between our neighbor's house and our house. So, the company is going to be digging around fixing all of that for a while. So, here I am getting stuff done and having a good latté. I got a little sidetracked by some questions about my Chromebook Pixel, and it does cut quite the figure, so I can understand people asking about it. I'm back on track now. The music for today is: The Crystal Method. I'm not really sure how I came across it, but I put in my Google Play Music a bit ago, and voilà! Cool music! I'll probably throw some Pink Floyd in there too. The radios are just playing their two most popular songs according to them: Another Brick In The Wall, and Wish You Were Here. It makes me want to hear more than just those two, but enough chatter! Time to plug in and plug away!

     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]);
}

It kind of had me there for a bit until I realized they weren't trying to print numbers, they were printing the elements in the array and calling them in order by number.
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


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

Wednesday, January 15, 2014

Are you Human?


     Well, I'm back and hoping there'll be less stupidity today which will be difficult since I forgot my wallet like a genius, so water is my drink today. One of my g+ peoples shared some music that I thought I'd check out. So, I'm listening to Tomahawk. Never heard of them, but it seems kinda nifty. Now it's time to plug in and plug away!

     Blackjack. That's a fun game. Now I'm going to be writing code to make the game. Good news: I like the fact that they want you to think about how to figure it out by yourself. Bad news: I don't like the fact that once you uncover the "hint" that tells you what you need to do, it turns out there's only one way that they will take as a pass. It should be that if it works, that's a pass. If you don't tell me how to get it done, I should be able to have a certain amount of freedom as to how it gets done, but no. Only one way. Oh well. I just wish there wording had been a little bit more transparent.
Well, that was easier than I thought it was going to be. I didn't like how they finished it, but it works. So, whatever.
     Now I've moved on to a "review primitives" section. Pro: I remember most of it. Con: all they have you do is print a sentence to the console to pass the section. This is going to take some personal initiative. After playing with some of the lessons, they are now actually having me do some stuff. So, I don't have to come up with my own stuff. I kinda liked it. Ah well, back to the grindstone.

     I really like using <Math.random()> and such. It's so easy and yet so useful! A handy dandy little random number generator.

     OK, this was a little strange; I just did a lesson and they had a var that they didn't use, but they wanted me to answer. I'll show you:
// Write your full name
var myName = ("Mookie Chess");

// And your age
var myAge = 24;

// Are you a human? Be honest.
var iAmHuman = "no";

console.log("My name is " + myName + " and I am " + myAge + " years old.");

Am I human? Alone a strange question, but then to not use it? It's times like these when I over-analyze things. I just want to know!  But hey, now I have a post title.

     So, a Boolean is only true or false? Well, OK then. Good thing I looked it up, or I would have been stuck. These guys really don't inform you of everything, but then I suppose that's a good thing. Use some personal initiative to get through sort of thing.

     Hey, another badge!







We made it through! Olé!
Well, hopefully I won't be so slow to Google some definitions next time! See you humans on Friday!
--Martin

Monday, January 13, 2014

Capitalizing On Skills With A Side Of Stupid


(sorry for the late post. As you'll see there was a loooot of stupid...)
     Well, I made it back for yet another week! Today's post is brought to us by some Blind Melon and a latté whipped up by the friendly barista. I was going to just work with no music, but then the place got swamped and everyone was talking and noise happened, but now I can plug in and plug away!
  
     I've been doing these classes for about a year, but this is my first REAL attempt at actually taking time every day to do at LEAST an hour's worth of studying in and I'm starting to see some of the skills that get picked up along the way. For instance, today I was working on some classwork and I got a syntax error. It used to be that I would be at a loss as to what the reason was, but now I'm starting to learn what to check before giving up hope when I get a syntax error, and today I took the time to check that all of my variables and such were in the correct place and that I had the correct capitalization. Turns out one of them needed to be moved AND capitalized. Good thing I'm a student and not a pro, because; that would have been embarrassing. I've also noticed I'm better at algebra too. Turns out I was right in thinking that there was a lot in common between the two. 

     Right now I'm working on a section that (once again) is using math involving a startup. Such as paying employees, rent and such. I'm also dealing with multiple parameters which are easy, it's just difficult to always get the correct ones in the correct places, but copy pasta!

I really don't like it when I don't pass the lesson and they won't tell we why. They're just like: fail. Try again. At least tell me what's wrong. The weirdest is when I get NaN, but they say I passed the lesson. No. I'm not going to NaN my way through this. Whoever wrote this lesson definitely didn't think of everything. 

Switch statements are awesome, but I had forgotten that you have to add a return at the end after the <}> and now I feel stupid. Duh, of course there should be a return. 
I just finished the function which tells you the total costs for a startup based on salary, number of workers and city. Kinda sounds cool when I write it out. 

Speaking of not thinking of everything, look at this:
var calculateTotalCosts = function(salary,numWorkers,city)
{
fixedCosts = 5000;
variableCosts = salary*numWorkers;
switch(city)
{
case "BEJ":
rent = 25000;
break;
case "NYC":
rent = 30000;
break;
default:
rent = 10000;
break;
}
return rent + variableCosts + fixedCosts;
};
  
console.log(calculateTotalCosts(50000,9,"BEJ"));
console.log(calculateTotalCosts(50000,9,"NYC"));
console.log(calculateTotalCosts(50000,9,"MUM"));

That is a perfectly working code and exactly how they TELL you it should be. They actually give you the code with everything except the console.log parts. 
Turns out they want you to change it to an if/else situation. WHAT?? why... omgosh this si so stupid.... gr... just going to peddle through this crap and hope they don't do something so mind boggingly stupid again....
Aaaaand they signed me out. None of my work from today is saved. Wow... Well, at least I know how to get through this crap.
Jeeze that was annoying. Ah well. All part of the experience, I hope. 
See y'all Wednesday!
--Martin

Friday, January 10, 2014

Badge Happy

     Stupid! That's what it is! When a lesson has a specific way that it wants you to do a line of code, and then DOESN'T tell you!
Let me show you:
var x =
var y =

//The ternary operator in action
result = x > y ? "good job" : 20;

//Rewrite the ternary code using if else statements
First I tried to use return, but that gave me some error messages, but then I tried this and it worked, but I didn't pass the lesson:
if (x>y){
   console.log("good job");
}else{
   console.log(20);
}
See the 'result' in the ternary operator? Turns out you need that instead of anything else, because; they feel like it. 
That's stupid. I understand using result, but they could have told me that....
I finished the conditionals section! Olé!







And Now I'm doing a dice game and using math. 
var die1 = Math.floor(Math.random()*6 + 1);
Math.Whoever created the math section in .js is hilarious! 
Today's post is brought to us by a nice latté and some Electric Light Orchestra. Time to plug in atd plug away!
I just got ridiculously happy, because; I finished a lesson with no errors and passed at the very first try! WHOO!!
 One of the really cool things that I like about having a forum, is that I can see how other people wrote their answers, and how they are different from mine. 
For instance, this is mine:
 // here we need to check if there are doubles.  If so, score should be
  // double the sum of the two dice
  if(die1+die2%2===0){
    score=(2*(die1+die2));  
  }else{
      score=(die1+die2);
  }
}
and this is someone else's:
// here we need to check if there are doubles. If so, score should be
// double the sum of the two dice
if(die1===die2){
score=(die1+die2)*2;
}
else{
score=die1+die2;
}
}

Personally speaking, I like what they did with the <if (die1===die2)> better than my <if (die1+die2%2===0)> their's is so much more simple! I should have thought of that...
Simplicity is what I'm trying to go for every time I write code. So, I'm now upset that I didn't do a better job at it. Oh well, next time I'll know.
Hopefully, they won't split each test into something like this: // Define a function named calculateTotalCosts 
// declare a variable fixedCosts the value of 5000
// have the function return fixedCosts

I can do that easily. why not have the text three things in the same page?
Ah well. See y'all Monday! 
--Martin 

Wednesday, January 8, 2014

What The What!

     Ever since the beginning of this course, I've been working with if/else statements and conditionals. It would seem that thing are about to take the next step. Now I'm starting on switch statements. Olé? I'm actually pretty happy with my rate of studying. I just have to keep on plugging in and plugging away. Ok, so I'm working away with the switch statements(Which are awesome BTW) and now they're saying there's another way to do it called Ternary operators. According to el Goog, 'ternary' is an adjective meaning composed of three parts, or in mathematics, means using three as a base. Now to find out if that is what it means in programming. They say they are an ugly name. That's kind of dumb. I like the sound of the name. Ternary. Sounds like it's about a bird or something. But I digress, back to the code shtuff. The Offspring is my soundtrack today. I'd never heard of them, but my friend suggested them, and I am really liking them. My drink is some black coffee. Don't want to have the same type of thing all the time, right?
What the what! I know <if/else> stuff; now ternary operators can do that in one line?
Why did I learn <if/else> ? It better be because sometimes it's better to use one over the other.
Here's what I mean:
var x = 7;
var y = 4;

if (x > y) {
  result = "good job";
}
else {
  result = 20;
}

//Below is the above code written using the ternary operator
result = x > y ? "good job" : 20;

See what I mean? 
If I find out there's something after this that's even simpler, I'm going to be upset with these dudes.
Fist pump! I'm getting these down easy!
Maybe that's why they started with <if/else>? I hope that they had a plan when they did this.
So, the good news is that I can read the code they have set up for me and see what it means, the bad news is that now when I read anything and see punctuation commonly used in .js (<>?/+===) for instance, I start reading in 'code mode' when it's not code, and I get confused for a sec. That will probably go away after a bit. I hope?
That's all for me folks. I got a lot done today! See Y'all friday!
--Martin

Monday, January 6, 2014

Staying Frosty!

        So, the weather decided to be redonkulous today. In Texas, 33 degrees Fahrenheit is crazy cold even when there's no wind, but I got out of the house and game to my coffee shop to get my coffee on and some code done!
 I thought I'd start with some links that I found and/or were shared with me on G+:
link one:
http://www.christopherbiscardi.com/2014/01/06/flattening-nested-arrays-in-javascript/
I'm not COMPLETELY sure how this will be applied to me, but I've got some stuff that I'm working on that I think could be aided by this.
Also this:
http://www.javaworld.com/article/2078724/mobile-java/10-steps-to-becoming-the-developer-everyone-wants.html
The bullet points were enough for me, but read the definitions if you're crazy like that.

So, now down to business. I'm playing a Chris Cornell album called Carry On. I love the songs on here. A few covers, but they're decent.
Today's lesson starts off with MOAR conditionals.
var legalDrivingAge = 18;
var canIDrive =
  // write if else statement here. Return true or false
Have to make it return true or false if they can drive. This'll be easy. The next one will probably be crazy insane. That's how they do it. 
Turns out this was the crazy insane one. T`hose tricky bastards.
Also, what the hell does 
"Expected an identifier and instead saw ';'
missing semi colon."
Mean?? That's contradictory!
Side note:
doing my studies at a coffee shop is interesting in that I will occasionally glance around whilst sipping my latté (could actually afford one today! XD) and I'll be like; woah. those people weren't here a second ago. wait, it's been an hour?? haha!! 
// Define the function under this line
var canIdrive=function(myAge,legalDrivingAge){
 if(myAge>=legalDrivingAge){
     return true;
 }else{
     return false;
 }
};

// Declare legalDrivingAge under myAge
var myAge = prompt("How old are you?");
var legalDrivingAge=18;

//Create an if else statement using the function as a condition
if (myAge>=legalDrivingAge===true) {
  console.log("You can legally drive!");
}else {
  console.log("You'll have to wait a few more years!");
}
see that first 'var'?
yeah it just took me twenty minutes and a few WTFs to figure out that I missed that in my code...
Yup. Every coder person does that. well that was forever! 
see y'all wednesday!
--Martin