SlideShare a Scribd company logo
1 of 40
LESSON TWO
Front End Development
HTML
[review]
ANATOMY OF A TAG

(1) Opening & closing =>
<tag_name attr_1=”val_1”   [...]   attr_n=”val_n” >

         [...]

</tag_name>

Ex:
ANATOMY OF A TAG


(2) “Self-closing” =>
<tag_name attr_1=”val_1” [...] attr_n=”val_n”   />

Ex:
15 TAGS YOU MUST KNOW
(1) div

(2) a

(3) p

(4) img (self-closing)

(5) ol + li

(6) ul + li

(7) form + input + select

(8) br (self-closing)
15 TAGS YOU MUST KNOW

(9) span

(10) h1...h6

(11) html, head, body

(12) meta

(13) script

(14) style

(15) link
CSS
[review]
ANATOMY OF A SELECTOR

(1) Select by tag name
tag_name {

      style_1: value_1;
      [ ... ]
      style_n: value_n;
}

Ex:

p {

      color: #000;
      font-size: 12px;
}
ANATOMY OF A SELECTOR
(2) Select by class
.class {

      style_1: value_1;
      [ ... ]
      style_n: value_n;
}

Ex:

.highlight {

      font-weight: bold;
      font-size: 14px;
}
ANATOMY OF A SELECTOR

(3) Select by id
#id {

      style_1: value_1;
      [ ... ]
      style_n: value_n;
}

Ex:

#footer p {

      font-size: 9px;
}
PRECEDENCE

Q: When two selectors conflict, who wins?
A: The more “specific” selector.
•   Specificity determined by tallying the ids, classes, and tags
    comprising a selector

•   Inline >> id >> classes >> tag

•   Hierarchy is classified in the sense that 1 id beats 1,000 classes, 1
    class beats 1,000 tags, and inline trumps all

•   In case of a tie, the one defined “last” wins

•   Details here
CSS
[laying out your pages]
TWO CAVEATS


(1) This stuff is confusing


(2) Muddling through & experimentation are
okay!
•   We’re experts at this technique

•   Ours are not necessarily best practices
DEFAULTS


Differ across browsers => use a reset
  •   E.g., Blueprint CSS

  •   Provides you with a common starting point

Resets create default settings like:
  •   Align everything to the left

  •   Divs are “block level” elements

  •   No padding, no margin, no border, anywhere
SPACING & THE BOX MODEL
Think of HTML elements as boxes. Each box has (1) content, (2) padding
(optionally), (3) a border (optionally), and (4) margin (optionally)
BLOCK LEVEL VS. INLINE

Block level => intuitively, “blocks” of
content
•   Starts a new line (before and after)

•   Has a width

•   By default, spans the entire width of their containing element

•   CSS: “display: block”

•   Block level elements: div, h1 - h6, p, ul, ol, li, table, tr, td, th,
    blockquote
BLOCK LEVEL VS. INLINE


Inline => intuitively, displayed “inline”
•   Does NOT start a new line (before or after)

•   Does NOT have a width

•   Takes up only as much space as necessary

•   CSS: “display: inline”

•   Inline elements: i, b, a, em, strong, q
FLOAT & CLEAR


Float => floats an element to ‘left’ or ‘right’
•   Values: inherit, left, right, none

•   Floats to left or right of container element.

•   Content flows around to side, down and around

•   Ignores display ‘block’ or display ‘in-line’

•   Needs a defined width
FLOAT & CLEAR


               China has a carefully thought out
               and strategic plan to take over
               America We took the Bible and prayer
               out of public schools, and now were
               having weekly shootings practically.
               The American Left hates Christendom.
They hate Western civilization. I am a firm believer
in intelligent design as a matter of faith and
intellect. I believe intelligent design should be
presented in schools alongside the theories of
evolution. The exact phrase separation of Church and
State came out of Adolph Hitlers mouth, thats where it
comes from.
FLOAT & CLEAR



Clear => allow elements to float on sides?
•   Values: inherit, left, right, none

•   If set, does not render until “beneath” previous floating object

•   Can be applied to any object, regardless of it’s float

•   Does not naturally inherit down to children
FLOAT & CLEAR


                        same text, with ‘clear:left’


China has a carefully thought out and strategic plan
to take over America We took the Bible and prayer out
of public schools, and now were having weekly
shootings practically. The American Left hates
Christendom. They hate Western civilization. I am a
firm believer in intelligent design as a matter of
faith and intellect. I believe intelligent design
should be presented in schools alongside the theories
of evolution. The exact phrase separation of Church
and State came out of Adolph Hitlers mouth, thats
where it comes from.
Fixed and Absolute Positioning


Fixed => fixed with respect to the
“viewport” (i.e. what you see)
Absolute => fixed with respect to its nearest
ancestor that has declared “position:
relative”
JAVASCRIPT
[language basics]
DATA TYPES




        Javascript
      [language basics]
BASIC SYNTAX




Lines end with a semicolon
Group code with braces: { }
DATA TYPES
    Must interact with Javascript on its own terms
    It divides the world into six fundamental
    categories:
•   (1) Numbers

•   (2) Strings

•   (3) Booleans

•   (4) Functions

•   (5) Objects

•   (6) Undefined
(1) NUMBERS & ARITHMETIC


Can do all your basic arithmetic in Javascript
Order of operations matters (as always)
   •   Use parentheses for clarity

Integer vs. floating point
   •   “Floating point” => decimal
(2) STRINGS



Intuitively, a string is text
   •   Must be enclosed in single or double quotes, e.g. “this is a
       string” and ‘so is this’
(3) BOOLEANS




Boolean is a fancy way of saying true or false
BUZZZZWORD



DRY => “Don’t Repeat Yourself”
•   Staying DRY is about efficiency and clarity

•   If you find yourself typing the same thing over and over, ask yourself
    whether you can dry off

•   Ways you’ll learn to stay dry: (1) variables, (2) functions, (3)
    modules
VARIABLES


Store data with an “arbitrary” name
One of the most fundamental coding
concepts
var name;
name = 17;
console.log(name); // => 17
ASSIGNMENT VS. EQUALITY

“== != =” -Charlie Croom
=
    •   This is a command

    •   Sets the value of a variable

== and ===
    •   These are tests

    •   Return Booleans (true or false)
(4) FUNCTIONS


The ultimate DRY

Encapsulate common functionality
function name( arg_1, ... arg_n ) {

    [ FUNCTION BODY ]

}
(4) FUNCTIONS


Can “return a value”
•   Return undefined if no return value specified


function name( arg_1, ... arg_n ) {
  var x;
  [ DO SOME STUFF WITH x ]
  return x;
}
CONTROL FLOW

if
     •   Execute some code if a certain condition pertains

for
     •   Execute some code a “definite” number of times

while
     •   Execute some code an “indefinite” number of times
CONTROL FLOW: if

if ( condition_1) {
    [ DO SOME STUFF ]
} else if ( condition_2 ) {
    [ DO SOME OTHER STUFF ]
} else {
    [ DO DEFAULT STUFF ]
}
CONTROL FLOW: for



for ( var i = 0; i < 10; i++ ) {
    [ DO SOME STUFF ]
}
// That stuff will happen 10 times
CONTROL FLOW: while


while ( [SOME CONDITION OBTAINS] ) {
    [ KEEP DOING STUFF ]
}
// That stuff will keep happening until
// the condition is false
QUESTIONS?
contact will_and_bay@hackyale.com

More Related Content

Similar to Week2

Similar to Week2 (20)

Excel 2016 VBA PPT Slide Deck - For Basic to Adavance VBA Learning
Excel 2016 VBA PPT Slide Deck - For Basic to Adavance VBA LearningExcel 2016 VBA PPT Slide Deck - For Basic to Adavance VBA Learning
Excel 2016 VBA PPT Slide Deck - For Basic to Adavance VBA Learning
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
Bill howe 6_machinelearning_1
Bill howe 6_machinelearning_1Bill howe 6_machinelearning_1
Bill howe 6_machinelearning_1
 
Hardcore CSS
Hardcore CSSHardcore CSS
Hardcore CSS
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Introduction to c ++ part -1
Introduction to c ++   part -1Introduction to c ++   part -1
Introduction to c ++ part -1
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
Week3
Week3Week3
Week3
 
Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
Object concepts
Object conceptsObject concepts
Object concepts
 
A quick python_tour
A quick python_tourA quick python_tour
A quick python_tour
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
Demystifying Shapeless
Demystifying Shapeless Demystifying Shapeless
Demystifying Shapeless
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
C++ nothrow movable types
C++ nothrow movable typesC++ nothrow movable types
C++ nothrow movable types
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like Pythonista
 
Object concepts
Object conceptsObject concepts
Object concepts
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 

Week2

  • 1.
  • 2. LESSON TWO Front End Development
  • 4. ANATOMY OF A TAG (1) Opening & closing => <tag_name attr_1=”val_1” [...] attr_n=”val_n” > [...] </tag_name> Ex:
  • 5. ANATOMY OF A TAG (2) “Self-closing” => <tag_name attr_1=”val_1” [...] attr_n=”val_n” /> Ex:
  • 6. 15 TAGS YOU MUST KNOW (1) div (2) a (3) p (4) img (self-closing) (5) ol + li (6) ul + li (7) form + input + select (8) br (self-closing)
  • 7. 15 TAGS YOU MUST KNOW (9) span (10) h1...h6 (11) html, head, body (12) meta (13) script (14) style (15) link
  • 9. ANATOMY OF A SELECTOR (1) Select by tag name tag_name { style_1: value_1; [ ... ] style_n: value_n; } Ex: p { color: #000; font-size: 12px; }
  • 10. ANATOMY OF A SELECTOR (2) Select by class .class { style_1: value_1; [ ... ] style_n: value_n; } Ex: .highlight { font-weight: bold; font-size: 14px; }
  • 11. ANATOMY OF A SELECTOR (3) Select by id #id { style_1: value_1; [ ... ] style_n: value_n; } Ex: #footer p { font-size: 9px; }
  • 12. PRECEDENCE Q: When two selectors conflict, who wins? A: The more “specific” selector. • Specificity determined by tallying the ids, classes, and tags comprising a selector • Inline >> id >> classes >> tag • Hierarchy is classified in the sense that 1 id beats 1,000 classes, 1 class beats 1,000 tags, and inline trumps all • In case of a tie, the one defined “last” wins • Details here
  • 14. TWO CAVEATS (1) This stuff is confusing (2) Muddling through & experimentation are okay! • We’re experts at this technique • Ours are not necessarily best practices
  • 15. DEFAULTS Differ across browsers => use a reset • E.g., Blueprint CSS • Provides you with a common starting point Resets create default settings like: • Align everything to the left • Divs are “block level” elements • No padding, no margin, no border, anywhere
  • 16. SPACING & THE BOX MODEL Think of HTML elements as boxes. Each box has (1) content, (2) padding (optionally), (3) a border (optionally), and (4) margin (optionally)
  • 17. BLOCK LEVEL VS. INLINE Block level => intuitively, “blocks” of content • Starts a new line (before and after) • Has a width • By default, spans the entire width of their containing element • CSS: “display: block” • Block level elements: div, h1 - h6, p, ul, ol, li, table, tr, td, th, blockquote
  • 18. BLOCK LEVEL VS. INLINE Inline => intuitively, displayed “inline” • Does NOT start a new line (before or after) • Does NOT have a width • Takes up only as much space as necessary • CSS: “display: inline” • Inline elements: i, b, a, em, strong, q
  • 19. FLOAT & CLEAR Float => floats an element to ‘left’ or ‘right’ • Values: inherit, left, right, none • Floats to left or right of container element. • Content flows around to side, down and around • Ignores display ‘block’ or display ‘in-line’ • Needs a defined width
  • 20. FLOAT & CLEAR China has a carefully thought out and strategic plan to take over America We took the Bible and prayer out of public schools, and now were having weekly shootings practically. The American Left hates Christendom. They hate Western civilization. I am a firm believer in intelligent design as a matter of faith and intellect. I believe intelligent design should be presented in schools alongside the theories of evolution. The exact phrase separation of Church and State came out of Adolph Hitlers mouth, thats where it comes from.
  • 21. FLOAT & CLEAR Clear => allow elements to float on sides? • Values: inherit, left, right, none • If set, does not render until “beneath” previous floating object • Can be applied to any object, regardless of it’s float • Does not naturally inherit down to children
  • 22. FLOAT & CLEAR same text, with ‘clear:left’ China has a carefully thought out and strategic plan to take over America We took the Bible and prayer out of public schools, and now were having weekly shootings practically. The American Left hates Christendom. They hate Western civilization. I am a firm believer in intelligent design as a matter of faith and intellect. I believe intelligent design should be presented in schools alongside the theories of evolution. The exact phrase separation of Church and State came out of Adolph Hitlers mouth, thats where it comes from.
  • 23. Fixed and Absolute Positioning Fixed => fixed with respect to the “viewport” (i.e. what you see) Absolute => fixed with respect to its nearest ancestor that has declared “position: relative”
  • 25. DATA TYPES Javascript [language basics]
  • 26. BASIC SYNTAX Lines end with a semicolon Group code with braces: { }
  • 27. DATA TYPES Must interact with Javascript on its own terms It divides the world into six fundamental categories: • (1) Numbers • (2) Strings • (3) Booleans • (4) Functions • (5) Objects • (6) Undefined
  • 28. (1) NUMBERS & ARITHMETIC Can do all your basic arithmetic in Javascript Order of operations matters (as always) • Use parentheses for clarity Integer vs. floating point • “Floating point” => decimal
  • 29. (2) STRINGS Intuitively, a string is text • Must be enclosed in single or double quotes, e.g. “this is a string” and ‘so is this’
  • 30. (3) BOOLEANS Boolean is a fancy way of saying true or false
  • 31. BUZZZZWORD DRY => “Don’t Repeat Yourself” • Staying DRY is about efficiency and clarity • If you find yourself typing the same thing over and over, ask yourself whether you can dry off • Ways you’ll learn to stay dry: (1) variables, (2) functions, (3) modules
  • 32. VARIABLES Store data with an “arbitrary” name One of the most fundamental coding concepts var name; name = 17; console.log(name); // => 17
  • 33. ASSIGNMENT VS. EQUALITY “== != =” -Charlie Croom = • This is a command • Sets the value of a variable == and === • These are tests • Return Booleans (true or false)
  • 34. (4) FUNCTIONS The ultimate DRY Encapsulate common functionality function name( arg_1, ... arg_n ) { [ FUNCTION BODY ] }
  • 35. (4) FUNCTIONS Can “return a value” • Return undefined if no return value specified function name( arg_1, ... arg_n ) { var x; [ DO SOME STUFF WITH x ] return x; }
  • 36. CONTROL FLOW if • Execute some code if a certain condition pertains for • Execute some code a “definite” number of times while • Execute some code an “indefinite” number of times
  • 37. CONTROL FLOW: if if ( condition_1) { [ DO SOME STUFF ] } else if ( condition_2 ) { [ DO SOME OTHER STUFF ] } else { [ DO DEFAULT STUFF ] }
  • 38. CONTROL FLOW: for for ( var i = 0; i < 10; i++ ) { [ DO SOME STUFF ] } // That stuff will happen 10 times
  • 39. CONTROL FLOW: while while ( [SOME CONDITION OBTAINS] ) { [ KEEP DOING STUFF ] } // That stuff will keep happening until // the condition is false

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n