OpenBrackets
Intermediate Web Development
Week 6 Day 1
Welcome!
Welcome to class!
This is the Intermediate Web Development class. Make sure you’re in the right place!
We’ll be spending all of today tackling functions, which is one of the most important programming concepts.
How are you doing today?
On a scale of 1-10, how are you doing today and why?
Asking Questions
Type in chat
Or
Functions
Calling Functions and Function Parameters
Defining Functions
10 minute break!
Defining Functions
Defining Functions
function sayHello() {
console.log("Hello!")
}
When creating a function, we start with "function"
The name of this function is "sayHello"
After the function’s name, we put parentheses with any extra information our function needs (which is none for sayHello)
The function’s code goes between curly braces
This code will run whenever the function gets called
Defining Functions
function addFive(x) {
return x + 5
}
let result = addFive(8)
When creating a function, we start with "function"
The name of this function is "addFive"
Here, our function needs a number named x. Now we can use x like a variable name
The function’s code goes between curly braces
Functions can return a value, which can be used by the code that called it. Math.random and window.prompt are functions that return values.
Defining Functions
When you need help outside class
Email contact@openbrackets.us and say what class and teacher you have
If you are age 13 or older, you can try Discord
The age restriction is because of Discord’s Terms of Service
Thanks for coming to class!
Please let us know if you have any questions!