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

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,814 Points

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