Front-End
Web Development
Lesson 8
Functions
Agenda
●
●
●
●
●

Review Pizza Project
JavaScript Functions
Parameters and arguments
The return keyword
Lab
Functions
A function is a series of programming steps that
you set up at the beginning of your script
●
●
●

write code on...
Functions
Basic structure:
function functionName() {
// the JavaScript you want to run
}
Functions
Naming functions (examples):
● calculateTax()
● getScreenHeight()
● updatePage()
● fadeImage()
Cannot use JavaSc...
Code Along
Need template.html and two css files.
Save template.html as print_date.html
Two steps:
● create function in hea...
Built-In Functions
JavaScript Built-in Functions
String Methods
toLowerCase()
Date Methods
toDateString()
Parameters & Arguments
Parameters are variables used to accept
information into a function.
Arguments are values used to s...
Parameters & Arguments
Example:
function print(message) {
document.write(message);
}

parameter

argument

print(‘Example ...
Code Along
parameters.html
Retrieving Info from Functions
To return a value from your own functions, use
the return keyword.
Notes:
● the return keyw...
Retrieving Info from Functions
Example:
function functionName(parameter1, parameter2) {
// the JavaScript you want to run
...
Code Along
tax.html
quiz.html
Lab
Create a quiz (at least five questions) testing
the user’s knowledge on the HTML, CSS and
JavaScript you’ve learned so...
Lab
Build out pizza site:
● add date
● add sales tax function
Create index page for your server
Upcoming SlideShare
Loading in …5
×

Lesson 08

315 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
315
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Lesson 08

  1. 1. Front-End Web Development Lesson 8 Functions
  2. 2. Agenda ● ● ● ● ● Review Pizza Project JavaScript Functions Parameters and arguments The return keyword Lab
  3. 3. Functions A function is a series of programming steps that you set up at the beginning of your script ● ● ● write code once run code any time you like run code as many times as you like
  4. 4. Functions Basic structure: function functionName() { // the JavaScript you want to run }
  5. 5. Functions Naming functions (examples): ● calculateTax() ● getScreenHeight() ● updatePage() ● fadeImage() Cannot use JavaScript reserved words
  6. 6. Code Along Need template.html and two css files. Save template.html as print_date.html Two steps: ● create function in head ● call function in body
  7. 7. Built-In Functions JavaScript Built-in Functions String Methods toLowerCase() Date Methods toDateString()
  8. 8. Parameters & Arguments Parameters are variables used to accept information into a function. Arguments are values used to supply information to a function.
  9. 9. Parameters & Arguments Example: function print(message) { document.write(message); } parameter argument print(‘Example of parameters and arguments’);
  10. 10. Code Along parameters.html
  11. 11. Retrieving Info from Functions To return a value from your own functions, use the return keyword. Notes: ● the return keyword should be the last statement in a function ● a function can only return one value
  12. 12. Retrieving Info from Functions Example: function functionName(parameter1, parameter2) { // the JavaScript you want to run return value; }
  13. 13. Code Along tax.html quiz.html
  14. 14. Lab Create a quiz (at least five questions) testing the user’s knowledge on the HTML, CSS and JavaScript you’ve learned so far. ● make functional first ● make stylish last ● upload to server ● ask classmates to take the quiz
  15. 15. Lab Build out pizza site: ● add date ● add sales tax function Create index page for your server

×