SlideShare a Scribd company logo
Intro to JavaScript
April 2017
http://bit.ly/intro-js-la
© 2017 Thinkful, Inc. All Rights Reserved. 2
About us
We train developers and data
scientists through 1-on-1
mentorship and career prep
© 2017 Thinkful. All Rights Reserved. 3
About me
Zac Carter
Thinkful mentor
Software developer for 10 years
© 2017 Thinkful. All Rights Reserved. 4
About you
What brought you here?
Do you want to work better with developers?
Do you want to start working in tech?
Do you have an idea that you want to build?
Programming experience?
First lines of code will be written tonight?
Been self teaching for 1-3 months?
Been at this for 3+ months
© 2017 Thinkful. All Rights Reserved. 5
Today’s Goals
Context: Understand JavaScript’s role in modern
software development
Practice core JavaScript concepts
Get comfortable getting stuck
Aha! (Google is a developer’s best friend)
Pick your roadmap to learn from here
© 2017 Thinkful. All Rights Reserved. 6
Not Goals
Exhaustive course on all JavaScript fundamentals
Focus on concepts vs. syntax
HTML/CSS — check out tomorrow’s workshop. Same
place, same time
© 2017 Thinkful. All Rights Reserved. 7
Before We Review Anything…
Chrome Developer Tools provides an interactive
JavaScript console, where you can run and debug
code:
View -> Developer -> JavaScript console
Shortcut: option-command-J on a Mac; Ctrl + Shift +
J on a PC
Type the following command and hit enter:
alert(“Hello world!”);
Type: 2+2;
© 2017 Thinkful. All Rights Reserved. 8
Congrats!
You just typed your first two lines of code!
💯
© 2017 Thinkful. All Rights Reserved. 9
What is Programming?
Programming is writing instructions for a
computer to execute
© 2017 Thinkful. All Rights Reserved. 10
What is Programming?
Programming is problem-solving
© 2017 Thinkful. All Rights Reserved. 11
What is Programming?
Programming is a process:
1. Defining problems
2. Finding solutions to those problems
3. Implementing those solutions in a language your
computer can understand
© 2017 Thinkful. All Rights Reserved. 12
JavaScript: a brief history
Written by Brendan Eich in 1995 for use in Netscape
Initial version written in 10 days
Completely unrelated to Java, but maybe named after
it to draft off its popularity
Over 10 years, became default programming language
for browsers
© 2017 Thinkful. All Rights Reserved. 13
JavaScript: today
Has an exceptional community of developers, libraries
and frameworks.
A partial list: https://en.wikipedia.org/wiki/
List_of_JavaScript_libraries
Continues to evolve under guidance of Ecma
International, with input from top tech companies
Great place for beginners to start programming
© 2017 Thinkful. All Rights Reserved. 14
Most commonly used language on GitHub
Details here: http://githut.info/
JavaScript: today
© 2017 Thinkful. All Rights Reserved. 15
Why learn JavaScript
Most popular language means job opportunities
Good starting place to see if coding is for you
Coding as a medium of expression
© 2017 Thinkful. All Rights Reserved. 16
How the web works
You type a URL: facebook.com (your computer is the
client)
The browser communicates with the DNS server to find
the IP address
The browser sends an HTTP request to the server asking
for specific files
The browser receives those files and renders them as a
website
© 2017 Thinkful. All Rights Reserved. 17
Client / Server
Front-end developer Back-end developer
Client Server
© 2017 Thinkful. All Rights Reserved. 18
What are we learning?
100% of client side code is written in JavaScript
You can also use JavaScript to write server-side
code (thanks to Node.js)
Backend web applications have been written in
many languages (incl. Java, Ruby, PHP,
Python…)
© 2017 Thinkful. All Rights Reserved. 19
What we’ll cover
Variables
Data types
Functions
Strings + Functions: drills
Numbers + Functions: drills
© 2017 Thinkful. All Rights Reserved. 20
JavaScript variables
A variable is a name that is attached to a value
Gives us a shorthand way to refer to values created
elsewhere in a program
Why do we use variables? To manage state in a
program
Example: https://jsbin.com/ciqade/1/edit
© 2017 Thinkful. All Rights Reserved. 21
JavaScript variables
Declaring a variable
var firstVariable;
Assigning a value to it
firstVariable = 6;
Retrieving that value
alert(firstVariable);
Causes a popup to appear with the alert message “6"
Example (uncheck “Auto-run with JS”):
https://jsbin.com/xamipa/edit?js,output
© 2017 Thinkful. All Rights Reserved. 22
Variable naming
Choose meaningful words
loggedInUsers is better than x
Use camelCasing
First word starts with lower case; subsequent words
start with upper case
Must start with a letter
© 2017 Thinkful. All Rights Reserved. 23
JavaScript Data Types
String
Number
Boolean
Null (in appendix)
Undefined (in appendix)
Object (in appendix)
© 2017 Thinkful. All Rights Reserved. 24
Strings
Strings are created with opening and closing quotes
(either single or double, but both must be same kind):
var foo = 'bar';
var bar = "foo";
© 2017 Thinkful. All Rights Reserved. 25
Strings are useful when…
You’re building an application that involves users
interacting with text… so, almost all the time.
When you post a Facebook Status, your status is
stored as a String
When you read tweets, those tweets are stored as
strings
© 2017 Thinkful. All Rights Reserved. 26
Strings: Oh the things you can do!
© 2017 Thinkful. All Rights Reserved. 27
Concatenating strings
JavaScript lets us use the + operator to concatenate —
which just means combine — two strings into one:
var innerText = 'The quick brown fox.…’;
var element = '<p>' + innerText + '</p>';
console.log(element)
// => '<p>The quick brown fox…</p>’
© 2017 Thinkful. All Rights Reserved. 28
Strings drill
Using the JavaScript console
Store your first name in one variable and then your
last name in a second variable
Concatenate the two to print your full name
© 2017 Thinkful. All Rights Reserved. 29
Numbers
The number type in JavaScript is used to represent all
numbers:
Integer values (whole numbers like 1, 2, 3,
10000000…)
Floating point decimal numbers (1.234999). These
are stored differently than integers and occasionally
you’ll run into quirks doing math with decimals.
© 2017 Thinkful. All Rights Reserved. 30
Using Numbers
© 2017 Thinkful. All Rights Reserved. 31
Numbers drill
Using the JavaScript console
Store two numbers in two different variables named
firstNumber and secondNumber
Add the two numbers
Multiply them
© 2017 Thinkful. All Rights Reserved. 32
Booleans
Booleans signify true or false
var loggedIn = true;
if (loggedIn = true) {
redirectToDashboard();
}
© 2017 Thinkful. All Rights Reserved. 33
Functions
A function describes a repeatable process or behavior.
JavaScript has some built-in functions, and in writing a
complex program, you’ll write many, many functions
that handle sub-sets of the behavior you’re creating.
type in the console:
alert(‘Hello from JavaScript land’);
© 2017 Thinkful. All Rights Reserved. 34
Functions
Go to JSBin.com
Declare and execute a function:
function myFunction() {
console.log("myFunction");
}
myFunction();
Write a function that logs your name
Write a function that adds two numbers
© 2017 Thinkful. All Rights Reserved. 35
Functions: parameter and return
We sometimes pass a parameter and return a value:
function hello(name) {
return 'Hello ' + name + '!';
}
console.log(hello('TJ')); // => "Hello TJ!"
In JSbin, write a function that adds two numbers that
are passed to the function as parameters and returns
the sum.
© 2017 Thinkful. All Rights Reserved. 36
Comparing strings
Use the === operator to compare two strings to see if
they're identical.
var foo = 'foo';
var foo1 = 'foo';
var bar = 'bar';
foo === foo1 true
foo === bar false
© 2017 Thinkful. All Rights Reserved. 37
Strings methods
JavaScript provides a number of built-in methods that
you can use on strings:
var foo = 'foo bar foo bar';
foo.length 15
foo.charAt(0) "f"
foo.slice(4) "bar foo bar"
foo.slice(4, 7) "bar"
foo.split(" ") ["foo", "bar", "foo", "bar"]
foo.toUpperCase() "FOO BAR FOO BAR"
foo.replace('foo', ‘bar') 'bar bar foo bar'
© 2017 Thinkful. All Rights Reserved. 38
Strings drill 1:
Fill in the function `wisePerson` that takes two arguments:
wiseType and whatToSay.
This function takes a block of text and presents it as a
quote from the wise person. wiseType is the person the
quote will be attributed to, and whatToSay is what the
wise person will be quoted as saying.
When called like this: wisePerson('goat', "Gibbida
abbida abbida") should return the string 'A wise
goat once said: "Gibbida abbida abbida".'
https://jsbin.com/riraqi/2/edit
© 2017 Thinkful. All Rights Reserved. 39
Strings drill 1: Tips
Break the problem down into detailed steps
Write Pseudocode, or programming in English.
Describe what should happen in English line by line,
and then translate that into code.
© 2017 Thinkful. All Rights Reserved. 40
Strings drill 2:
Create a function that takes a single argument:
whatToShout. The function should return an all caps
version of the string it's given, with three exclamation
points !!! at the end.
Given the text shouter('as you can hear i am
whispering'), the function should return "AS YOU
CAN HEAR I AM WHISPERING!!!".
https://jsbin.com/fijetec/1/edit
© 2017 Thinkful. All Rights Reserved. 41
Strings drill 2: Tips
Break the problem down into precise steps written in
Pseudocode
Don’t know how to turn an English description
(“Capitalize “). Try googling it – you’re probably not the
first programmer who needed it.
© 2017 Thinkful. All Rights Reserved. 42
Numbers drill
Create a function called computeArea that takes two
arguments: width and height. It returns the area of a
square whose width is width and height is height. So
computeArea(2, 2) would return 4, and
computeArea(3, 5) would return 15.
https://jsbin.com/cuhuded/2/edit
© 2017 Thinkful. All Rights Reserved. 43
Topics we’re not covering
Application logic
Loops and Arrays
Working with objects
More practice writing useful functions / breaking down
large problems into small, manageable ones
© 2017 Thinkful. All Rights Reserved. 44
More about Thinkful
You’ll learn concepts, practice with drills, and build capstone
projects for your own portfolio — all guided by a personal mentor
© 2017 Thinkful. All Rights Reserved. 45
Mentors have, on average, 10+ years of experience
Our mentors
© 2017 Thinkful. All Rights Reserved. 46
Job Titles after GraduationMonths until Employed
Our results
© 2017 Thinkful. All Rights Reserved. 47
Try the program for two
weeks, includes six mentor
sessions - $50
Learn HTML/CSS/JavaScript
Option to continue onto web
development bootcamp
Come talk to me if you’re
interested (or email me at
noel@thinkful.com)
Try us out!
© 2017 Thinkful. All Rights Reserved. 48
How did everyone find out about tonight’s event?
Meetup, Eventbrite, Facebook, etc.
Would you have traveled to Santa Monica for tonight’s
workshop? 🚗 🚙 🚕
Quick poll
Thank you!
Email me with questions or suggestions:
noel@thinkful.com
April 2017

More Related Content

Similar to Intro to JavaScript - Thinkful LA (20)

PDF
Thinkful - Intro to JavaScript
TJ Stalcup
 
PPTX
JS digest. Mid-Summer 2017
ElifTech
 
PPT
Java script
Kumar
 
PDF
Ijsphx927
Thinkful
 
PDF
Intro to javascript (6:27)
David Coulter
 
PDF
Intro javascript build a scraper (3:22)
Thinkful
 
PDF
Javascript pdf for beginners easy levell
SakshamGupta957136
 
PDF
An Introduction to TypeScript
WrapPixel
 
XLS
Lt web quiz_answer
0983676660
 
PPTX
Java 8 - Gateway Drug or End of Line?
Garth Gilmour
 
PDF
Intro to JavaScript
Aaron Lamphere
 
PPTX
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
PDF
Type script vs javascript come face to face in battleground
Katy Slemon
 
PDF
Intro to JavaScript - Thinkful LA, June 2017
Thinkful
 
PDF
Maintainable Javascript carsonified
Christian Heilmann
 
PPTX
React js basics
Maulik Shah
 
PDF
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
PDF
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
Thinkful
 
PDF
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Codemotion
 
PDF
Introjs1.9.18tf
Thinkful
 
Thinkful - Intro to JavaScript
TJ Stalcup
 
JS digest. Mid-Summer 2017
ElifTech
 
Java script
Kumar
 
Ijsphx927
Thinkful
 
Intro to javascript (6:27)
David Coulter
 
Intro javascript build a scraper (3:22)
Thinkful
 
Javascript pdf for beginners easy levell
SakshamGupta957136
 
An Introduction to TypeScript
WrapPixel
 
Lt web quiz_answer
0983676660
 
Java 8 - Gateway Drug or End of Line?
Garth Gilmour
 
Intro to JavaScript
Aaron Lamphere
 
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
Type script vs javascript come face to face in battleground
Katy Slemon
 
Intro to JavaScript - Thinkful LA, June 2017
Thinkful
 
Maintainable Javascript carsonified
Christian Heilmann
 
React js basics
Maulik Shah
 
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
Thinkful
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Codemotion
 
Introjs1.9.18tf
Thinkful
 

More from Thinkful (20)

PDF
893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-25-46-115-141-308-324-370
Thinkful
 
PDF
LA 1/31/18 Intro to JavaScript: Fundamentals
Thinkful
 
PDF
LA 1/31/18 Intro to JavaScript: Fundamentals
Thinkful
 
PDF
Itjsf129
Thinkful
 
PDF
Twit botsd1.30.18
Thinkful
 
PDF
Build your-own-instagram-filters-with-javascript-202-335 (1)
Thinkful
 
PDF
Baggwjs124
Thinkful
 
PDF
Become a Data Scientist: A Thinkful Info Session
Thinkful
 
PDF
Vpet sd-1.25.18
Thinkful
 
PDF
LA 1/18/18 Become A Web Developer: A Thinkful Info Session
Thinkful
 
PDF
How to Choose a Programming Language
Thinkful
 
PDF
Batbwjs117
Thinkful
 
PDF
1/16/18 Intro to JS Workshop
Thinkful
 
PDF
LA 1/16/18 Intro to Javascript: Fundamentals
Thinkful
 
PDF
(LA 1/16/18) Intro to JavaScript: Fundamentals
Thinkful
 
PDF
Websitesd1.15.17.
Thinkful
 
PDF
Bavpwjs110
Thinkful
 
PDF
Byowwhc110
Thinkful
 
PDF
Getting started-jan-9-2018
Thinkful
 
PDF
Proglangauage1.10.18
Thinkful
 
893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-25-46-115-141-308-324-370
Thinkful
 
LA 1/31/18 Intro to JavaScript: Fundamentals
Thinkful
 
LA 1/31/18 Intro to JavaScript: Fundamentals
Thinkful
 
Itjsf129
Thinkful
 
Twit botsd1.30.18
Thinkful
 
Build your-own-instagram-filters-with-javascript-202-335 (1)
Thinkful
 
Baggwjs124
Thinkful
 
Become a Data Scientist: A Thinkful Info Session
Thinkful
 
Vpet sd-1.25.18
Thinkful
 
LA 1/18/18 Become A Web Developer: A Thinkful Info Session
Thinkful
 
How to Choose a Programming Language
Thinkful
 
Batbwjs117
Thinkful
 
1/16/18 Intro to JS Workshop
Thinkful
 
LA 1/16/18 Intro to Javascript: Fundamentals
Thinkful
 
(LA 1/16/18) Intro to JavaScript: Fundamentals
Thinkful
 
Websitesd1.15.17.
Thinkful
 
Bavpwjs110
Thinkful
 
Byowwhc110
Thinkful
 
Getting started-jan-9-2018
Thinkful
 
Proglangauage1.10.18
Thinkful
 
Ad

Recently uploaded (20)

PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
community health nursing question paper 2.pdf
Prince kumar
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Ad

Intro to JavaScript - Thinkful LA

  • 1. Intro to JavaScript April 2017 http://bit.ly/intro-js-la
  • 2. © 2017 Thinkful, Inc. All Rights Reserved. 2 About us We train developers and data scientists through 1-on-1 mentorship and career prep
  • 3. © 2017 Thinkful. All Rights Reserved. 3 About me Zac Carter Thinkful mentor Software developer for 10 years
  • 4. © 2017 Thinkful. All Rights Reserved. 4 About you What brought you here? Do you want to work better with developers? Do you want to start working in tech? Do you have an idea that you want to build? Programming experience? First lines of code will be written tonight? Been self teaching for 1-3 months? Been at this for 3+ months
  • 5. © 2017 Thinkful. All Rights Reserved. 5 Today’s Goals Context: Understand JavaScript’s role in modern software development Practice core JavaScript concepts Get comfortable getting stuck Aha! (Google is a developer’s best friend) Pick your roadmap to learn from here
  • 6. © 2017 Thinkful. All Rights Reserved. 6 Not Goals Exhaustive course on all JavaScript fundamentals Focus on concepts vs. syntax HTML/CSS — check out tomorrow’s workshop. Same place, same time
  • 7. © 2017 Thinkful. All Rights Reserved. 7 Before We Review Anything… Chrome Developer Tools provides an interactive JavaScript console, where you can run and debug code: View -> Developer -> JavaScript console Shortcut: option-command-J on a Mac; Ctrl + Shift + J on a PC Type the following command and hit enter: alert(“Hello world!”); Type: 2+2;
  • 8. © 2017 Thinkful. All Rights Reserved. 8 Congrats! You just typed your first two lines of code! 💯
  • 9. © 2017 Thinkful. All Rights Reserved. 9 What is Programming? Programming is writing instructions for a computer to execute
  • 10. © 2017 Thinkful. All Rights Reserved. 10 What is Programming? Programming is problem-solving
  • 11. © 2017 Thinkful. All Rights Reserved. 11 What is Programming? Programming is a process: 1. Defining problems 2. Finding solutions to those problems 3. Implementing those solutions in a language your computer can understand
  • 12. © 2017 Thinkful. All Rights Reserved. 12 JavaScript: a brief history Written by Brendan Eich in 1995 for use in Netscape Initial version written in 10 days Completely unrelated to Java, but maybe named after it to draft off its popularity Over 10 years, became default programming language for browsers
  • 13. © 2017 Thinkful. All Rights Reserved. 13 JavaScript: today Has an exceptional community of developers, libraries and frameworks. A partial list: https://en.wikipedia.org/wiki/ List_of_JavaScript_libraries Continues to evolve under guidance of Ecma International, with input from top tech companies Great place for beginners to start programming
  • 14. © 2017 Thinkful. All Rights Reserved. 14 Most commonly used language on GitHub Details here: http://githut.info/ JavaScript: today
  • 15. © 2017 Thinkful. All Rights Reserved. 15 Why learn JavaScript Most popular language means job opportunities Good starting place to see if coding is for you Coding as a medium of expression
  • 16. © 2017 Thinkful. All Rights Reserved. 16 How the web works You type a URL: facebook.com (your computer is the client) The browser communicates with the DNS server to find the IP address The browser sends an HTTP request to the server asking for specific files The browser receives those files and renders them as a website
  • 17. © 2017 Thinkful. All Rights Reserved. 17 Client / Server Front-end developer Back-end developer Client Server
  • 18. © 2017 Thinkful. All Rights Reserved. 18 What are we learning? 100% of client side code is written in JavaScript You can also use JavaScript to write server-side code (thanks to Node.js) Backend web applications have been written in many languages (incl. Java, Ruby, PHP, Python…)
  • 19. © 2017 Thinkful. All Rights Reserved. 19 What we’ll cover Variables Data types Functions Strings + Functions: drills Numbers + Functions: drills
  • 20. © 2017 Thinkful. All Rights Reserved. 20 JavaScript variables A variable is a name that is attached to a value Gives us a shorthand way to refer to values created elsewhere in a program Why do we use variables? To manage state in a program Example: https://jsbin.com/ciqade/1/edit
  • 21. © 2017 Thinkful. All Rights Reserved. 21 JavaScript variables Declaring a variable var firstVariable; Assigning a value to it firstVariable = 6; Retrieving that value alert(firstVariable); Causes a popup to appear with the alert message “6" Example (uncheck “Auto-run with JS”): https://jsbin.com/xamipa/edit?js,output
  • 22. © 2017 Thinkful. All Rights Reserved. 22 Variable naming Choose meaningful words loggedInUsers is better than x Use camelCasing First word starts with lower case; subsequent words start with upper case Must start with a letter
  • 23. © 2017 Thinkful. All Rights Reserved. 23 JavaScript Data Types String Number Boolean Null (in appendix) Undefined (in appendix) Object (in appendix)
  • 24. © 2017 Thinkful. All Rights Reserved. 24 Strings Strings are created with opening and closing quotes (either single or double, but both must be same kind): var foo = 'bar'; var bar = "foo";
  • 25. © 2017 Thinkful. All Rights Reserved. 25 Strings are useful when… You’re building an application that involves users interacting with text… so, almost all the time. When you post a Facebook Status, your status is stored as a String When you read tweets, those tweets are stored as strings
  • 26. © 2017 Thinkful. All Rights Reserved. 26 Strings: Oh the things you can do!
  • 27. © 2017 Thinkful. All Rights Reserved. 27 Concatenating strings JavaScript lets us use the + operator to concatenate — which just means combine — two strings into one: var innerText = 'The quick brown fox.…’; var element = '<p>' + innerText + '</p>'; console.log(element) // => '<p>The quick brown fox…</p>’
  • 28. © 2017 Thinkful. All Rights Reserved. 28 Strings drill Using the JavaScript console Store your first name in one variable and then your last name in a second variable Concatenate the two to print your full name
  • 29. © 2017 Thinkful. All Rights Reserved. 29 Numbers The number type in JavaScript is used to represent all numbers: Integer values (whole numbers like 1, 2, 3, 10000000…) Floating point decimal numbers (1.234999). These are stored differently than integers and occasionally you’ll run into quirks doing math with decimals.
  • 30. © 2017 Thinkful. All Rights Reserved. 30 Using Numbers
  • 31. © 2017 Thinkful. All Rights Reserved. 31 Numbers drill Using the JavaScript console Store two numbers in two different variables named firstNumber and secondNumber Add the two numbers Multiply them
  • 32. © 2017 Thinkful. All Rights Reserved. 32 Booleans Booleans signify true or false var loggedIn = true; if (loggedIn = true) { redirectToDashboard(); }
  • 33. © 2017 Thinkful. All Rights Reserved. 33 Functions A function describes a repeatable process or behavior. JavaScript has some built-in functions, and in writing a complex program, you’ll write many, many functions that handle sub-sets of the behavior you’re creating. type in the console: alert(‘Hello from JavaScript land’);
  • 34. © 2017 Thinkful. All Rights Reserved. 34 Functions Go to JSBin.com Declare and execute a function: function myFunction() { console.log("myFunction"); } myFunction(); Write a function that logs your name Write a function that adds two numbers
  • 35. © 2017 Thinkful. All Rights Reserved. 35 Functions: parameter and return We sometimes pass a parameter and return a value: function hello(name) { return 'Hello ' + name + '!'; } console.log(hello('TJ')); // => "Hello TJ!" In JSbin, write a function that adds two numbers that are passed to the function as parameters and returns the sum.
  • 36. © 2017 Thinkful. All Rights Reserved. 36 Comparing strings Use the === operator to compare two strings to see if they're identical. var foo = 'foo'; var foo1 = 'foo'; var bar = 'bar'; foo === foo1 true foo === bar false
  • 37. © 2017 Thinkful. All Rights Reserved. 37 Strings methods JavaScript provides a number of built-in methods that you can use on strings: var foo = 'foo bar foo bar'; foo.length 15 foo.charAt(0) "f" foo.slice(4) "bar foo bar" foo.slice(4, 7) "bar" foo.split(" ") ["foo", "bar", "foo", "bar"] foo.toUpperCase() "FOO BAR FOO BAR" foo.replace('foo', ‘bar') 'bar bar foo bar'
  • 38. © 2017 Thinkful. All Rights Reserved. 38 Strings drill 1: Fill in the function `wisePerson` that takes two arguments: wiseType and whatToSay. This function takes a block of text and presents it as a quote from the wise person. wiseType is the person the quote will be attributed to, and whatToSay is what the wise person will be quoted as saying. When called like this: wisePerson('goat', "Gibbida abbida abbida") should return the string 'A wise goat once said: "Gibbida abbida abbida".' https://jsbin.com/riraqi/2/edit
  • 39. © 2017 Thinkful. All Rights Reserved. 39 Strings drill 1: Tips Break the problem down into detailed steps Write Pseudocode, or programming in English. Describe what should happen in English line by line, and then translate that into code.
  • 40. © 2017 Thinkful. All Rights Reserved. 40 Strings drill 2: Create a function that takes a single argument: whatToShout. The function should return an all caps version of the string it's given, with three exclamation points !!! at the end. Given the text shouter('as you can hear i am whispering'), the function should return "AS YOU CAN HEAR I AM WHISPERING!!!". https://jsbin.com/fijetec/1/edit
  • 41. © 2017 Thinkful. All Rights Reserved. 41 Strings drill 2: Tips Break the problem down into precise steps written in Pseudocode Don’t know how to turn an English description (“Capitalize “). Try googling it – you’re probably not the first programmer who needed it.
  • 42. © 2017 Thinkful. All Rights Reserved. 42 Numbers drill Create a function called computeArea that takes two arguments: width and height. It returns the area of a square whose width is width and height is height. So computeArea(2, 2) would return 4, and computeArea(3, 5) would return 15. https://jsbin.com/cuhuded/2/edit
  • 43. © 2017 Thinkful. All Rights Reserved. 43 Topics we’re not covering Application logic Loops and Arrays Working with objects More practice writing useful functions / breaking down large problems into small, manageable ones
  • 44. © 2017 Thinkful. All Rights Reserved. 44 More about Thinkful You’ll learn concepts, practice with drills, and build capstone projects for your own portfolio — all guided by a personal mentor
  • 45. © 2017 Thinkful. All Rights Reserved. 45 Mentors have, on average, 10+ years of experience Our mentors
  • 46. © 2017 Thinkful. All Rights Reserved. 46 Job Titles after GraduationMonths until Employed Our results
  • 47. © 2017 Thinkful. All Rights Reserved. 47 Try the program for two weeks, includes six mentor sessions - $50 Learn HTML/CSS/JavaScript Option to continue onto web development bootcamp Come talk to me if you’re interested (or email me at [email protected]) Try us out!
  • 48. © 2017 Thinkful. All Rights Reserved. 48 How did everyone find out about tonight’s event? Meetup, Eventbrite, Facebook, etc. Would you have traveled to Santa Monica for tonight’s workshop? 🚗 🚙 🚕 Quick poll
  • 49. Thank you! Email me with questions or suggestions: [email protected] April 2017