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 trialMirali Mirzayev
1,980 PointsChallenge Task 2 of 2
I am basically stuck in the second part of this challenge. I have created a new variable which stores the return values from the parameters above it. At lear i think i have? Could somebody tell me what i am doing wrong:
function returnValue (location){ var echo = location; return location ; } returnValue(location);
Thank you!
function returnValue (location){
var echo = location;
return location;
}
returnValue("Azer");
<!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
Aakash Srivastava
5,415 PointsHey friend Mirali Mirzayev ,
First , you need to create a function that returns a value . Here is the code :
function returnValue(name) {
return name;
}
Now , you need to create a variable echo which stores the return value from the function . You can do this by calling the function with any argument , and then assigning the result to the variable echo like this:
const echo = returnValue("foo");
Here is the whole code:
function returnValue(name) {
return name;
}
const echo = returnValue("foo");
Hope it helped :)
Mirali Mirzayev
1,980 PointsHello again Sunny,
Thank you for your help, and yes i actually arrived to that questions answer yesterday after asking you. It was a silly question but thank you for helping me and explaining it all to me in depth.
Aakash Srivastava
5,415 PointsIt's the silliest mistakes that teaches us great lessons . We all face the same . So , no mistakes are silly , because it teaches us a lesson . So , keep asking questions :)
Most welcome :)
Mirali Mirzayev
1,980 PointsMirali Mirzayev
1,980 PointsHello Sunny,
But why const, i actually tried it but instead of const i had VAR for variable. I am just little bit confused now.
Aakash Srivastava
5,415 PointsAakash Srivastava
5,415 PointsHey Mirali Mirzayev , both are right here.
const
andlet
are introduced in ES6 , so it's just a newer syntax .You will get introdced to them and lots of other changes too that made in ES6 , in upcoming courses , don't worry .
Till then you can use
var
.And that doesn't matter here , what matters is you must store the returned value in the echo variable , which may be a var or const .
Hope it helped :)