-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgettingstarted.txt
40 lines (28 loc) · 927 Bytes
/
gettingstarted.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Getting started with javascript
Variables
In javascript variables are used to store information. Variables are also case sensitives.
You can store strings, arrays, numbers or objects
<pre><code class="javascript">
var a = "Hello";
console.log(a) //prints out Hello
var A = "World";
console.log(A) //prints out World
//store an array in a variable
var array = [1,2,4];
console.log(array) // [1, 2, 4]
</code></pre>
You can also do arithmetic with variables. All the common operators work "+, -, *, /"
<pre><code class="javascript">
var num1 = 10;
var num2 = 15;
var num3 = num1 + num2;
console.log(num3) //25
</code></pre>
If you use the plus operators with strings then the two strings are concatenated.
<pre><code class="javascript">
var a = "Hello";
var b = "World";
// concatenated an empty space also to make the print out clear
var wholeString = a + " "+ b;
console.log(wholeString)//Hello World
</code></pre>