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 trialJose Esplana
12,503 PointsCan someone please show me how to solve this code challenge or show me where's the link
https://teamtreehouse.com/library/javascript-basics/creating-reusable-code-with-functions/create-a-max-function https://teamtreehouse.com/library/javascript-basics/creating-reusable-code-with-functions/passing-an-argument-to-a-function
function returnValue(x) {
var echo = x;
return echo;
}
alert(returnValue('string'));
Q2
function max(number1, number2) {
if (number1 > number2) {
return number1;
}
else {
return number2;
}
console.log(max(5,20));
<!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
Jamila Cornick
4,465 Pointsfor the first one :
function returnValue(x) { return x; }
var echo = returnValue('string');
The second one you needed a closing bracket for the first part
function max(number1, number2) { if (number1 > number2) { return number1; } else { return number2; } } /here/
alert(max(5,20)); /* and here you needed to use alert() method instead of console.log() */
Jose Esplana
12,503 PointsHi Jamila, Thank you for your help! Do you know any other sites where I can practice more of this problems?
Anna Gibson
Front End Web Development Techdegree Student 4,468 PointsYou can practice here: https://codefights.com/
If you're into videogames you can always do this one as well... https://codecombat.com/
Jamila Cornick
4,465 PointsJamila Cornick
4,465 PointsHey Jose sorry to answer back so late, some other resources I use are freecodecamp.com and codecademy.com