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 trialBill Ertle
9,286 Pointspassing an argument to a function in javascript
even though this is pretty simple, i can seem to get it...any help would be much appreciated
function returnValue(number) {
var echo = "1";
return number;
}
returnValue("1");
<!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>
4 Answers
Galen Cook
2,463 PointsYou need to define echo
outside of the function, not inside it.
var echo = returnValue('apple');
Dustin McCaffree
14,310 PointsI'm a bit confused by your question, but from the looks of it, you are looking to do this:
function returnValue(number) {
return number;
}
returnValue(1);
This should return 1 as your number. Is this what you were attempting?
Bill Ertle
9,286 Pointssorry i didn't make this very clear, but i'm confused...i'm trying to get through a code challenge and i'm being asked to create the var echo before calling a function
Galen Cook
2,463 PointsDouble-check the prompt and see my answer -- it wants you to define echo AFTER the function, not before it.
Galen Cook
2,463 PointsDouble-check the prompt and see my answer -- it wants you to define echo AFTER the function, not before it.
Bill Ertle
9,286 Pointsthank you for your answers, galen and dustin