Your SlideShare is downloading. ×
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

JavaScript from Scratch: Getting Your Feet Wet

1,566

Published on

The first part of an 8 part series covering the basics of the JavaScript language. This presentation covers variables, conditionals, loops and functions.

The first part of an 8 part series covering the basics of the JavaScript language. This presentation covers variables, conditionals, loops and functions.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,566
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
62
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JavaScript From Scratch “Getting Your Feet Wet”
  • 2. Agenda • Variables • Conditionals • Loops • Functions
  • 3. Variables are... • Storage Containers for Data • Someone’s name • A username/password • The current time • ... or anything else your application needs
  • 4. var password = ‘mike is awesome’;
  • 5. var name = ‘Mike G’; var age = 25; var isCool = true;
  • 6. Conditionals are... • A way to execute code conditionally • If something is true, do this • Otherwise, do that
  • 7. var age = 25; if (age < 21) { alert(‘Go home’); }
  • 8. var age = 25; if (age < 21) { alert(‘Go home’); } else { alert(‘Two drink minimum’); }
  • 9. Loops • Loops allow code to run repeatedly • Over and over and over... • But only upon a condition
  • 10. var start = 10; var stop = 20; var counter = start; while (counter <= stop) { alert(counter); counter = counter + 1; }
  • 11. About those operators = var foo = 100;
  • 12. About those operators == (foo == 100)
  • 13. About those operators < (age < 21)
  • 14. About those operators > (calories > 2000)
  • 15. About those operators <= (age <= 21)
  • 16. About those operators >= (calories >= 2000)
  • 17. About those operators && (age >= 25 && age <= 50)
  • 18. About those operators || (name == ‘mike’ || name == ‘joe’)
  • 19. Functions • Store “blocks” of code so they can be reused later • Are one of the most powerful features of the JavaScript language
  • 20. function add () { alert(2 + 2); } add();
  • 21. function add (num1, num2) { alert(num1 + num2); } add(2, 2); add(42, 10); add(123, 0);
  • 22. function add (num1, num2) { return num1 + num2; } var sum1 = add(2, 2); var sum2 = add(42, 10); var sum3 = add(123, 0);
  • 23. Review • Variables... • Store data • Begin with a var • Are given names • Are assigned values with =
  • 24. Review • Conditionals... • Fork code execution based on a condition • Begin with an if • Condition enclosed in (parenthesis) • Blocks are enclosed in {curly braces}
  • 25. Review • Conditionals... • Can use else to catch a failed conditional
  • 26. Review • Loops... • Repeatedly execute blocks of code • Execute conditionally • Come in many flavors: • while, for, for in, do while
  • 27. Review • Functions... • Store code for later use • Can accept input parameters (arguments). • Can send output (return values).
  • 28. Homework • Build a micro-library which performs basic math operations • Functions should accept arguments and return the result of the math operation
  • 29. Homework • Required Functions: • add (num1, num2) • subtract (num1, num2) • multiply (num1, num2) • divide (num1, num2)
  • 30. Homework • Required Functions: • square (num) • increment (num) • decrement (num) • power (num, power)

×