Intro to Programming

What is Programming?

Computers are dumb. This might come as a shock, or seem controversial, but it's true. Computers are only capable of doing what they're told, and our role as the programmer, is to write code in a way that breaks down complicated instructions into steps so simple that even a computer can follow them.

When you're writing code, you're writing instructions for your computer to follow, similar to what you might do when writing a recipe for a friend or asking for a favour. When we communicate with each other, however, we rely on a lot of context. Imagine someone sent you this text message:

Can you make me a cup of tee?

Even though they made a spelling error, as a thinking human being, you know that what they meant to say is tea. Computers can't do that – when we communicate instructions to computers, we have to be very, very specific.

Assuming we could send this message to a computer, in its logic it might respond by telling you it doesn't know what "tee" is, or it might make you a cup containing a single golf tee. In either case, that's not what you want!

Getting Set Up

Step 1

Let's prepare our HTML document to link the JavaScript (.js file) to it.

Add the following HTML tag to the bottom of your index.html file, right before the closing </body> tag and save it.

    -- previous code --

    <script src="game.js></script>
</body>

When the HTML file is loaded again, it will ask the browser to fetch another file (called game.js) and apply the JavaScript to the page. Since our HTML page is loaded from top to bottom, it is important that our JavaScript files are linked right before the closing body tag, so that our HTML elements and CSS styles have a chance to load before we begin manipulating them with JavaScript.

Step 2

Oops, we don't even have that file in our project, let's add it the same way we created the index.html & style.css files.

In the end you should wind up with a folder structure like this:

results matching ""

    No results matching ""