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 trialAndrew Ginzberg
Courses Plus Student 1,900 PointsaddTwo function
I am having a great deal of difficulty getting past this challenge. I have even looked up function for adding two numbers online, and still cannot get the answer. can anyone help me?
2 Answers
Dennis Walsh
5,793 PointsAndrew,
Can you clarify which part you are having trouble with? You need to define a function which takes two parameters (of type float) and returns the sum of those parameters (also a float). The basic syntax for defining a function is as follows:
(return_type)functionName(type parameter_one, type parameter_two)
{
//add the two numbers together and return the result
}
Carlos Martell
496 PointsThey are asking you to return a float as a result. In the tutorial they return integers. What you have to do is this:
float addTwo(float a, float b){
return a+b;
}
Andrew Ginzberg
Courses Plus Student 1,900 PointsAndrew Ginzberg
Courses Plus Student 1,900 Pointsi have tried this several times, looked back at the function tutorial, and still cannot understand what exactly I am doing wrong.