Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor

Well done. As you can see, parameters work just like a variable inside a function, allowing us to pass data into a function that we want to operate on.

What if we wanted to use multiple parameters in a function? We can write it like this:

function sayHello(firstName, lastName) { console.log('Hello, my name is ' + firstName + " " + lastName); } sayHello('Jon', 'Snow');
  1. When we set up the function, we made two parameters separated by commas: firstName and lastName.
  2. Then, when we called sayHello, we set the two parameters equal to 'Jon' and 'Snow', also separated by commas.
  3. When the function runs, it will know that firstName equals 'Jon', and that lastName equals 'Snow'.
  4. When we call sayHello('Jon', 'Snow');, it will output (can you guess it?):
Hello, my name is Jon Snow
Report a Bug
If you see a bug or any other issue with this page, please report it here.