-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript Meet up.js
More file actions
219 lines (116 loc) · 3.73 KB
/
javascript Meet up.js
File metadata and controls
219 lines (116 loc) · 3.73 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
introduction :
JavaScript
js got its name from Java
a programming language for computer
what use forme
Animation
Event hadling
dynamic styling
Everybody use this
webbrowser read js code like human
all js code follow specific contraint
js in put : 22 + 4 / 22 +"Austin"
js out put : 26 / "22 Austin"
js variable :
var myName = "tyler"
var theYear = 2015
variable
must start
la première de js est js minuscule daprès la convention
var myName = "kevin"
myName = "not kevin" js = not kevin
console.log(myName)
var myName = "kevin"
console.log(myName) js kevin
myName = "not kevin"
var x = 15
var y = x
math operation
var x = 22
var y = 4
var Z = x / y
(22 + 4 + 2 - 2) / 4
function
var myFunction = function(){
code to be excuted
}
ex :
var makeSeven = function {
return 6 + 1
}
var calculation =
var myfunction = function(num1, num2) {
return num1 * num2
}
function vs
var kevinThrow = function(item) {
[...] // code here
}
kevinThrow(ball); //ball is your argument
js : math library
in put Math.random() * 10 between 0 and 1
out put 8,394
in put math.floor(4.7) need a number
out put 3
math.max(23, 45, 12, 18, 4)
output : 45
var myName = "John"
myName.length
string concatenation
var firstname = "Amelie"
var lastname = "Lee"
var fullname = firstname + " " + lastname
fullname.toUpperCase()
"hello"tolowcase()
"HELLO"toUpCase()
career transtion sequence
4 week prep course 17 octobre to 13 novembre
interview deadline 26
12 dec to march hackReactor immersive
795$ pré programs 98% placement telegraph Academy
104k salaire
angularjs par google / react /
getCoding.HackReactor.com/bootcamp-prep
prep@telegraphacademy.com
Exercise 1: Restaurant Tip Calculator
1) Define a function named calculateTip and give it two arguments: total and percent
2) Inside your function, use the return keyword to output a tip according to the percent argument.
Extra Credit: Want to shave off the extra decimal places? Click here to learn about the .toFixed() function and how to use it.
In the example below, your function should output 7.965.
calculateTip(44.25, 18)
solution :
var calculateTip = function(total, tips) {
return total * tips / 100;
}
calculateTip(44.25, 18);
Exercise 2: Picking apart a URL
1) Define a function named removePrefix and give it one argument: url
2) Inside your function, return the url without "www." included. Hint: Use .slice
Hint: Don't forget to wrap quotes around your strings!
In the example below, your function should output google.com.
removePrefix('www.google.com')
var fruits = ["Banane", "Orange", "Citron", "Pomme", "Mangue"];
var agrumes = fruits.slice(1, 3);
// fruits vaut --> ["Banane", "Orange", "Citron", "Pomme", "Mangue"]
// agrumes vaut --> ["Orange", "Citron"]
solution :
var removePrefix = function(url) {
return url.slice(3);
};
removePrefix("www.google.com");
Exercise 3: Random Number Generator
1) Define a function named randomNumberGen with no arguments.
2) Inside your function, return a random number between 1 and 10. Hint: Use Math.random() and Math.floor(number)
In the example below, your function should output a whole number between 1 and 10.
randomNumberGen()
Solution :
var randomNumberGen = function() {
return Math.floor(Math.random() * 10);
}
randomNumberGen()
Math.floor: défini lentier le plus petit
Exercise 4 : Super Extra Credit: "Sentence Reverser"
1) Define a function named reverseSentence with one argument: sentence
2) Inside your function, return the reversed copy of the sentence that is passed in as an argument. Hint: Use String.split() Array.reverse() and Array.join()
In the example below, your function should output "!ecnetnes emosewa na si sihT".
reverseSentence('This is an awesome sentence!')