Monday, May 26, 2014

Things Remembered/Know The Rules

Well, howdy! Or, rather, hello netizens. Sorry, I got a little Southern there. For those that don't know, netizen: a person who actively uses the internet especially in a proper and responsible way. The more you know. So, today I'm going to talk about some things that have made me stumble for stupid/crazy simple reasons. There are two main issues that I've come across. But first! I'm going to make coffee. Good thing this isn't a live stream. Now that ten minutes have passed for me and about a second for you, I'm back with coffee and sustenance. Le Music De Goog(read Google Play Music) is going and I'm ready. Time to plug in and plug away!

The biggest thing that gets my metaphorical goat is when your code looks like it's correct, there aren't any errors or anything like that, and it still doesn't return the result that you want. for instance: nested if statements. If you don't do them the right way, they will ignore entire sections of the code. For example:
<script type = "text/javascript">
var artist = "Foo Fighters"
var song = "Walk"

if(artist != "Foo Fighters"){
    alert("You don't like 'em, eh?");
      if(song == "Walk"){
        alert("nice choice");
      }else{
        alert("Too slow for you?");
      }
  }else{
    alert("Nice!");
  }
</script>

While this looks like it is correct, notice that the first if statement has a != that means does not equal. But the variable artist does equal "Foo Fighters" so it has to go to the end of the script to use alert("Nice!"); which means that the second if statement gets completely ignored. However, if the artist variable didn't equal "Foo Fighters" you'd be fine. So, it just calls for a little preexisting knowledge about your variables. Because if you don't know what's going on, your code will soon get really messed up and you won't know why because it all looks fine. Makes for debugging very annoying when you find out that you just had things in the wrong order, or something. The worst is when you spend hours trying to fix your code and it turns out that you're missing a period, or something like that. And if you haven't had this happen, it will. Don't worry.

Another thing that will mess you up is not knowing the rules. And the rule that doesn't get talked about too much, is that you can't name a variable with a number. So, var 1 ="hi" wouldn't register. It just sits there and does nothing. I'm not saying I've done this(totally have),but if I had(which I did) then I would tell you that it's annoying to look up the problem and it just makes you realize what a newb you are. 

So, there we have it, some things to watch out for in any language. 
1. Know the order in which things are read and run.
2. Know the rules.
3. Know that you'll mess up and don't be afraid of it.

And with that, I'll go and finish listening to +Jupiter Broadcasting because those guys are awesome.
See y'all on Wednesday!



 --Martin 

Friday, May 23, 2014

Explain (not all) The Things/ It's Not Scary

   Well, howdy y'all! It's Friday and that means that I have a post to... post? Yeah, that's gotta be a thing. Today, for my "doozy" I decided to take some of the names of things in JavaScript and try to define them AND link to Mozilla. They know how to explain things really well. Sometimes. So, after having made it to the coffee shop and dealt with people, I'm ready to do this. My music is random things from Google and The Roots' latest album. So, let's plug in and plug away!


 JavaScript 

      So, the first things we should cover are the basics such as Values, variables and literals.

Variables
   Variables are just like in algebra. They store info. Of any type. For example: var x = 25 var x = "Hello" var x = true Notice that var is variable. Duh. The first var is a numeral. Numerals are numbers. Duh, again. Most of the names for things make sense which is good because there are a lot. The second var is a string. A string is anything (numbers, symbols, punctuation) surrounded by quotations. "this" "15" "A" "string..." those are all strings. the last var is a Boolean. You hear a lot about Booleans. A Boolean is just a true or a false. That's it.

Arrays
   Arrays are mainly just like variables, but there's usually more than one of them. The only difference is that they have brackets([]) surrounding whatever it is that is an array. For example: var x = ["French Roast", true, 25]; Notice that different types in the array. This can be very helpful when you need to call certain things multiple times.

   Now, I don't expect to show you all of the things that could be called. I'm just trying to show that everything makes sense and has its own way of working. It's not a scary foreign language. It's just something that can make really cool things happen.
   For a larger list with bigger words, check out this to realize that there is a lot of stuff. But, again, don't let it scare you. Just think of the dictionary. That's a really thick book, but you don't have issues communicating. Same thing with this. The words you need, you will memorize.
For now, that'll be all. See y'all on Monday.


 --Martin 

Wednesday, May 21, 2014

Back To The Basics/.js All Up In Your HTML

Hello, y'all! Yup, it's a Wednesday. Again. Darn thing keeps coming back! Today's post is going to cover JavaScript since we're back to the basics, all of y'all should be able to keep up. Today's music is NOT GrooveShark. Whoa, right? Not really. I'm a big Jimmy Fallon fan and watch the show all the time. The band that plays on there is called The Roots and they came out with a new album, so that's what I'm listening to! That took a while to explain. I love the album! It's called "... and the you shoot your cousin" Yup. On le Google Music. It's also on iTunes and whatnot. So, now that I overly explained my musical choice, let's plug in and plug away!


 JavaScript 




      This might have been covered before, but like I said, I'm going over some things again. Today, I'm working on using a .js script on an HTML5 webpage. Which is a lot like CSS. You can put in the <script> tags into the actual HTML page. The location of which can mean things. Not like, spiritually! Goof. Like when they when triggered and such. The easiest(for now) way to do it is how you call a CSS script from another page. For those of you that don't know how to do that, go here where it talks about other things getting called and how it can effect things. Affect things? Buh. Those two... ANYhoo, you just in a script like this:

<!DOCTYPE html>
  <head>
    <title> Hola al mundo</title>
    <script type = "text/javascript" src = "Day_One.js"> <!--The script for the .js stuff -->
    </script>
  </head>
</html>

   Notice the script tag calling out the type and source of the .js script from a separate file. Now, once things get going, the source can became quite convoluted especially if you're using a NAS drive or something fancy. So, always remember to get everything correct. Now, the .js side to this doesn't have to change anything, it just does its own thing, and gets called out by the HTML. So, the code that I'm using that is getting called out looks like this:

 for(i=0; i<10; i++)
      if(i===5){
        alert("there is a five");
      }else{
        document.write(i);

      }
Now, the fun thing to be noticed here is that the code will run from 0 to 4, throw the alert at you, and only AFTER you acknowledge it, the code will continue. Pretty nifty! So, there you have it, how to connect the two things. 

   I'm going to go find a doozy for y'all on Friday. See y'all then!


--Martin