Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Using the function print(message);
I don't quite understand how the function print(message) work? I thought the variable message inside the parenthesis has to be declared before the function can be executed?
Seth Kroger56,392 Points
When you define a function the parameters are automatically declared as variables within the function's body. There is no need to declare them separately.
I meant from the exercise they did, they didn't define the variable message in the function print().
Adam Beer11,304 Points
Simpliest way, just create a variable and give content to a string, like this
var myFirstPrint = "This is my first string when I learned how I can use print() method";
Now put your variable name into the print() method.
var myFirstPrint = "This is my first string when I learn how can use print() method"; print(myFirstPrint);
Print() method get a string, and print out your variable content. Hope this help!