Heh. Lines.
Today's music is... Electro Chill. I know, not very informative, but that's pretty much what it is. Anyways, I'm cold. So, I'm going to make some coffee and get a sammich, or something and then I'm going to plug in and plug away!
JavaScript
Today, we're doing fun with functions. I know; lame play on words. If you can even call it that. Blame the class. They're the ones that used it. AAANYhoo, Here's a little something for you:
/*Add a speak method to the Person constructor. Whenever speak is called, it should print "Hello!" to the console.*/
function Person(job, married) {
this.job = job;
this.married = married;
// add a "speak" method to Person!
this.speak = function(){
console.log("Hello!");
};
}
var user = new Person("Codecademy Student",false);
user.speak();
Now, here's the thing; not all of that code applies to what they wanted me to do, but I think I can point out where and why you need it. This code is called a Constructor and we have a Method inside of it. Notice that there is the new Peron and the user.speak. They just wanted me to add the speak part. The whole function applies to user, but when you call a specific section like user.speak, it doesn't matter what else you have wrong as long as what you're calling is correct. Everything else applies to the variable user, and if I was to call that and anything was wrong, I would get errors.
Woah. That was crazy. I'm always amazed when I know what they're talking about in the lessons. I figured it out with the hint, and usually those things are no help at all. This time I got it! I'll count that as a victory for me.
Well, that was just stupid. Apparently, the lesson has a bug, and the devs don't seem to care to fix it. The forum was filled with people that couldn't figure it out. So, I posted the working code that I found/figured out in the forum. Hopefully that'll help some people. Definitely a WTF moment.
And, last, but least, I leave with a new built-in operator. <typeof> //angel voices
It's actually really helpful! Here's Mozilla's definition on it: "The typeof operator returns a string indicating the type of the unevaluated operand." Basically, if you don't know what type of code you're dealing with, you use typeof, and there you go! it'll tell you!
There you have it, folks! a whole bunch of .js. for your noggin. I'm still getting through the HTML. The only new thing I've learned is the <hr /> thing that makes a line. I'll see y'all on Wednesday! Hopefully the ice will be gone.
No comments:
Post a Comment