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 trialashique desai
3,662 Pointshow 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
Treehouse TeacherHi 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!
ashique desai
3,662 Pointsashique desai
3,662 PointsThanks again Jennifer, for a very descriptive answer.