Introduction to Code

Intro to Code

What is code?

Code is instructions to a computer.

Code Syntax

In code there are special words and characters, variables you can name, and whitespace. Semicolons in JavaScript are like punctuation that act as periods for our code.

let hereIsAVariableWithASillyName = 'Hello, welcome to this course!';
console.log(hereIsAVariableWithASillyName);

There are certain rules for code. If you break the rules, your code will complain or not run.

There are also conventions on how to write code. If you use standard conventions your code will be easier to read and fix.

Printing

The standard way of viewing the result of your code in JavaScript is using console.log(). You will see the result in the web console. Programmers refer to this as printing or logging the code.

console.log('print what is in here');

Comments

Comments are a way of placing text in a code document without running the text as code. Often programmers will put notes in their code to remind teammates or themselves the purpose of a piece of code.

Two backslashes make up a single line comment and a slash and a star make up multiline JavaScript comments.

// here is an example of a single line comment
/* here is an example of a
of a multiline comment
neither of these will be run as code */