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 JavaScript Quickstart Functions Write a Function

I really don't know what im doing

yeah

script.js
function add10(1) {
  return num + 10;
};
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

What you trying to do?

1 Answer

Cooper Runstein
Cooper Runstein
11,837 Points

I think what you're confused as to how arguments work in functions. Here's what you want:

function add10(num) { //This line is declaring  function named add10 that takes an argument named num
  return num + 10;
};

add10(1) //Call the add10 function and pass it the argument 1

You were trying to both create and call a function in one go, the point of functions is re-usability, you want to define the function in a way that can accept more than one argument, The code above will also let you pass 2 or 100 to the funciton.