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 trialJason Lewis
Full Stack JavaScript Techdegree Student 4,854 PointsLOST!! HELP!!
I am lost as to how I use the float function in this challenge. Ive seen this code written & executed with the "int" variable (in the video "Functions"). I am totally lost on the concept of the mechanics & architecture of this code.
4 Answers
Rodrigo Chousal
16,009 PointsSo, in the code below you are just writing the implementation, not the declaration. In the declaration you create the function, and in the implementation you actually explain what that function will consist of (what it will do).
You begin by assuming that the function has already been implemented. So you write float (the type of value that the function will return) and then you write the name of that function, which in this case is addTwo. Right after writing the name of the previously created function, you insert the arguments that the function will take (float a, float b). Finally, between the curly braces, you do something with those variables (in this case, you add them).
float addTwo(float a, float b) {
return a + b;
}
Feel free to say so if you have any doubts :)
Rodrigo Chousal
16,009 PointsCould you post the instructions as a comment?
Jason Lewis
Full Stack JavaScript Techdegree Student 4,854 PointsSure... Sorry: "Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments. It should add the two arguments together, and return the result. (No need to write the main function. Just write out the implementation for the addTwo function.)"
Jason Lewis
Full Stack JavaScript Techdegree Student 4,854 PointsTHANKS!! WOW, I really over-thought that one!!