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 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;
  }
console.log(add10);

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,

Shari

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