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!
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
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,412 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,314 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!