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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Using For Loops with Arrays

Durdona Abdusamikovna
Durdona Abdusamikovna
1,553 Points

I 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.

Marcus Parsons

3 Answers

Hey 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
Durdona Abdusamikovna
1,553 Points

As 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

Absolutely 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

My pleasure!