- Printing, variables and arrays
Printing in the console:
In this tutorial we will learn to say something in the console, use variables, and arrays.
when you do the
function is creates some text in your console which is located inside the inspector
we will use the about:blank page in your browser to write code,
in this short clip I show you how to use the
(click to zoom in)
you need to use quotation marks when writing text!
Variables and Arrays:
variables are a type of element that holds data, if you are doing algebra in math you will have used a variable before.
to create a variable you must do
VAR <variable name> = <variable value>;
Most lines of code will end with a ;
As you can see we declared a name and a value for our variable
our the main types
- Booleans: have true or false as the value
- Strings: have "<text>" as the value (the <text> part varies)
- Integers or ints: numbers without any quotation marks!
You can use variables in printing by doing this:
var str = "Hello, World!"; console.log(str);
In that code we declared a new variable<string> and set its value to Hello, World!
then we printed the variable!
This clip will show you how to start writing your code!