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 trialNaoki Tanaka
588 PointsIt looks like Task 1 is no longer passing. I have no idea what I should put in the function.
I put like this in task one: function (str){ return str; }
And second task, I put 'My argument' in parameter but I have no idea what I should do next. Please give me advice.
Thanks
function returnValue('my argument'){
var echo = returnvalue();
return 'my argument';
}
<!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>
2 Answers
Riku Wikman
7,744 PointsYou are trying to define a new function, to call a function with an argument you can just do this:
function returnValue(argument) {
return argument;
};
var echo = returnValue("My argument");
Stefan Osorio
16,419 PointsYour solution for task 1 was on the right track :) Task 2 asks you to pass the function a literal string value. This would look like this:
function returnValue(argument){
return argument;
}
returnValue('My argument');
"Passing" something to a function essentially means putting it into the parenthesis when you call it. Instead you replaced the arguments inside of the function definition, which wasn't what the task meant, and which broke task 1 - because a variable name can't have quotation marks around it.