-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass1.html
704 lines (638 loc) · 25.8 KB
/
class1.html
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Class 1 ~ Javascript ~ Girl Develop IT</title>
<meta name="description" content="This is the official Girl Develop It Core Intro Javascript course. Material based on original material by Sara Chipps, Pamela Fox, Alexis Goldstein, Izzy Johnston and Leo Newball.
The course is meant to be taught in 4 two-hour sections. Each of the slides and practice files are customizable according to the needs of a given class or audience.">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="reveal/css/reveal.css">
<link rel="stylesheet" href="reveal/css/theme/gdidefault.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor<link rel="stylesheet" href="lib/css/light.css">-->
<!-- dark editor--><link rel="stylesheet" href="reveal/lib/css/dark.css">
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="reveal/css/print/pdf.css" type="text/css" media="print">
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- Opening slide -->
<section>
<img src = "images/gdi_logo_badge.png">
<h3>Beginner Javascript</h3>
<h4>Class 1</h4>
</section>
<!-- Welcome-->
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p class ="green">While we wait to get started, please ensure you have the following set up:</p>
<ul>
<li>A browser up and running (Recommendation: Chrome)</li>
<li>A text editor installed and running (Recommendation: Sublime Text 2)</li>
</ul>
</div>
</section>
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p>Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.</p>
<p class ="green">Some "rules"</p>
<ul>
<li>We are here for you!</li>
<li>Every question is important</li>
<li>Help each other</li>
<li>Have fun</li>
</ul>
</div>
</section>
<section>
<h3>Welcome!</h3>
<div class = "left-align">
<p class = "blue">Let's get to know eachother</p>
<ul>
<li>Who are you?</li>
<li>Why do you want to learn JavaScript?</li>
<li>Fun fact about you </li>
</ul>
</div>
</section>
<!-- Terms-->
<!--<section>
<h3>Terms</h3>
<ul>
<li>
<div class = "green">Web design</div>
<div>The process of planning, structuring and creating a website</div>
</li>
<li>
<div class = "green">Web development</div>
<div>The process of programming dynamic web applications</div>
</li>
<li>
<div class = "green">Front end</div>
<div>The outwardly visible elements of a website or application.
<span class ="blue">(Javascript goes here!)</span></div>
</li>
<li>
<div class = "green">Back end</div>
<div>The inner workings and functionality of a website or application.</div>
</li>
</ul>
</section>-->
<section>
<h3>Course Agenda</h3>
<ul>
<li class = "fragment">Class 1: Introduction to JavaScript</li>
<li class="fragment">Class 2: Deeper dive into JavaScript</li>
<li class = "fragment">Class 3: Introduction to jQuery</li>
<li class = "fragment">Class 4: Introduction to APIs, REST and AJAX (We will work with the Meetup.com API)</li>
</ul>
</section>
<section>
<h3>Course Flow</h3>
<ul>
<li class="fragment">Each class will include 3 exercises</li>
<li class="fragment">We will go through a group of slides that explain new concepts, then test our learnings in an exercise together. </li>
<li class = "fragment">In the first couple classes I will walk you through the exercises but as we get the hang of things, I will encourage you to work in partners. </li>
<li class = "fragment">At the end of each week, all code will be shared with you. It's more important to understand then to rush through copying. </li>
</ul>
</section>
<!-- Nitty gritty 1 - Clients and servers -->
<section>
<h3>Clients and servers</h3>
<p>How your computer accesses websites</p>
<img src = "images/client-server.png"/>
<p class = "fragment">JavaScript is "client side"</p>
<p class = "fragment">Your browser understands it!</p>
</section>
<!-- Nitty gritty 2 - Tools -->
<!--<section>
<h3>Tools</h3>
<ul>
<li>
<div class = "yellow">Browser</div>
<div>Chrome</div>
<div>Firefox</div>
</li>
<li>
<div class = "yellow">Development Toolkit</div>
<div>Chrome - Inspector</div>
<div>Firefox - Firebug</div>
</li>
<li>
<div class = "yellow">Text Editor</div>
<div>TextWrangler - Mac<br /><a href='http://www.barebones.com/products/textwrangler/'>http://www.barebones.com/products/textwrangler/</a></div>
<div>Notepad ++ - Windows<br /><a href='http://notepad-plus-plus.org/'>http://notepad-plus-plus.org/</a></div>
<div>Sublime Text - Mac or Windows<br /><a href='http://www.sublimetext.com/'>http://www.sublimetext.com/</a></div>
</li>
</ul>
</section>-->
<!-- History-->
<section>
<h3>JavaScript Introduction</h3>
<ul>
<li class = "fragment">JavaScript is a Scripting Language (a lightweight programming language)</li>
<li class="fragment">JavaScript is programming code that can be inserted into HTML pages.</li>
<li class = "fragment">JavaScript code can be executed by all modern web browsers.</li>
<li class = "fragment">JavaScript is the world's most popular programming language.</li>
</ul>
</section>
<section>
<h3>History of JavaScript</h3>
<ul>
<li class = "fragment">Developed by Brendan Eich of Netscape in 1995 (in 10 days!)</li>
<li class="fragment">Originally called Mocha and then LiveScript</li>
<li class = "fragment">Java -- Actually JavaScript has nothing to do with the language Java. Java was just the cool kid in town at the time.</li>
<li class = "fragment">The next version of JavaScript "ECMAScript 6" or "ES6" is in the process of being finalized and should be rolled out soon!</li>
</ul>
</section>
<!-- History-->
<!--<section>
<h3>History of JavaScript</h3>
<ul>
<li class = "fragment">"AJAX" -- a way to communicate to servers, coined in 2005</li>
<li class = "fragment">jQuery -- a super-popular JavaScript Library debuted 2006</li>
<li class = "fragment">Node.js -- a way for JavaScript to perform back end functions in 2010</li>
<li class = "fragment">2012 -- spec for JavaScript "nearly" finished</li>
</ul>
</section>-->
<section>
<h3>What JavaScript Is and Isn’t</h3>
<ul>
<li class = "fragment">The primary purpose of JavaScript is to add interactivity to the page.</li>
<li class = "fragment">JavaScript does not replace your HTML and CSS, it adds to it.</li>
<li class = "fragment">You may have heard of jQuery or played with it a little bit. This is a JavaScript library.</li>
<li class = "fragment">JavaScript libraries like jQuery, Mootools, Dojo, are collections of JavaScript code that handle the major of the heavy lifting for you (i.e. think "homepage sliders")</li>
</ul>
</section>
<!--What does JavaScript do -->
<section>
<h3>What does JavaScript do?</h3>
<ul>
<li><a href = "http://fancyapps.com/fancybox/#examples" target = '_blank'>Image Galleries and Lightboxes</a></li>
<li><a href = "https://www.google.com/doodles/30th-anniversary-of-pac-man" target = '_blank'>Games and all sorts of Google Doodles</a></li>
<li><a href = "http://www.girldevelopit.com/materials" target = '_blank'>Interactions, like show/hide and accordians</a></li>
<li><a href = "http://www.girldevelopit.com/classes" target = '_blank'>Retrieving data from other websites (through APIs)</a></li>
<li>All sorts of awesomeness, including this slideshow!</li>
</ul>
</section>
<!--What does JavaScript do -->
<section>
<h3>Best way to learn JavaScript...</h3>
<ul>
<li>DON'T BE SCARED!</li>
<li>Try things out without worrying about breaking the code. This is how you learn.</li>
<li>Practice! This course will not teach you everything about JavaScript, continue to practice on sites like CodeAcademy or Code School (or many others!)</li>
</ul>
</section>
<!--Statements -->
<section>
<h3>Statements/Script</h3>
<div>Each line in JavaScript is an instruction or a script</div>
<div>When the browser reads it, it "executes the script"</div>
<pre><code contenteditable class ="javascript">
alert('Hello');
</code></pre>
</section>
<!-- Variables-->
<section>
<h3>Variables</h3>
<div class = "fragment left-align">
<p>Variables hold content</p>
<p>Words, numbers, true/false, basically any kind of content</p>
</div>
<div class = "fragment">
<p>Declare a variable (Give it a name)</p>
<pre><code contenteditable class ="javascript">
var bananas;
</code></pre>
</div>
<div class = "fragment">
<p>Initialize variable (Give it a value)</p>
<pre><code contenteditable class ="javascript">
bananas = 5;
</code></pre>
</div>
</section>
<section>
<h3>Variables</h3>
<div class = "fragment">
<p>Declare and initialize at the same time!</p>
<pre><code contenteditable class ="javascript">
var bananas = 5;
</code></pre>
</div>
<div class = "fragment">
<p>Change value of variable</p>
<pre><code contenteditable class ="javascript">
bananas = 4;
</code></pre>
<p>(I ate a banana)</p>
</div>
</section>
<!-- Data Types-->
<section>
<h3>Data types</h3>
<div class = "fragment">
<p>string -- a group of characters in quotes</p>
<pre><code contenteditable class ="javascript">
var fruit = "banana";
</code></pre>
</div>
<div class = "fragment">
<p>number -- (well, a number)</p>
<pre><code contenteditable class ="javascript">
var pi = 3.14;
var year = 2013;
var bananaTally = 200;
</code></pre>
</div>
<div class = "fragment">
<p>boolean -- yes or no</p>
<pre><code contenteditable class ="javascript">
var skyIsBlue = true;
var grassIsPink = false;
</code></pre>
</div>
</section>
<!-- Data Types-->
<section>
<h3>Data types</h3>
<div class = "fragment">
<p>undefined -- no value yet</p>
<pre><code contenteditable class ="javascript">
var favoriteDinosaur;
</code></pre>
</div>
<div class = "fragment">
<p>null -- a purposely empty value (not the same as 0)</p>
<pre><code contenteditable class ="javascript">
var myTigersName = null;
</code></pre>
</div>
<div class = "fragment">
In nerd speak, JavaScript variables are "loosely typed". You don't know the kind of value a variable will have until you assign it.
</div>
</section>
<!-- Naming rules-->
<section>
<h3>Naming rules</h3>
<div class = "fragment">
<p>Begin with a letter, _, or $</p>
<p>Contain letters, numbers, _ and $</p>
<pre><code contenteditable class ="javascript">
var hello;
var _hello;
var $hello;
var hello2;
</code></pre>
</div>
<div class = "fragment">
<p>Names are case sensitive</p>
<pre><code contenteditable class ="javascript">
var hello;
var Hello;
var heLLO;
</code></pre>
</div>
</section>
<!-- Expressions -->
<section>
<h3>Expressions</h3>
<div class = "fragment">
<p>Math-y expressions!</p>
<pre><code contenteditable class ="javascript">
var bananas = 5;
var oranges = 2;
var fruit = bananas + oranges;
</code></pre>
</div>
<div class = "fragment">
<table>
<tr><th>Symbol</th><th>Meaning</th></tr>
<tr><td>+</td><td>Addition</td></tr>
<tr><td>-</td><td>Subtraction</td></tr>
<tr><td>*</td><td>Multiplication</td></tr>
<tr><td>/</td><td>Division</td></tr>
<tr><td>%</td><td>Modulus</td></tr>
<tr><td>++</td><td>Increment</td></tr>
<tr><td>--</td><td>Decrement</td></tr>
</table>
</div>
</section>
<!-- -->
<section>
<h3>Expressions</h3>
<div class = "fragment">
<p>Word-y expressions!</p>
<pre><code contenteditable class ="javascript">
var name = "Mitch";
var dinosaur = "Stegosaurus";
var sentence = "My dinosaur is a " + dinosaur + ". It's name is " + name + ".";
</code></pre>
</div>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It</h3>
<p>Create a new html file</p>
<pre><code class ="html">
<html>
<head>
<title>My Site!</title>
</head>
<body>
My site!
</body>
</html>
</code></pre>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Create a new javascript file (a file that ends in .js)</p>
<p>Link it to your html file</p>
<pre><code class ="html">
<html>
<head>
<title>My Site!</title>
<script src="javascript.js"></script>
</head>
<body>
My site!
</body>
</html>
</code></pre>
</section>
<section>
<h3>Let's Develop It</h3>
<p>Life time supply calculator</p>
<p>Ever wonder how much a lifetime supply of your favorite snack or drink is?</p>
<ul>
<li>Store your age in a variable</li>
<li>Store your maximum age in a variable</li>
<li>Store an estimated amount per day in a variable</li>
<li>Calculate how many you would eat/drink for the rest of your life.</li>
<li>Output the result in an alert(see below) like so: "You will need NN to last you until your old age of NN"</li>
</ul>
<pre><code contenteditable class ="javascript">
alert(answer);
</code></pre>
</section>
<!-- If statement-->
<section>
<h3>The if statement</h3>
<p>Javascript can run through code based on conditions</p>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
if (condition here){
// statement to execute
}
</code></pre>
</div>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
var bananas = 1;
if (bananas < 2){
console.log("You should buy more bananas!")
}
</code></pre>
</div>
<div class = "fragment">
Note: you can write comments that only you, not the browser reads
<pre><code contenteditable class ="javascript">
// comment on one line
/* comment on
multiple lines
*/
</code></pre>
</div>
</section>
<!-- Comparison-->
<section>
<h3>Comparisons</h3>
<table>
<tr class = "fragment"><td> === </td><td> Equality </td></tr>
<tr class = "fragment"><td> !== </td><td> Inequality </td></tr>
<tr class = "fragment"><td> > </td><td> Greater than </td></tr>
<tr class = "fragment"><td> >= </td><td> Greater than or equal to </td></tr>
<tr class = "fragment"><td> < </td><td> Less than </td></tr>
<tr class = "fragment"><td> <= </td><td> Less than or equal to </td></tr>
</table>
<p class = "fragment green"> Don't confuse = (assign a value) <br/>with === (compare a value)</p>
</section>
<!-- Logic-->
<section>
<h3>Logic</h3>
<table>
<tr class = "fragment"><td> && </td><td> AND </td></tr>
<tr class = "fragment"><td> || </td><td> OR </td></tr>
<tr class = "fragment"><td> ! </td><td> NOT </td></tr>
</table>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
var bananas = 5;
var oranges = 2;
if (bananas > 3 && oranges > 3){
console.log('Eat fruit!');
}
if (bananas < 2 || oranges < 2){
console.log('Buy fruit!');
}
if (!(bananas >= 0)){
console.log('How do you have negative bananas?');
}
</code></pre>
</div>
</section>
<!-- If/else-->
<section>
<h3>If/Else Statement</h3>
<p>You can use else to perform an alternative action if the "if" fails</p>
<pre><code contenteditable class ="javascript">
var bananas = 5;
if (bananas > 3){
console.log('Eat a banana!');
} else {
console.log('Buy a banana!');
}
</code></pre>
</section>
<section>
<h3>If/Else Statement</h3>
<p>You can use else if to have multiple choices</p>
<pre><code contenteditable class ="javascript">
var age = 20;
if (age >= 35) {
console.log('You can vote AND hold any place in government!');
} else if (age >= 25) {
console.log('You can vote AND run for the Senate!');
} else if (age >= 18) {
console.log('You can vote!');
} else {
console.log('You have no voice in government (yet)!');
}
</code></pre>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It!</h3>
<p class = "left-align">Add an if/else statement to our lifetime supply calculator so that if the lifetime supply is greater than 40,000, you say "Wow! That's a lot!" otherwise, say "You seem pretty reasonable!"</p>
</section>
<!-- Functions-->
<section>
<h3>Functions</h3>
<p class = "fragment">Functions are re-usable collections of statements</p>
<div class = "fragment">
Declare a function
<pre><code contenteditable class ="javascript">
function sayHi(){
console.log('Hi!');
}
</code></pre>
</div>
<div class = "fragment">
Call the function
<pre><code contenteditable class ="javascript">
sayHi();
</code></pre>
</div>
</section>
<!-- Functions cont.-->
<section>
<h3>Arguments</h3>
<p class = "fragment">Functions can take named arguments</p>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
function sayHi(name){
console.log('Hi' + name + '!');
}
sayHi('Mitch, the dinosaur');
sayHi('Harold, the hippo');
var name = 'Pip, the mouse';
sayHi(name);
</code></pre>
</div>
</section>
<!-- Functions cont.-->
<section>
<h3>Arguments</h3>
<p class = "fragment">Functions can take MULTIPLE named arguments</p>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
function addNumbers(num1, num2){
var result = num1 + num2;
console.log(result);
}
addNumbers(5, 6);
var number1 = 12;
var number2 = 15;
addNumbers(number1, number2);
</code></pre>
</div>
</section>
<!-- Functions cont.-->
<section>
<h3>Return values</h3>
<p class = "fragment">Functions can return a value</p>
<div class = "fragment">
<pre><code contenteditable class ="javascript">
function addNumbers(num1, num2){
var result = num1 + num2;
return result; //Anything after this line won't be read
}
var sum = addNumbers(5, 6);
</code></pre>
</div>
</section>
<!-- Functions cont.-->
<section>
<h3>Variable Scope</h3>
<p class = "fragment">JavaScript have "function scope". They are visible in the function where they are defined</p>
<div class = "fragment">
A variable with "local" scope:
<pre><code contenteditable class ="javascript">
function addNumbers(num1, num2){
var result = num1 + num2;
return result; //Anything after this line won't be read
}
var sum = addNumbers(5, 6);
console.log(result); //will return undefined because result only exists inside the addNumbers function
</code></pre>
</div>
</section>
<!-- Functions cont.-->
<section>
<h3>Variable Scope</h3>
<p class = "fragment">JavaScript have "function scope". They are visible in the function where they are defined</p>
<div class = "fragment">
A variable with "global" scope:
<pre><code contenteditable class ="javascript">
var result;
function addNumbers(num1, num2){
result = num1 + num2;
return result; //Anything after this line won't be read
}
var sum = addNumbers(5, 6);
console.log(result); //will return 11 because the variable was defined outside the function
</code></pre>
</div>
</section>
<!-- Exercise-->
<section>
<h3>Let's Develop It</h3>
<div>
<p>Wrap the lifetime supply calculator in a function called calculate()</p>
<p>Add a link to the html that calls the function when it is clicked</p>
<pre><code contenteditable class ="html">
<a href = "#" onclick="calculate()">
Calculate life time supply
</a>
</code></pre>
</div>
</section>
<!-- -->
<section>
<h2>Questions?</h2>
<div style = "font-size:1200%; height:100%; margin-top:40%" class ="blue">?
<div class ="clear"></div></div>
</section>
</div>
<footer>
<div class="copyright">
Javascript ~ Girl Develop It ~
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" /></a>
</div>
</footer>
</div>
<script src="reveal/lib/js/head.min.js"></script>
<script src="reveal/js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'reveal/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'reveal/plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'reveal/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'reveal/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>