-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintroductionjavascript.js
140 lines (99 loc) · 2.2 KB
/
introductionjavascript.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// numbers //
// adding the datatype number//
80 + 80
// adding the booleans and number//
true + 1
// adding number and string//
5 + "foo"
// strings //
// concatenates strings together //
"love" + "hurt" + "hate" + "food"
// strings are true for they are the same character and spaces"
"Patch my boat with chewing gum." == "Patch my boat with chewing gum."
// string turned into an array //
"chinenyemlovesfrankeandrueben" .split("")
//array//
// length of the array//
["c", "h", "i", "n", "e", "n", "y", "e", "m", "l", "o", "v", "e", "s", "f", "r", "a", "n", "k", "e", "a", "n", "d", "r", "u", "e", "b", "e", "n"] .length
// reverse the array including a string //
[4, "love", 8] .reverse ("")
//push array//
var fruits = ["Banana", "Orange", "Apple", "Mango"];
undefined
fruits.push("Kiwi");
5
fruits
["Banana", "Orange", "Apple", "Mango", "Kiwi"]
// function
var arr = [];
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
"Borge"
var arr = [];
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
console.log(arr.join());
arr.splice(2, 0, "Lene");
console.log(arr.join());
Jani,Hege,Stale,Kai Jim,Borge VM2264:9
Jani,Hege,Lene,Stale,Kai Jim,Borge VM2264:11
undefined
function chinenyem = function(x, y)
function chinenyem(x, y) {
return "howard"
}
function clickHandler() {
alert("Hello, World!");
}
return clickHandler
// object //
// this is an example of a mutation. turning propertyName into length
// and text into mainline//
var propertyName = "length";
var text = "mainline";
propertyName + text
//booleans
[ 2,4,8, 6] > [1,1,1,1]
true
var love = 5
undefined
var hate = 6
undefined
love < hate
true
var love = 5
undefined
var hate = 6
undefined
love < hate
true
var cat =10
undefined
var car =1
undefined
car + cat === love + hate
true
var chinedu = 500;
undefined
chinedu = chinedu - 100;
console .log(chinedu);
undefined
400
var mouse = function(b){
return b * 19;
};
mouse(2);
function house(a,b,c) {
var bedroom = (a);
var office = (b);
var kitchen = (c);
var buildhouse = bedroom + office + kitchen;
return buildhouse;
}
house('mom room,' , 'mom office' , 'mom kitchen');