Intro to Javascript – Programming Virgin




http://codebabes.com/courses/programming-virgin
Welcome to the Codebabes programming virgin course. In this course all you need is a text editor, a computer, a browser, and your brain. This course explains basic programming concepts used in languages like Ruby, Python, PHP, and others just with minor differences in syntax and nomenclature.

We use Javascript in this lesson because it’s a good language to start with. It’s based on C like a bunch of other languages, and your browser understands it. We’ll show you how to write it directly in the browser.

Programming languages are just a tool, a means to an end. Once you master the concepts of programming and a language or two, it makes it easier to learn new ones. Just like if you’re good at picking up babes. Once you figure it out, it doesn’t matter who the next one is right? I’m sure you’re all regular casanovas.

First, let’s add some javascript to a basic webpage. We’ve got an html page already written in a directory on our desktop. We just need to add a javascript file named script dot JS inside our website directory. Ok, open the html file and add the script tag between the head tags. We do this by writing the script tag and then source equal to the path of our javascript file in relation to this html file. Since they are in the same directory we can just write the name of the file, script dot js. When the browser sees this it knows there’s some javascript up in here. You can name your javascript file whatever you want, but script dot js is pretty common.

That’s a good way to add javascript to a page. If you wrote some javascript in here, it would load when you opened this html file. But, let’s explore an even easier way to start writing javascript. Everybody likes easy right?

Open the html file with Chrome. On a side note, Chrome is an awesome browser to use, but as long as you’re not using Internet Explorer you are in pretty good shape. If you use Internet Explorer you’re definitely not getting my number.

Once you’re in chrome you need to open the javascript console. Go to view, developer, then javascript console. There’s also a keyboard shortcut. If you’re getting into programming, start learning keyboard shortcuts, they are super sexy.

Now we have a console to frolick in. This is similar to the command line. It allows you to write javascript commands that the browser will interpret.

Let’s start with some math. Math is sexy! We can do 1 + 1, and it will output 2. Easy right? We can get more complicated too, like (20 + 3) * 3. Which equals 69. So, then we would type, hahaha, cause you know, we’re all pretty immature. Except if you do that and hit enter you’ll get an Error! This is because javascript doesn’t know what hahaha is. We want it to be interpreted as the word ‘hahaha’, a string in programming lingo. Numbers are known as integers. Strings and integers are common throughout programming. If a number has a decimal attached then it’s called a float.

The thing with strings is that they need to be enclosed in quotes. If it’s not in quotes javascript doesn’t know whether the text is a command, variable or in this case, a string.

A string can be numbers too, like a phone number. We don’t want a phone number to be treated like a normal integer, so we wrap it in quotations and make it a string.

You can also put together two strings, like “hey girl ” and “you had me at hello world” with the plus sign, but make sure to have a space after hey girl. In programming lingo, putting stuff together like this is called concatenation.

Let’s get a little freaky. We can use built in javascript functions to make things more interactive. Let’s write alert, parentheses, then the string, “stop playing with yourself” in quotes. Hit return and this pops up an alert in the browser. If you want to run that command again in the console you can just hit the up arrow on your keyboard. A function is just a bit of code that you can use over and over again to do stuff, all kinds of stuff. Programming languages have built in functions, but you can also write your own, which we’ll talk about later.

That’s it for the intro to programming. Next lesson we’ll talk about our first topic, variables. And I’ll turn up the heat.
http://codebabes.com/courses/programming-virgin

Original source


26 responses to “Intro to Javascript – Programming Virgin”

  1. Living the joking aside and the "they are just models reciting something" comments, you can actually learn something solid here. I think you people should continue and cover more complicated concepts.

  2. Javascript is not based on C.
    It's syntax was made to resemble java, and it's design principles are based on Scheme and self, and some others that came from Xerox Parc.

    Please don't spread misinformation.

  3. Ребят, а мне очень понравился курс Евгения Попова. Все очень качественно и понятным языком изложено, очень доволен. Единственный минус – он платный. Но он того стоит, я не капли не пожалел. всем советую)) Ссылка внизу.
    http://p.cscore.ru/s/19735

Leave a Reply