Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Vince Leung
Vince Leung
4,730 Points

Javascript function not working.

I can't seem to get my simple function code to work. Am i missing something?

function returnValue(math){
 var addition = math + 10;
 return addition; 
}

console.log( returnValue (12) );

Hey vince I run your code in my system as well as in browser console and i found it is working. I got 22 as a return value in console

Vince Leung
Vince Leung
4,730 Points

Thanks Ashish. Maybe has to do with spacing or formating of my code, i heard treehouse challenges has to have a specific formating an order for your code to pass.

In terms of my code, i keep getting this message " Bummer! Make sure you return the argument that's passed into the function. In other words type return, a space, and the parameter name."

can u please paste the link of challenge

Vince Leung
Vince Leung
4,730 Points

I'm not 100% sure if this is going to work but: https://teamtreehouse.com/library/javascript-basics/creating-reusable-code-with-functions/passing-an-argument-to-a-function

If not, it is called "Challenge Task 1 of 2" under javascript basics

Vince Leung
Vince Leung
4,730 Points

Great! appreciate it, maybe i just made the challenge little too complicated LOL

Thanks Ashish appreciate it!

Vince

your welcome and happy coding

1 Answer

try this it will work as u only need to do these thing in challenge

function returnValue(math){
  return math;
}
var echo = returnValue("Hy");
rydavim
rydavim
18,786 Points

I've changed your comment to an answer so that it may be voted on or marked as best answer.