-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Expand file tree
/
Copy pathtest.js
More file actions
38 lines (27 loc) · 697 Bytes
/
test.js
File metadata and controls
38 lines (27 loc) · 697 Bytes
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
//Hello world
var msg = 'Hello World';
console.log(msg);
//Addation of 2 numbers
var x = 5;
var y = 2;
var z = x + y;
console.log(z);
//Addation of 2 Sting
var txt1 = "What a very ";
txt1 += "nice day";
console.log(txt1);
//JavaScript Arrays
var cars = ["Saab", "Volvo", "BMW"];
console.log(cars);
//Accessing the First Array Element
fruits = ["Banana", "Orange", "Apple", "Mango"];
var first = fruits[0];
console.log(first);
//Accessing the Last Array Elemen
fruits = ["Banana", "Orange", "Apple", "Mango"];
var last = fruits[fruits.length - 1];
console.log(last);
//Adding Array Elements
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Lemon");
console.log(fruits);