Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Review: Giving Information to Functions

ashique desai
ashique desai
3,662 Points

how to pass the value '12' to this function?

Cannot solve this quiz. Tried with answering var = 12; in the blank space. And alert(getRandom + 12); as well to pass the value of 12 and call the function but that does not work. Please let me know how to solve this quiz.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Let's take a look at a sample function I wrote to demonstrate how we call a function and pass in an argument.

function sayHi(name){  //our function has one parameter
  alert("Hi there, " + name + "!");  //alert that will print out a greeting plus whatever name we send in
}

sayHi("ashique");  //call the function and pass in a name of our choosing

When we call a function we only need to write out the function name and include the argument/s in the parentheses that follow. In this case, I sent in your name. But hopefully you can extrapolate the answer from this example. Good luck! :sparkles:

ashique desai
ashique desai
3,662 Points

Thanks again Jennifer, for a very descriptive answer.