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 help please!!!

Here's the question:

Inside the function, return the sum of the num parameter and 10.

Bummer: The 'add10' function needs to return the sum of the 'num' parameter and the number 10.

My answer:

function add10(num) {
 return num = 10;

I keep getting an error. Any pointers? If you will be so kind as to explain your answer and what I did wrong I will be doubly appreciative.

Thanks in advance,


2 Answers

You need to invoke/call the function add10() and pass a number. However, the function will return 10 each time.

What you can do is return num + 10 and that will return any number you pass in, adding 10 to it.

function add10(num) {
      return  num  +  10;
console.log(add10(100)); // returns 110

Holy crap! It worked! And I totally understand why. Thank you!

sometimes its just silly, glad to know I am not allone!!!