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 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,850 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.