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 trialrovelle trinidad
390 PointsI really don't know what im doing
yeah
function add10(1) {
return num + 10;
};
<!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>
1 Answer
Cooper Runstein
11,850 PointsI 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.
reece tobin
Courses Plus Student 39 Pointsreece tobin
Courses Plus Student 39 PointsWhat you trying to do?