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 trialSamuel Joseph
5,406 PointsI am trying to return 5, but it keeps telling me that I am wrong. def five(b) b = 5 return b end
How can I find my correct answer based on what I have input?
def three(a)
a = 3
return a
end
def five(b)
b = 5
return b
end
1 Answer
andren
28,558 PointsThe issue is that you have defined parameters for the functions. Parameters are the thing you write within the parenthesis of the function definition. They are used to pass data into a function when it is called, since your functions are not meant to have data passed to them they should not have parameters.
Like this:
def three() # Don't declare "a" as a parameter
a = 3
return a
end
def five() # Don't declare "b" as a parameter
b = 5
return b
end
Also while not invalid it is not really necessary to assign the numbers to a variable if you are just going to return them right away. You can instead just return the numbers directly.
Like this:
def three()
return 3
end
def five()
return 5
end