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

Silvia Correia
Silvia Correia
747 Points

Code not accepted

function returnValue (hours){ var echo = "I work " + hours + " a week"; return echo; } returnValue ("50h");

Why is this code not working?!

Interesting...I ran it in the console in Chrome. It worked if I entered the value as a string as you have done here. It didn't work when I ran returnValue(50h); with no quotes. I'm wondering if this is the problem? If you put it without quotes the interpreter will be looking for a variable named 50h which would be invalid as variables can't begin with numbers in JavaScript.

1 Answer

Brian Foley
Brian Foley
8,440 Points

Hello,

It looks like the challenge wants you to return the parameter of the function. Your parameter in this case is hours, so it'd look like this:

function returnValue (hours) { var echo = "I work " + hours + " a week"; return hours; }

Hope that helps! :)

Silvia Correia
Silvia Correia
747 Points

Hi Brian! Thanks for your help! It did work :)