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 trialja5on
10,338 PointsBreakdown of a function
https://w.trhou.se/61zhq9z1na can someone please tell me what is the expression, declaration within this code.
Thanks.
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsThe declaration is the main body of the function from the keyword to what is in the curly braces. So you're writing a function that takes a parameter and in the console.log you have the function call and its argument.
console.log(getRandomNumber(10));
function getRandomNumber(upper) {
}
And inside, you're writing an expression and passing it to the Math.floor()
method.
Math.floor(Math.random() * upper ) + 1;