SlideShare una empresa de Scribd logo
1 de 42
Descargar para leer sin conexión
BEGINNING JAVASCRIPT
CLASS 1Javascript ~ Girl Develop It ~
WELCOME!
Girl Develop It is here to provide affordable and
accessible programs to learn software through
mentorship and hands-on instruction.
Some "rules"
We are here for you!
Every question is important
Help each other
Have fun
WELCOME!
Tell us about yourself.
Who are you?
What do you hope to get out of the class?
What is your favorite dinosaur?
TERMS
Web design
The process of planning, structuring and creating a
website.
Web development
The process of programming dynamic web
applications. (JavaScript goes here!)
Front end
The outwardly visible elements of a website or
application. (JavaScript goes here, too!)
Back end
The inner workings and functionality of a website or
application. (Recently, JavaScript has started to
arrive here!)
CLIENTS AND SERVERS
How your computer accesses websites
JavaScript is "client side"
Your browser understands it!
TOOLS
Browser
Browser Developer Tools
Chrome, IE, and Safari Developer Tools
Firebug for Firefox
Opera Dragonfly
Text Editors
Eclipse JSDT - Windows and Mac
Aptana - Windows and Mac
Sublime Text - Windows and Mac
Notepad++ - Windows
HISTORY OF JAVASCRIPT
Developed by Brendan Eich of Netscape in 1995 (in
10 days!)
Originally called Mocha and then LiveScript
Java -- Actually, JavaScript has nothing to do with the
language Java. Java was just the cool kid in town at
the time.
Script -- Instructions that a computer can run one line
at a time
HISTORY OF JAVASCRIPT
1996 - Netscape 2 is released with JavaScript
support
1997 - First standardized version of JavaScript
2005 - AJAX is first coined. AJAX is used to
communicate with servers using JavaScript.
2006 - jQuery, a super-popular JavaScript library,
debuts.
2010 - Node.js debuts. This provided a way for
JavaScript to perform back end functions (although
not the first).
2012 - The spec for JavaScript is "nearly" finished.
WHAT DOES JAVASCRIPT DO?
Primary use is controlling the browser, manipulating
Web pages, and enhancing user interaction.
All sorts of awesomeness, including this slideshow!
Image Galleries and Lightboxes
Games and all sorts of Google Doodles
Interactions, like show/hide and accordians
Retrieving data from other websites (through
APIs)
VALUES, TYPES, AND VARIABLES
The fundamental building blocks of programming
languages are values, types, and variables.
A variable stores a value. The value is defined by a
type.
VALUES
Any piece of information that a computer program can
store or manipulate.
For example:
The sentence "Hello, world!"
The number 3.14
A set of numbers [3.14, 6.09, 9.0805]
A set of strings ["Welcome", "to", "JavaScript"]
VARIABLES
A storage location for a value used to perform
computations.
Declare a variable (give it a name)
Initialize variable (give it a value and a type)
Declare AND initialize at the same time!
Change value of variable
var bananas;
bananas = 5;
var bananas = 5;
bananas = 4; //I ate a banana.
COMMENTS
You can write comments that only you, not the browser,
reads
// comment on one line
/* comment on
multiple lines */
TYPES
The definition of the kinds of data a computer program
can store or manipulate.
JavaScript infers the type based on the data. This is
known as "loosely typed" in nerd speak.
TYPES
Primitives
Number - well, a number!
String - a collection of characters.
Boolean - a true or false value.
Array - a collection of values.
null - no valid value or purposely empty.
undefined - no value has been initialized or set yet.
Objects
Anything that isn't a primitive.
DATA TYPES
string -- a group of characters in quotes
number -- (well, a number)
boolean -- yes or no
var fruit = "banana";
var pi = 3.14;
var year = 2013;
var bananaTally = 200;
var skyIsBlue = true;
var grassIsPink = false;
DATA TYPES
undefined -- no value yet
null -- a purposely empty value (not the same as 0)
var favoriteDinosaur;
var myTigersName = null;
NAMING RULES
Begin with a letter, _, or $
Contain letters, numbers, _ and $
Names are case sensitive
var hello;
var _hello;
var $hello;
var hello2;
var hello;
var Hello;
var heLLO;
MATHEMATICAL EXPRESSIONS
Symbol Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
-- Decrement
var bananas = 5;
var oranges = 2;
var fruit = bananas + oranges;
STRING EXPRESSIONS
var name = "Mitch";
var dinosaur = "Stegosaurus";
var sentence = "My dinosaur is a " + dinosaur + ". It's name is " + name + ".";
INCLUDING JAVASCRIPT
Inline - a script tag with code inside of it.
External - a script tag that points to another file.
<body>
<script>
</script>
</body>
var dinosaur = "Liopleurodon";
...
<body>
<script src="external.js"></script>
</body>
LET'S DEVELOP IT
Create a new HTML file
Create a new JavaScript file (.js extension) and include
it on the page.
<html>
<head>
<title>My Site!</title>
</head>
<body>
My site!
</body>
</html>
<head>
<title>My Site!</title>
<script src="calculator.js"></script>
</head>
LET'S DEVELOP IT
Life time supply calculator
Ever wonder how much a lifetime supply of your
favorite snack or drink is?
Store your age in a variable
Store your maximum age in a variable
Store an estimated amount per day in a variable
Calculate how many you would eat/drink for the rest
of your life.
Output the result into the page (see below) like so:
"You will need NN to last you until your old age of
NN"
document.write(answer);
LET'S ANSWER IT!
var age = 26;
var oldAge = 96;
var perDay = 2;
var days = (oldAge - age) * 365;
var total = perDay * days;
document.write("You will need $" + total + " to last you until the ripe old age of " + oldAge);
COMPARISONS
=== Equality
!== Inequality
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
Don't confuse = (assign a value)
with === (compare a value)
var name = "Mitch";
document.write(name === "Mitch"); //true
LOGIC
&& AND
|| OR
! NOT
var bananas = 5;
var oranges = 2;
document.write(bananas > 3 && oranges > 3); //false
document.write(bananas < 2 || oranges < 2); //false
document.write(bananas !== oranges); //true
THE IF STATEMENT
JavaScript can run through code based on conditions
if (condition here){
// statement to execute
}
var bananas = 1;
if (bananas < 2){
document.write("You should buy more bananas!");
}
IF/ELSE STATEMENT
You can use else to perform an alternative action if the
"if" fails
var bananas = 5;
if (bananas > 3){
document.write('Eat a banana!');
}
else {
document.write('Buy a banana!');
}
IF/ELSE STATEMENT
You can use else if to have multiple choices
var age = 20;
if (age >= 35) {
document.write('You can vote AND hold any place in government!');
}
else if (age >= 25) {
document.write('You can vote AND run for the Senate!');
}
else if (age >= 18) {
document.write('You can vote!');
}
else {
document.write('You have no voice in government (yet)!');
}
LET'S DEVELOP IT!
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!"
LET'S ANSWER IT!
var age = 26;
var oldAge = 96;
var perDay = 2;
var days = (oldAge - age) * 356;
var total = perDay * days;
if(total > 40000){
document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's
a lot!");
}
else{
document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pr
etty reasonable");
}
FUNCTIONS
Functions are re-usable collections of statements
Declare a function
Call the function
function sayHi(){
document.write('Hi!');
}
sayHi();
ARGUMENTS
Functions can take named values known as arguments.
function sayHi(name){
console.log('Hi' + name + '!');
}
sayHi('Mitch, the dinosaur');
sayHi('Harold, the hippo');
var mouseName = 'Pip, the mouse';
sayHi(mouseName);
ARGUMENTS
Functions can take MULTIPLE named arguments
function addNumbers(num1, num2){
var result = num1 + num2;
document.write(result);
}
addNumbers(5, 6);
var number1 = 12;
var number2 = 30;
addNumbers(number1, number2);
RETURN VALUES
Functions can return a value to you (such as the result
of addition).
function addNumbers(num1, num2){
var result = num1 + num2;
return result; //Anything after this line won't be read
}
var meaningOfLife = addNumbers(12, 30);
document.write(meaningOfLife);
VARIABLE SCOPE
JavaScript have "function scope". That means the
variables are only accessible in the function where they
are defined.
A variable with "local" scope:
function addNumbers(num1, num2){
var result = num1 + num2;
return result;
}
var meaningOfLife = addNumbers(12, 30);
document.write(result);
//This will show as undefined because the result variable only exists inside the addNumbers function.
LET'S DEVELOP IT!
Wrap the lifetime supply calculator in a function called
calculate()
Add a button to the html that calls the function when it is
clicked
<button type="button" onclick="calculate()">
Calculate life time supply
</button>
LET'S ANSWER IT!
function calculate(){
var age = 26;
var oldAge = 96;
var perDay = 2;
var days = (oldAge - age) * 356;
var total = perDay * days;
if(total > 40000) {
document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's
a lot!"); }
else {
document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pr
etty reasonable"); }
}
QUESTIONS?
?
GDI Seattle - Intro to JavaScript Class 1

Más contenido relacionado

La actualidad más candente

Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Andre Foeken
 
Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Rafael Dohms
 
Introduction to Moose
Introduction to MooseIntroduction to Moose
Introduction to Moosethashaa
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingNando Vieira
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackDavid Copeland
 
Vision academy classes bcs_bca_bba_sybba_php
Vision academy  classes bcs_bca_bba_sybba_phpVision academy  classes bcs_bca_bba_sybba_php
Vision academy classes bcs_bca_bba_sybba_phpsachin892777
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQueryorestJump
 
Marc’s (bio)perl course
Marc’s (bio)perl courseMarc’s (bio)perl course
Marc’s (bio)perl courseMarc Logghe
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Introduction to PHP Lecture 1
Introduction to PHP Lecture 1Introduction to PHP Lecture 1
Introduction to PHP Lecture 1Ajay Khatri
 
Let's write secure Drupal code!
Let's write secure Drupal code!Let's write secure Drupal code!
Let's write secure Drupal code!Balázs Tatár
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersGiovanni924
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 

La actualidad más candente (20)

Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)
 
Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13
 
Introduction to Moose
Introduction to MooseIntroduction to Moose
Introduction to Moose
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power Stack
 
Vision academy classes bcs_bca_bba_sybba_php
Vision academy  classes bcs_bca_bba_sybba_phpVision academy  classes bcs_bca_bba_sybba_php
Vision academy classes bcs_bca_bba_sybba_php
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Javascript
JavascriptJavascript
Javascript
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQuery
 
Marc’s (bio)perl course
Marc’s (bio)perl courseMarc’s (bio)perl course
Marc’s (bio)perl course
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Phphacku iitd
Phphacku iitdPhphacku iitd
Phphacku iitd
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Introduction to PHP Lecture 1
Introduction to PHP Lecture 1Introduction to PHP Lecture 1
Introduction to PHP Lecture 1
 
Let's write secure Drupal code!
Let's write secure Drupal code!Let's write secure Drupal code!
Let's write secure Drupal code!
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
jQuery
jQueryjQuery
jQuery
 

Destacado

Kuala Lumpur Hotels
Kuala Lumpur HotelsKuala Lumpur Hotels
Kuala Lumpur Hotelsquicksweet
 
GDI Seattle - Intro to JavaScript Class 2
GDI Seattle - Intro to JavaScript Class 2GDI Seattle - Intro to JavaScript Class 2
GDI Seattle - Intro to JavaScript Class 2Heather Rock
 
GDI Seattle - Intermediate HTML and CSS Class 3 Slides
GDI Seattle - Intermediate HTML and CSS Class 3 SlidesGDI Seattle - Intermediate HTML and CSS Class 3 Slides
GDI Seattle - Intermediate HTML and CSS Class 3 SlidesHeather Rock
 
New cervical screening guidelines. 1
New cervical screening guidelines. 1New cervical screening guidelines. 1
New cervical screening guidelines. 1CSPWQ
 
GDI Seattle - Web Accessibility Class 1
GDI Seattle - Web Accessibility Class 1GDI Seattle - Web Accessibility Class 1
GDI Seattle - Web Accessibility Class 1Heather Rock
 
Prova origami
Prova origamiProva origami
Prova origamipiranzor
 

Destacado (8)

Pic pas demo
Pic pas demoPic pas demo
Pic pas demo
 
Kuala Lumpur Hotels
Kuala Lumpur HotelsKuala Lumpur Hotels
Kuala Lumpur Hotels
 
GDI Seattle - Intro to JavaScript Class 2
GDI Seattle - Intro to JavaScript Class 2GDI Seattle - Intro to JavaScript Class 2
GDI Seattle - Intro to JavaScript Class 2
 
GDI Seattle - Intermediate HTML and CSS Class 3 Slides
GDI Seattle - Intermediate HTML and CSS Class 3 SlidesGDI Seattle - Intermediate HTML and CSS Class 3 Slides
GDI Seattle - Intermediate HTML and CSS Class 3 Slides
 
New cervical screening guidelines. 1
New cervical screening guidelines. 1New cervical screening guidelines. 1
New cervical screening guidelines. 1
 
Nelson mandela
Nelson mandelaNelson mandela
Nelson mandela
 
GDI Seattle - Web Accessibility Class 1
GDI Seattle - Web Accessibility Class 1GDI Seattle - Web Accessibility Class 1
GDI Seattle - Web Accessibility Class 1
 
Prova origami
Prova origamiProva origami
Prova origami
 

Similar a GDI Seattle - Intro to JavaScript Class 1

Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04Hassen Poreya
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014hwilming
 
Intro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXIntro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXCindy Royal
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to ProgrammingCindy Royal
 
Intro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXIntro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXCindy Royal
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboardsDenis Ristic
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
Reason - introduction to language and its ecosystem | Łukasz Strączyński
Reason - introduction to language and its ecosystem | Łukasz StrączyńskiReason - introduction to language and its ecosystem | Łukasz Strączyński
Reason - introduction to language and its ecosystem | Łukasz StrączyńskiGrand Parade Poland
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009cwarren
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboardsDenis Ristic
 

Similar a GDI Seattle - Intro to JavaScript Class 1 (20)

Fewd week5 slides
Fewd week5 slidesFewd week5 slides
Fewd week5 slides
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
 
Intro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXIntro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATX
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
JavaScript
JavaScriptJavaScript
JavaScript
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
Intro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATXIntro to Programming for Communicators - Hacks/Hackers ATX
Intro to Programming for Communicators - Hacks/Hackers ATX
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
Training on php by cyber security infotech (csi)
Training on  php by cyber security infotech (csi)Training on  php by cyber security infotech (csi)
Training on php by cyber security infotech (csi)
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Reason - introduction to language and its ecosystem | Łukasz Strączyński
Reason - introduction to language and its ecosystem | Łukasz StrączyńskiReason - introduction to language and its ecosystem | Łukasz Strączyński
Reason - introduction to language and its ecosystem | Łukasz Strączyński
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 

Más de Heather Rock

GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4Heather Rock
 
GDI Seattle Intro to HTML and CSS - Class 4
GDI Seattle Intro to HTML and CSS - Class 4GDI Seattle Intro to HTML and CSS - Class 4
GDI Seattle Intro to HTML and CSS - Class 4Heather Rock
 
GDI Seattle Intro to HTML and CSS - Class 3
GDI Seattle Intro to HTML and CSS - Class 3GDI Seattle Intro to HTML and CSS - Class 3
GDI Seattle Intro to HTML and CSS - Class 3Heather Rock
 
Intro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 SlidesIntro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 SlidesHeather Rock
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1Heather Rock
 
GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1Heather Rock
 

Más de Heather Rock (6)

GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4
 
GDI Seattle Intro to HTML and CSS - Class 4
GDI Seattle Intro to HTML and CSS - Class 4GDI Seattle Intro to HTML and CSS - Class 4
GDI Seattle Intro to HTML and CSS - Class 4
 
GDI Seattle Intro to HTML and CSS - Class 3
GDI Seattle Intro to HTML and CSS - Class 3GDI Seattle Intro to HTML and CSS - Class 3
GDI Seattle Intro to HTML and CSS - Class 3
 
Intro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 SlidesIntro to HTML and CSS - Class 2 Slides
Intro to HTML and CSS - Class 2 Slides
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
 
GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1
 

Último

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Último (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

GDI Seattle - Intro to JavaScript Class 1

  • 2.
  • 3. WELCOME! Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction. Some "rules" We are here for you! Every question is important Help each other Have fun
  • 4. WELCOME! Tell us about yourself. Who are you? What do you hope to get out of the class? What is your favorite dinosaur?
  • 5. TERMS Web design The process of planning, structuring and creating a website. Web development The process of programming dynamic web applications. (JavaScript goes here!) Front end The outwardly visible elements of a website or application. (JavaScript goes here, too!) Back end The inner workings and functionality of a website or application. (Recently, JavaScript has started to arrive here!)
  • 6. CLIENTS AND SERVERS How your computer accesses websites JavaScript is "client side" Your browser understands it!
  • 7. TOOLS Browser Browser Developer Tools Chrome, IE, and Safari Developer Tools Firebug for Firefox Opera Dragonfly Text Editors Eclipse JSDT - Windows and Mac Aptana - Windows and Mac Sublime Text - Windows and Mac Notepad++ - Windows
  • 8. HISTORY OF JAVASCRIPT Developed by Brendan Eich of Netscape in 1995 (in 10 days!) Originally called Mocha and then LiveScript Java -- Actually, JavaScript has nothing to do with the language Java. Java was just the cool kid in town at the time. Script -- Instructions that a computer can run one line at a time
  • 9. HISTORY OF JAVASCRIPT 1996 - Netscape 2 is released with JavaScript support 1997 - First standardized version of JavaScript 2005 - AJAX is first coined. AJAX is used to communicate with servers using JavaScript. 2006 - jQuery, a super-popular JavaScript library, debuts. 2010 - Node.js debuts. This provided a way for JavaScript to perform back end functions (although not the first). 2012 - The spec for JavaScript is "nearly" finished.
  • 10. WHAT DOES JAVASCRIPT DO? Primary use is controlling the browser, manipulating Web pages, and enhancing user interaction. All sorts of awesomeness, including this slideshow! Image Galleries and Lightboxes Games and all sorts of Google Doodles Interactions, like show/hide and accordians Retrieving data from other websites (through APIs)
  • 11. VALUES, TYPES, AND VARIABLES The fundamental building blocks of programming languages are values, types, and variables. A variable stores a value. The value is defined by a type.
  • 12. VALUES Any piece of information that a computer program can store or manipulate. For example: The sentence "Hello, world!" The number 3.14 A set of numbers [3.14, 6.09, 9.0805] A set of strings ["Welcome", "to", "JavaScript"]
  • 13. VARIABLES A storage location for a value used to perform computations. Declare a variable (give it a name) Initialize variable (give it a value and a type) Declare AND initialize at the same time! Change value of variable var bananas; bananas = 5; var bananas = 5; bananas = 4; //I ate a banana.
  • 14. COMMENTS You can write comments that only you, not the browser, reads // comment on one line /* comment on multiple lines */
  • 15. TYPES The definition of the kinds of data a computer program can store or manipulate. JavaScript infers the type based on the data. This is known as "loosely typed" in nerd speak.
  • 16. TYPES Primitives Number - well, a number! String - a collection of characters. Boolean - a true or false value. Array - a collection of values. null - no valid value or purposely empty. undefined - no value has been initialized or set yet. Objects Anything that isn't a primitive.
  • 17. DATA TYPES string -- a group of characters in quotes number -- (well, a number) boolean -- yes or no var fruit = "banana"; var pi = 3.14; var year = 2013; var bananaTally = 200; var skyIsBlue = true; var grassIsPink = false;
  • 18. DATA TYPES undefined -- no value yet null -- a purposely empty value (not the same as 0) var favoriteDinosaur; var myTigersName = null;
  • 19. NAMING RULES Begin with a letter, _, or $ Contain letters, numbers, _ and $ Names are case sensitive var hello; var _hello; var $hello; var hello2; var hello; var Hello; var heLLO;
  • 20. MATHEMATICAL EXPRESSIONS Symbol Meaning + Addition - Subtraction * Multiplication / Division % Modulus ++ Increment -- Decrement var bananas = 5; var oranges = 2; var fruit = bananas + oranges;
  • 21. STRING EXPRESSIONS var name = "Mitch"; var dinosaur = "Stegosaurus"; var sentence = "My dinosaur is a " + dinosaur + ". It's name is " + name + ".";
  • 22. INCLUDING JAVASCRIPT Inline - a script tag with code inside of it. External - a script tag that points to another file. <body> <script> </script> </body> var dinosaur = "Liopleurodon"; ... <body> <script src="external.js"></script> </body>
  • 23. LET'S DEVELOP IT Create a new HTML file Create a new JavaScript file (.js extension) and include it on the page. <html> <head> <title>My Site!</title> </head> <body> My site! </body> </html> <head> <title>My Site!</title> <script src="calculator.js"></script> </head>
  • 24. LET'S DEVELOP IT Life time supply calculator Ever wonder how much a lifetime supply of your favorite snack or drink is? Store your age in a variable Store your maximum age in a variable Store an estimated amount per day in a variable Calculate how many you would eat/drink for the rest of your life. Output the result into the page (see below) like so: "You will need NN to last you until your old age of NN" document.write(answer);
  • 25. LET'S ANSWER IT! var age = 26; var oldAge = 96; var perDay = 2; var days = (oldAge - age) * 365; var total = perDay * days; document.write("You will need $" + total + " to last you until the ripe old age of " + oldAge);
  • 26. COMPARISONS === Equality !== Inequality > Greater than >= Greater than or equal to < Less than <= Less than or equal to Don't confuse = (assign a value) with === (compare a value) var name = "Mitch"; document.write(name === "Mitch"); //true
  • 27. LOGIC && AND || OR ! NOT var bananas = 5; var oranges = 2; document.write(bananas > 3 && oranges > 3); //false document.write(bananas < 2 || oranges < 2); //false document.write(bananas !== oranges); //true
  • 28. THE IF STATEMENT JavaScript can run through code based on conditions if (condition here){ // statement to execute } var bananas = 1; if (bananas < 2){ document.write("You should buy more bananas!"); }
  • 29. IF/ELSE STATEMENT You can use else to perform an alternative action if the "if" fails var bananas = 5; if (bananas > 3){ document.write('Eat a banana!'); } else { document.write('Buy a banana!'); }
  • 30. IF/ELSE STATEMENT You can use else if to have multiple choices var age = 20; if (age >= 35) { document.write('You can vote AND hold any place in government!'); } else if (age >= 25) { document.write('You can vote AND run for the Senate!'); } else if (age >= 18) { document.write('You can vote!'); } else { document.write('You have no voice in government (yet)!'); }
  • 31. LET'S DEVELOP IT! 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!"
  • 32. LET'S ANSWER IT! var age = 26; var oldAge = 96; var perDay = 2; var days = (oldAge - age) * 356; var total = perDay * days; if(total > 40000){ document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); } else{ document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pr etty reasonable"); }
  • 33. FUNCTIONS Functions are re-usable collections of statements Declare a function Call the function function sayHi(){ document.write('Hi!'); } sayHi();
  • 34. ARGUMENTS Functions can take named values known as arguments. function sayHi(name){ console.log('Hi' + name + '!'); } sayHi('Mitch, the dinosaur'); sayHi('Harold, the hippo'); var mouseName = 'Pip, the mouse'; sayHi(mouseName);
  • 35. ARGUMENTS Functions can take MULTIPLE named arguments function addNumbers(num1, num2){ var result = num1 + num2; document.write(result); } addNumbers(5, 6); var number1 = 12; var number2 = 30; addNumbers(number1, number2);
  • 36. RETURN VALUES Functions can return a value to you (such as the result of addition). function addNumbers(num1, num2){ var result = num1 + num2; return result; //Anything after this line won't be read } var meaningOfLife = addNumbers(12, 30); document.write(meaningOfLife);
  • 37. VARIABLE SCOPE JavaScript have "function scope". That means the variables are only accessible in the function where they are defined. A variable with "local" scope: function addNumbers(num1, num2){ var result = num1 + num2; return result; } var meaningOfLife = addNumbers(12, 30); document.write(result); //This will show as undefined because the result variable only exists inside the addNumbers function.
  • 38. LET'S DEVELOP IT! Wrap the lifetime supply calculator in a function called calculate() Add a button to the html that calls the function when it is clicked <button type="button" onclick="calculate()"> Calculate life time supply </button>
  • 39. LET'S ANSWER IT! function calculate(){ var age = 26; var oldAge = 96; var perDay = 2; var days = (oldAge - age) * 356; var total = perDay * days; if(total > 40000) { document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); } else { document.write("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pr etty reasonable"); } }
  • 41. ?