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 trialDurdona Abdusamikovna
1,553 PointsI was reviewing learned materials about function
Hello there,
Here is a script
function message (parameter) {
document.write('Document message');
}
console.log(message ('passing argument'));
Why when I run this function document writes its message to the website but console doesn't.
3 Answers
Marcus Parsons
15,719 PointsHey Durdona,
The problem lies within your function. When you're passing in information to a function via a placeholder variable, you should use that variable to determine the output. So, you should change the string 'Document message' inside the function to the variable parameter
that way document.write() will receive the value passed into it in the form of the placeholder parameter
.
function message (parameter) {
document.write(parameter);
}
console.log(message('passing argument'));
Durdona Abdusamikovna
1,553 PointsAs I see all functions use parameter names within the function
function getRandomNumber(lower, upper){
var random = Math.floor(Math.random() * (upper - lower + 1)) + lower;
return random;
console.log(getRandomNumber (1, 6));
Thank you ! Didn't pay attention to time sorry
Marcus Parsons
15,719 PointsAbsolutely right! Nothing to be sorry about :) We all make mistakes, and so long as we learn from them, we keep on being awesome! haha :P
Durdona Abdusamikovna
1,553 PointsThank you :)
Marcus Parsons
15,719 PointsMy pleasure!