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 Basics (Retired) Creating Reusable Code with Functions Passing an Argument to a Function

Why does the lesson tell me to put in a return?

I have the alert to show that the code is working, but it gives me an error saying to make a new return.

function returnValue( upper ) {
  var Value = Math.floor(Math.random() * upper ) + 1;
  return Value;
alert( returnValue( 10 ));
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

2 Answers

Hey Christian!

Your function is valid and it works fine but this is not what the challenge is asking you to do. You need to return the parameter of your function inside of its code and then outside of the function is where you would write the code for the second task. Something like this:

function returnValue(upper) {
  return upper;
// code for Task 2

Thanks! I've tried different things, like alerting 'Hello', and that worked before. I should have connected the dots. Have a good day and thank you again.