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 trialHilary Katsande
9,045 Pointscreate a new function named max
create a new function called max which accepts two numbers as arguments. thank you
function max (2)(4) {
return larger;
}
1 Answer
Cynthia Norwood
Front End Web Development Techdegree Graduate 15,214 PointsLet's see here is an example of a simple function that accepts two parameters. The function is called myFunction The parameters are p1 and p2 Then we can use the return statement to multiply p1 * p2. Next we call the function which is called myFunction, we call it like this myFunction(); Then I put in 2 random numbers to test myFunction. so we have myFunction(2, 4); And the output of that would be 8
function myFunction(p1, p2) {
return p1 * p2;
}
myFunction(2,4);
The output would be 8