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 trialammarkhan
Front End Web Development Techdegree Student 21,661 Pointswhich one is the argument?
I am stuck on a question which ask, what are the argument
function sum_two_numbers($one,$two) {
$sum = $one + $two;
return $sum;
}
$x = sum_two_numbers(1,5);
IMO, the argument is what is inside the brackets, but the quiz doesn't give me option. Instead it says in option either $one , $sum , $x.
2 Answers
Jennifer Nordell
Treehouse TeacherFor this challenge, they are expecting $one and $two as arguments. I would however argue that these are the parameters while the arguments would be 1 and 5. But it's semantics Some programmers use arguments and parameters interchangeably. But I'm picky
Antonio Rodrigues
2,306 Pointsthe arguments would be the variables $one and $two, because they are the values that you are passing into your function to work with. Arguments are external values that your function will work with, like in a mathematical function, f(x), x is the argument, because the value of the function varies according to the value of x.
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsAntonio Rodrigues I edited the question to put right values.
Jennifer Nordell
Treehouse Teacher@Anmar Khan then in that case the "arguments" would be $one and $two.
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsJennifer Nordell It has either option, or it says "All are considered args"
Jennifer Nordell
Treehouse TeacherAmmar Khan Not according to the question I'm looking at. The choices I'm presented are $one, $sum, $x, and "All three are considered arguments". In this case, the answer is $one.
Antonio Rodrigues
2,306 PointsUpdated! And Jennifer is totally right about the semantic distinction between arguments and parameters =).
ammarkhan
Front End Web Development Techdegree Student 21,661 Pointsammarkhan
Front End Web Development Techdegree Student 21,661 PointsJennifer Nordell i edited the question values, can you edit the answer accordingly.?